loplugin:stringconcat: Handle base case of recursion into left arg
Change-Id: I9ed8586e8b77b009d55e411fdaa863eefc38b1c2
This commit is contained in:
@@ -39,8 +39,12 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CallExpr const * left = dyn_cast<CallExpr>(
|
SourceLocation leftLoc;
|
||||||
expr->getArg(0)->IgnoreParenImpCasts());
|
auto const leftExpr = expr->getArg(0)->IgnoreParenImpCasts();
|
||||||
|
if (isa<StringLiteral>(leftExpr)) {
|
||||||
|
leftLoc = leftExpr->getLocStart();
|
||||||
|
} else {
|
||||||
|
CallExpr const * left = dyn_cast<CallExpr>(leftExpr);
|
||||||
if (left == nullptr) {
|
if (left == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -56,6 +60,8 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
leftLoc = left->getArg(1)->getLocStart();
|
||||||
|
}
|
||||||
StringRef name {
|
StringRef name {
|
||||||
compiler.getSourceManager().getFilename(
|
compiler.getSourceManager().getFilename(
|
||||||
compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) };
|
compiler.getSourceManager().getSpellingLoc(expr->getLocStart())) };
|
||||||
@@ -70,8 +76,7 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
|
|||||||
"replace '%0' between string literals with juxtaposition",
|
"replace '%0' between string literals with juxtaposition",
|
||||||
op == nullptr ? expr->getExprLoc() : op->getOperatorLoc())
|
op == nullptr ? expr->getExprLoc() : op->getOperatorLoc())
|
||||||
<< (oo == OverloadedOperatorKind::OO_Plus ? "+" : "<<")
|
<< (oo == OverloadedOperatorKind::OO_Plus ? "+" : "<<")
|
||||||
<< SourceRange(
|
<< SourceRange(leftLoc, expr->getArg(1)->getLocEnd());
|
||||||
left->getArg(1)->getLocStart(), expr->getArg(1)->getLocEnd());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user