diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-12-18 14:11:58 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-12-18 22:43:29 +0100 |
commit | 9ed9ca611a6abfe3096379ba52a56fd53f07d5a1 (patch) | |
tree | f8a8401568899ac6f62c6f44997c5263aa34c19e /compilerplugins | |
parent | dbbd2c48b157214fd3e4b912e25ffd0b02976fa4 (diff) |
loplugin:stringconcat: Adapt to definition of OSL_THIS_FUNC on Windows
Change-Id: I9a2be8c4265095ff2ac5e2216cb08c35c9049bf8
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/stringconcat.cxx | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/compilerplugins/clang/stringconcat.cxx b/compilerplugins/clang/stringconcat.cxx index fe842f6162e7..a944f4fcf319 100644 --- a/compilerplugins/clang/stringconcat.cxx +++ b/compilerplugins/clang/stringconcat.cxx @@ -36,10 +36,6 @@ Expr const * stripCtor(Expr const * expr) { return e3->getArg(0)->IgnoreParenImpCasts(); } -bool isStringLiteral(Expr const * expr) { - return isa<clang::StringLiteral>(stripCtor(expr)); -} - class StringConcat: public RecursiveASTVisitor<StringConcat>, public loplugin::Plugin { @@ -50,6 +46,9 @@ public: { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } bool VisitCallExpr(CallExpr const * expr); + +private: + bool isStringLiteral(Expr const * expr); }; bool StringConcat::VisitCallExpr(CallExpr const * expr) { @@ -109,6 +108,24 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) { return true; } +bool StringConcat::isStringLiteral(Expr const * expr) { + expr = stripCtor(expr); + if (!isa<clang::StringLiteral>(expr)) { + return false; + } + // OSL_THIS_FUNC may be defined as "" in include/osl/diagnose.h, so don't + // warn about expressions like 'SAL_INFO(..., OSL_THIS_FUNC << ":")' or + // 'OUString(OSL_THIS_FUNC) + ":"': + auto loc = expr->getLocStart(); + while (compiler.getSourceManager().isMacroArgExpansion(loc)) { + loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); + } + return !compiler.getSourceManager().isMacroBodyExpansion(loc) + || (Lexer::getImmediateMacroName( + loc, compiler.getSourceManager(), compiler.getLangOpts()) + != "OSL_THIS_FUNC"); +} + loplugin::Plugin::Registration<StringConcat> X("stringconcat"); } |