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

Manuel Klimek klimek at google.com
Fri Jul 31 06:19:12 PDT 2015


klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG


================
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()));
+  }
+
----------------
alexfh wrote:
> 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);
> ```
> 
> becomes
> 
> ```
> #define SECOND(x, y, z) y
>   s.count(22);
> ```
You're right. Add a FIXME to figure something out regarding a common function to get this use case covered.


http://reviews.llvm.org/D11677







More information about the cfe-commits mailing list