[PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'
Etienne Bergeron via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 25 14:26:35 PDT 2016
etienneb added inline comments.
================
Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:73
@@ +72,3 @@
+ Finder->addMatcher(
+ callExpr(allOf(callee(functionDecl(matchesName("::memcpy"))),
+ argumentCountIs(3)))
----------------
It's more efficient to use hasAnyName and merge the three following matcher.
That way, you won't need the function 'getCallExpr' to retrieve the CallExpr.
================
Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:80
@@ +79,3 @@
+ Finder->addMatcher(
+ callExpr(allOf(callee(functionDecl(matchesName("::memmove"))),
+ argumentCountIs(3)))
----------------
allOf is not needed.
================
Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:106
@@ +105,3 @@
+ const auto *MatchedExpr = getCallExpr(Result);
+ const auto MatchedName = MatchedExpr->getDirectCallee()->getNameAsString();
+ const auto ReplacedName = Replacements[MatchedName];
----------------
Instead of DirectCallee, you could add a "bind" to the Matcher : functionDecl(...).bind("callee")
================
Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:107
@@ +106,3 @@
+ const auto MatchedName = MatchedExpr->getDirectCallee()->getNameAsString();
+ const auto ReplacedName = Replacements[MatchedName];
+
----------------
What is the name is not in the map?
https://reviews.llvm.org/D22725
More information about the cfe-commits
mailing list