[PATCH] D11677: [clang-tidy] Support replacements in macro arguments in misc-inefficient-algorithm

Alexander Kornienko alexfh at google.com
Fri Jul 31 06:00:44 PDT 2015

alexfh added inline comments.

Comment at: clang-tidy/misc/InefficientAlgorithmCheck.cpp:114-118
@@ +113,7 @@
+  if (SM.isMacroArgExpansion(CallRange.getBegin()) &&
+      SM.isMacroArgExpansion(CallRange.getEnd())) {
+    CallRange.setBegin(SM.getSpellingLoc(CallRange.getBegin()));
+    CallRange.setEnd(SM.getSpellingLoc(CallRange.getEnd()));
+  }
klimek wrote:
> Any reason we don't want to use Lexer::makeFileCharRange here (which should handle all the cases correctly).
It was the first thing I tried, but it gets the test case wrong, i.e. it replaces the whole macro invocation instead of just the argument:

#define SECOND(x, y, z) y
  SECOND(q,std::count(s.begin(), s.end(), 22),w);


#define SECOND(x, y, z) y


More information about the cfe-commits mailing list