From c66274ef10279ad849b6a4ad0c41a736234ed08b Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Thu, 22 Nov 2018 03:01:38 +0330 Subject: update --- cgrep.cpp | 20 ++++++++++++++------ 1 file 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 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("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("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(); -- cgit v1.2.3