[PATCH] D18313: clang-format: Make include sorting's main include detection configurable.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 21 06:44:19 PDT 2016
djasper 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;
+
----------------
I chose this name for better alphabetical ordering. I don't strongly lean either way, WDYT?
================
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());
----------------
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).
http://reviews.llvm.org/D18313
More information about the cfe-commits
mailing list