@@ -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