diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-04-21 12:05:48 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-04-21 12:05:48 +0200 |
commit | 8d934b73ccac14c76f6596c33b087e22ba82be09 (patch) | |
tree | 45891f4c7dbbdde207f4bfa771550c93b591e8d8 /compilerplugins | |
parent | b481d42e56c9585a3a6018ee851dcca41e89666f (diff) |
Better fix for 13758a3d154e8e450fdfe8bcdeb6b3a03996c53a
"SourceManager::isMacroArgExpansion has only one param in older Clang", which
caused false positives like warning about sal_False in
CPPUNIT_ASSERT_EQUAL(guard.p->m1, sal_False);
in cppu/qa/cppumaker/test_cppumaker.cxx
Change-Id: I1c5a67527aef381e336d71cb8fefbb87961bbf96
Diffstat (limited to 'compilerplugins')
-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")) { |