[PATCH] D20814: [include-fixer] Rank symbols based on the number of occurrences we found while merging.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Tue May 31 07:35:52 PDT 2016


djasper accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: include-fixer/SymbolIndexManager.cpp:25
@@ +24,3 @@
+  // First collect occurrences per header file.
+  std::map<llvm::StringRef, unsigned> HeaderPopularity;
+  for (const SymbolInfo &Symbol : Symbols) {
----------------
Maybe use a DenseHashMap?

================
Comment at: include-fixer/tool/ClangIncludeFixer.cpp:101
@@ -100,3 +100,3 @@
       Split.second.split(CommaSplits, ",");
-      for (StringRef Header : CommaSplits)
+      for (const StringRef &Header : CommaSplits)
         Symbols.push_back(find_all_symbols::SymbolInfo(
----------------
Can you please write a regular for loop with index instead?

================
Comment at: include-fixer/tool/ClangIncludeFixer.cpp:105
@@ -104,3 +104,3 @@
             find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1,
-            {}));
+            {}, /*NumOccurrences=*/CommaSplits.end() - &Header));
     }
----------------
Add a comment that you are assigning fake occurrences to keep the existing test logic (with the first include being the most preferable).


http://reviews.llvm.org/D20814





More information about the cfe-commits mailing list