@@ -70,7 +70,18 @@ void LostStdMoveCheck::registerMatchers(MatchFinder* Finder) {
70
70
hasDeclaration (
71
71
varDecl (hasAncestor (functionDecl ().bind (" func" ))).bind (" decl" )),
72
72
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
+ )
74
85
.bind (" use" ),
75
86
this );
76
87
}
@@ -112,14 +123,14 @@ void LostStdMoveCheck::check(const MatchFinder::MatchResult& Result) {
112
123
return ;
113
124
}
114
125
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 ());
121
131
diag (LastUsage->getBeginLoc (), " could be std::move()" )
122
- << FixItHint::CreateReplacement (Range, (" std::move(" + NeedleExprCode + " )" ).str ());
132
+ << FixItHint::CreateReplacement (
133
+ Range, (" std::move(" + NeedleExprCode + " )" ).str ());
123
134
}
124
135
125
136
} // namespace clang::tidy::performance
0 commit comments