This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Support replacements in macro arguments in misc-inefficient-algorithm
ClosedPublic

Authored by alexfh on Jul 31 2015, 4:32 AM.

Diff Detail

Event Timeline

alexfh updated this revision to Diff 31117.Jul 31 2015, 4:32 AM
alexfh retitled this revision from to [clang-tidy] Support replacements in macro arguments in misc-inefficient-algorithm.
alexfh updated this object.
alexfh added a reviewer: klimek.
alexfh added a subscriber: cfe-commits.
klimek added inline comments.Jul 31 2015, 5:36 AM
clang-tidy/misc/InefficientAlgorithmCheck.cpp
114–118

Any reason we don't want to use Lexer::makeFileCharRange here (which should handle all the cases correctly).

alexfh added inline comments.Jul 31 2015, 6:00 AM
clang-tidy/misc/InefficientAlgorithmCheck.cpp
114–118

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);
klimek accepted this revision.Jul 31 2015, 6:19 AM
klimek edited edge metadata.

LG

clang-tidy/misc/InefficientAlgorithmCheck.cpp
114–118

You're right. Add a FIXME to figure something out regarding a common function to get this use case covered.

This revision is now accepted and ready to land.Jul 31 2015, 6:19 AM
alexfh closed this revision.Jul 31 2015, 6:35 AM
alexfh marked an inline comment as done.Jul 31 2015, 6:36 AM