Kaydet (Commit) 9ed9ca61 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:stringconcat: Adapt to definition of OSL_THIS_FUNC on Windows

Change-Id: I9a2be8c4265095ff2ac5e2216cb08c35c9049bf8
üst dbbd2c48
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment