Skip to content

Commit 592d79b

Browse files
committed
f((x))
1 parent 5bb6af6 commit 592d79b

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

clang-tools-extra/clang-tidy/performance/LostStdMoveCheck.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ void LostStdMoveCheck::registerMatchers(MatchFinder* Finder) {
7070
hasDeclaration(
7171
varDecl(hasAncestor(functionDecl().bind("func"))).bind("decl")),
7272

73-
hasParent(expr(hasParent(cxxConstructExpr())).bind("use_parent")))
73+
anyOf(
74+
75+
// f(x)
76+
hasParent(expr(hasParent(cxxConstructExpr())).bind("use_parent")),
77+
78+
// f((x))
79+
hasParent(parenExpr(hasParent(
80+
expr(hasParent(cxxConstructExpr())).bind("use_parent"))))
81+
82+
)
83+
84+
)
7485
.bind("use"),
7586
this);
7687
}
@@ -112,14 +123,14 @@ void LostStdMoveCheck::check(const MatchFinder::MatchResult& Result) {
112123
return;
113124
}
114125

115-
116-
const SourceManager &Source = Result.Context->getSourceManager();
117-
const auto Range = CharSourceRange::getTokenRange(LastUsage->getSourceRange());
118-
const StringRef NeedleExprCode = Lexer::getSourceText(
119-
Range, Source,
120-
Result.Context->getLangOpts());
126+
const SourceManager& Source = Result.Context->getSourceManager();
127+
const auto Range =
128+
CharSourceRange::getTokenRange(LastUsage->getSourceRange());
129+
const StringRef NeedleExprCode =
130+
Lexer::getSourceText(Range, Source, Result.Context->getLangOpts());
121131
diag(LastUsage->getBeginLoc(), "could be std::move()")
122-
<< FixItHint::CreateReplacement(Range, ("std::move(" + NeedleExprCode + ")").str());
132+
<< FixItHint::CreateReplacement(
133+
Range, ("std::move(" + NeedleExprCode + ")").str());
123134
}
124135

125136
} // namespace clang::tidy::performance

0 commit comments

Comments
 (0)