[Libreoffice-commits] core.git: compilerplugins/clang
Stephan Bergmann
sbergman at redhat.com
Thu Apr 21 10:07:42 UTC 2016
compilerplugins/clang/compat.hxx | 18 ++++++++++++++++++
compilerplugins/clang/salbool.cxx | 8 ++++----
2 files changed, 22 insertions(+), 4 deletions(-)
New commits:
commit 8d934b73ccac14c76f6596c33b087e22ba82be09
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Apr 21 12:05:48 2016 +0200
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
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 6c1152c..cd3cb3a 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 ed61b2d..6b3d8df 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"))
{
More information about the Libreoffice-commits
mailing list