diff options
-rw-r--r-- | compilerplugins/clang/compat.hxx | 18 | ||||
-rw-r--r-- | compilerplugins/clang/salbool.cxx | 8 |
2 files changed, 22 insertions, 4 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 6c1152c1fc9b..cd3cb3af89ee 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -256,6 +256,24 @@ inline void addPPCallbacks( #endif } +inline bool isMacroArgExpansion( + clang::CompilerInstance& compiler, clang::SourceLocation location, + clang::SourceLocation * startLocation) +{ +#if CLANG_VERSION >= 30900 + return compiler.getSourceManager().isMacroArgExpansion( + location, startLocation); +#else + bool b = compiler.getSourceManager().isMacroArgExpansion(location); + if (b) { + startLocation* = compiler.getSourceManager() + .getSLocEntry(compiler.getSourceManager().getFileID(location)) + .getExpansion().getExpansionLocStart(); + } + return b; +#endif +} + inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::SourceLocation location) { #if CLANG_VERSION >= 30300 diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx index ed61b2d8e55a..6b3d8df0fac5 100644 --- a/compilerplugins/clang/salbool.cxx +++ b/compilerplugins/clang/salbool.cxx @@ -284,12 +284,12 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) { compiler.getSourceManager().getImmediateMacroCallerLoc( loc)); if (!isFromCIncludeFile(callLoc)) { - if (compiler.getSourceManager().isMacroArgExpansion( - expr->getLocStart()) + SourceLocation argLoc; + if (compat::isMacroArgExpansion( + compiler, expr->getLocStart(), &argLoc) //TODO: check its the complete (first) arg to the macro && (Lexer::getImmediateMacroName( - expr->getLocStart(), - compiler.getSourceManager(), + argLoc, compiler.getSourceManager(), compiler.getLangOpts()) == "CPPUNIT_ASSERT_EQUAL")) { |