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

Samuel Benzaquen sbenza at google.com
Thu Mar 19 10:35:00 PDT 2015

Comment at: clang-tidy/readability/DuplicateIncludeCheck.cpp:28
@@ +27,3 @@
+  while (SM.getFileID(Start) == Id &&
+         SM.getSpellingLineNumber(Start.getLocWithOffset(Offset)) ==
+             LineNumber) {
LegalizeAdulthood wrote:
> 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.
I'm ok with the way it is.
It is only being used when making a warning so it should not cost anything on clean code.
It was just a general comment.
Maybe adding a comment here would be good in case someone comes looking for a speedup opportunity.



More information about the cfe-commits mailing list