aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-11-21 23:31:38 +0000
committerbloodstalker <thabogre@gmail.com>2018-11-21 23:31:38 +0000
commitc66274ef10279ad849b6a4ad0c41a736234ed08b (patch)
tree9362cb1895089fc6d5206116e36e7011e400b486
parentupdate (diff)
downloadcgrep-c66274ef10279ad849b6a4ad0c41a736234ed08b.tar.gz
cgrep-c66274ef10279ad849b6a4ad0c41a736234ed08b.zip
update
Diffstat (limited to '')
-rw-r--r--cgrep.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/cgrep.cpp b/cgrep.cpp
index 21a2a4e..1c4ab3f 100644
--- a/cgrep.cpp
+++ b/cgrep.cpp
@@ -71,6 +71,14 @@ cl::opt<int> CO_B("B", cl::desc("same as grep, howm many lines before the matche
#define REGEX_PP(RX_STR) regex_preprocessor(RX_STR)
#endif
+#if __clang_major__ <= 6
+#define DEVI_GETLOCSTART getLocStart
+#define DEVI_GETLOCEND getLocEnd
+#elif __clang_major__ >= 8
+#define DEVI_GETLOCSTART getBeginLoc
+#define DEVI_GETLOCEND getEndLoc
+#endif
+
#define RED "\033[1;31m"
#define CYAN "\033[1;36m"
#define GREEN "\033[1;32m"
@@ -229,7 +237,7 @@ public:
if (!Devi::IsTheMatchInMainFile(CO_MAINFILE, MR, SL)) return void();
std::string name = VD->getNameAsString();
if (regex_handler(REGEX_PP(CO_REGEX), name)) {
- std::cout << YELLOW << MR.SourceManager->getSpellingColumnNumber(VD->getLocation()) << ":"<< MR.SourceManager->getSpellingColumnNumber(VD->getEndLoc()) << NORMAL << "\n";
+ std::cout << YELLOW << MR.SourceManager->getSpellingColumnNumber(VD->getLocation()) << ":"<< MR.SourceManager->getSpellingColumnNumber(VD->DEVI_GETLOCEND()) << NORMAL << "\n";
//std::cout << BLUE << ID->getLength() << NORMAL << "\n";
output_handler(MR, SR, *MR.SourceManager, true);
}
@@ -332,7 +340,7 @@ public:
if (!Devi::IsTheMatchInMainFile(CO_MAINFILE, MR, SL)) return void();
std::string name = RD->getNameAsString();
if (regex_handler(REGEX_PP(CO_REGEX), name)) {
- output_handler(MR, SourceRange(RD->getBeginLoc(), RD->getEndLoc()), *MR.SourceManager, true);
+ output_handler(MR, SourceRange(RD->DEVI_GETLOCSTART(), RD->DEVI_GETLOCEND()), *MR.SourceManager, true);
}
}
}
@@ -420,8 +428,8 @@ class DeclRefExprHandler : public MatchFinder::MatchCallback {
virtual void run(const MatchFinder::MatchResult &MR) {
const DeclRefExpr* DRE = MR.Nodes.getNodeAs<clang::DeclRefExpr>("declrefexpr");
if (DRE) {
- SourceLocation SL = DRE->getBeginLoc();
- SourceLocation SLE = DRE->getEndLoc();
+ SourceLocation SL = DRE->DEVI_GETLOCSTART();
+ SourceLocation SLE = DRE->DEVI_GETLOCEND();
CheckSLValidity(SL);
SL = Devi::SourceLocationHasMacro(SL, Rewrite, "start");
if (Devi::IsTheMatchInSysHeader(CO_SYSHDR, MR, SL)) return void();
@@ -446,8 +454,8 @@ class CallExprHandler : public MatchFinder::MatchCallback {
virtual void run(const MatchFinder::MatchResult &MR) {
const CallExpr* CE = MR.Nodes.getNodeAs<clang::CallExpr>("callexpr");
if (CE) {
- SourceLocation SL = CE->getBeginLoc();
- SourceLocation SLE = CE->getEndLoc();
+ SourceLocation SL = CE->DEVI_GETLOCSTART();
+ SourceLocation SLE = CE->DEVI_GETLOCEND();
CheckSLValidity(SL);
SL = Devi::SourceLocationHasMacro(SL, Rewrite, "start");
if (Devi::IsTheMatchInSysHeader(CO_SYSHDR, MR, SL)) return void();