[PATCH] D18313: clang-format: Make include sorting's main include detection configurable.

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 06:49:40 PDT 2016

klimek added inline comments.

Comment at: include/clang/Format/Format.h:415
@@ +414,3 @@
+  /// as the "main" include in both a.cc and a_test.cc.
+  std::string IncludeMainRegex;
djasper wrote:
> I chose this name for better alphabetical ordering. I don't strongly lean either way, WDYT?
I'd still lean slightly towards MainIncludeRegex... but feel free to keep.

Comment at: lib/Format/Format.cpp:1967
@@ -1963,3 +1966,3 @@
           if (FileStem.startswith(HeaderStem)) {
-            Category = 0;
-            MainIncludeFound = true;
+            llvm::Regex MainFileRegex(
+                (Twine(HeaderStem) + Style.IncludeMainRegex).str());
djasper wrote:
> I believe this is more efficient. In many cases, no Regex will need to be formed at all and the cases where it is formed more than once are rare (many includes starting with HeaderStem, but not matching the regex).
Ok, makes sense.


More information about the cfe-commits mailing list