From cf4e229615f84653e47ec54a3035eb2ff1f454cc Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sat, 29 Sep 2018 14:51:57 +0330 Subject: with a few minor tweaks, you can build m0, obfuscator and bruiser with llvm 8.0(latest tested:trunk 340121). we are skipping llvm 7.0. Ill keep backwards compatibility with 5.0 or 6.0 for a good while. --- bruiser/bruiser.cpp | 24 ++++++++++++------------ bruiser/bruiser.h | 8 ++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'bruiser') diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index ae6db23..726f963 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -661,10 +661,10 @@ public: if (MR.Nodes.getNodeAs("mainwrapper") != nullptr) { const FunctionDecl* FD = MR.Nodes.getNodeAs("mainwrapper"); - SourceLocation SL = FD->getLocStart(); + SourceLocation SL = FD->DEVI_GETLOCSTART(); CheckSLValidity(SL); SL = Devi::SourceLocationHasMacro(SL, Rewrite); - SourceLocation SLE = FD->getLocEnd(); + SourceLocation SLE = FD->DEVI_GETLOCEND(); CheckSLValidity(SLE); SLE = Devi::SourceLocationHasMacro(SLE, Rewrite); @@ -695,7 +695,7 @@ class LiveListFuncs : public MatchFinder::MatchCallback { if (MR.Nodes.getNodeAs("livelistfuncs") != nullptr) { const clang::FunctionDecl* FD = MR.Nodes.getNodeAs("livelistfuncs"); - SourceLocation SL = FD->getLocStart(); + SourceLocation SL = FD->DEVI_GETLOCSTART(); CheckSLValidity(SL); SL = Devi::SourceLocationHasMacro(SL, R); @@ -705,13 +705,13 @@ class LiveListFuncs : public MatchFinder::MatchCallback { if (FD->hasBody()) { Stmt* Body = FD->getBody(); - SourceLocation SLBody = Body->getLocStart(); - SourceLocation SLShebang = FD->getLocStart(); + SourceLocation SLBody = Body->DEVI_GETLOCSTART(); + SourceLocation SLShebang = FD->DEVI_GETLOCSTART(); PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(clang::SourceRange(SLShebang, SLBody.getLocWithOffset(-1))).c_str()); PushToLua.push_back(R.getRewrittenText(clang::SourceRange(SLShebang, SLBody.getLocWithOffset(-1)))); } else { - SourceLocation SL = FD->getLocStart(); - SourceLocation SLE = FD->getLocEnd(); + SourceLocation SL = FD->DEVI_GETLOCSTART(); + SourceLocation SLE = FD->DEVI_GETLOCEND(); PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(clang::SourceRange(SL, SLE)).c_str()); PushToLua.push_back(R.getRewrittenText(clang::SourceRange(SL, SLE))); } @@ -730,7 +730,7 @@ class LiveListVars : public MatchFinder::MatchCallback { if (MR.Nodes.getNodeAs("livelistvars") != nullptr) { const clang::VarDecl* VD = MR.Nodes.getNodeAs("livelistvars"); - SourceLocation SL = VD->getLocStart(); + SourceLocation SL = VD->DEVI_GETLOCSTART(); CheckSLValidity(SL); SL = Devi::SourceLocationHasMacro(SL, R); @@ -738,8 +738,8 @@ class LiveListVars : public MatchFinder::MatchCallback { return void(); } - PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(SourceRange(VD->getLocStart(), VD->getLocEnd())).c_str()); - PushToLua.push_back(R.getRewrittenText(SourceRange(VD->getLocStart(), VD->getLocEnd()))); + PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(SourceRange(VD->DEVI_GETLOCSTART(), VD->DEVI_GETLOCEND())).c_str()); + PushToLua.push_back(R.getRewrittenText(SourceRange(VD->DEVI_GETLOCSTART(), VD->DEVI_GETLOCEND()))); } } @@ -755,8 +755,8 @@ class LiveListRecords : public MatchFinder::MatchCallback { if (MR.Nodes.getNodeAs("livelistvars") != nullptr) { const clang::RecordDecl* RD = MR.Nodes.getNodeAs("livelistvars"); - PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(SourceRange(RD->getLocStart(), RD->getLocEnd())).c_str()); - PushToLua.push_back(R.getRewrittenText(SourceRange(RD->getLocStart(), RD->getLocEnd()))); + PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(SourceRange(RD->DEVI_GETLOCSTART(), RD->DEVI_GETLOCEND())).c_str()); + PushToLua.push_back(R.getRewrittenText(SourceRange(RD->DEVI_GETLOCSTART(), RD->DEVI_GETLOCEND()))); } } diff --git a/bruiser/bruiser.h b/bruiser/bruiser.h index 1e54d34..d91bae2 100644 --- a/bruiser/bruiser.h +++ b/bruiser/bruiser.h @@ -47,6 +47,14 @@ namespace bruiser /**********************************************************************************************************************/ const char* M0REP = "../test/misrareport.xml"; /**********************************************************************************************************************/ +#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 JOIN2(x1, x2) x1##x2 #define JOIN3(x1, x2, x3) x1##x2##x3 -- cgit v1.2.3