xaizek / for-postfix (License: GPLv2+) (since 2018-12-07)
Clang-based standalone tool that detects for-loops with postfix operators.
Commit 40b769b50b74a0e3c0d8dd1a279d005a051dbc36

Print out found issues in parseable format
<path to source file>:<linenumber>:<description>
Author: xaizek
Author date (UTC): 2014-03-24 19:52
Committer name: xaizek
Committer date (UTC): 2014-03-24 19:52
Parent(s): f2bd84a633c0a7dfbda7f33e3c9596191f4f8bc1
Signing key:
Tree: ff6767fac83c90d26ba972b7c660f11dfad93299
File Lines added Lines deleted
for-postfix.cpp 16 3
File for-postfix.cpp changed (mode: 100644) (index e024d91..6cb18b5)
7 7 #include <clang/Tooling/CommonOptionsParser.h> #include <clang/Tooling/CommonOptionsParser.h>
8 8 #include <clang/Tooling/Tooling.h> #include <clang/Tooling/Tooling.h>
9 9
10 #include <clang/Basic/SourceLocation.h>
11 #include <clang/Basic/SourceManager.h>
12
13 using namespace clang;
10 14 using namespace clang::ast_matchers; using namespace clang::ast_matchers;
11 15 using namespace clang::tooling; using namespace clang::tooling;
12 16
 
... ... public:
57 61
58 62 private: private:
59 63 void printOut(const MatchFinder::MatchResult &result, void printOut(const MatchFinder::MatchResult &result,
60 const clang::Expr *expr) const
64 const Expr *expr) const
61 65 { {
62 expr->dump();
63 std::cout << '\n';
66 FullSourceLoc fullLoc(expr->getLocStart(), *result.SourceManager);
67
68 const std::string &fileName = result.SourceManager->getFilename(fullLoc);
69 const unsigned int lineNum = fullLoc.getSpellingLineNumber();
70
71 std::cout << fileName
72 << ":"
73 << lineNum
74 << ":"
75 << "dangerous use of postfix operator"
76 << '\n';
64 77 } }
65 78 }; };
66 79
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/for-postfix

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/for-postfix

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master