[PATCH] Add readability-duplicate-include check to clang-tidy

Richard legalize at xmission.com
Wed Mar 18 15:49:18 PDT 2015


================
Comment at: clang-tidy/readability/DuplicateIncludeCheck.cpp:28
@@ +27,3 @@
+  while (SM.getFileID(Start) == Id &&
+         SM.getSpellingLineNumber(Start.getLocWithOffset(Offset)) ==
+             LineNumber) {
----------------
sbenza wrote:
> This seems very wasteful, given that the SourceManager could tell you (if there was an API) the location for the next line in O(1) time.
> Don't know if it is worth enough to add this API to SourceManager.
I thought it should have been easy to say "get me the source range that spans the line containing this #include directive", but I didn't find anything easier that worked properly for my test cases.  I'm in the process of refactoring this check to share some common code with llvm-include-order and that might eliminate the need for this, but I haven't gotten that far yet.

http://reviews.llvm.org/D7982

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list