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 |
|
|