[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 17:42:30 PDT 2022


owenpan added inline comments.


================
Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:176-188
 const char IncludeRegexPattern[] =
-    R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+    R"(^[\t\ ]*[@#][\t\ ]*(import|include)([^"]*("[^"]+")|[^<]*(<[^>]+>)|[\t\ ]*([^;]+;)))";
+
+// Returns the last match group in the above regex (IncludeRegexPattern) that
+// is not empty.
+StringRef getIncludeNameFromMatches(const SmallVectorImpl<StringRef> &Matches) {
+  for (int i = Matches.size() - 1; i > 0; i--) {
----------------
owenpan wrote:
> If these are the same as in `Format.cpp` above, we should move the definitions to `HeaderIncludes.h`.
> If these are the same as in `Format.cpp` above, we should move the definitions to `HeaderIncludes.h`.

I meant we should remove the definitions from `Format.cpp` and add the declarations to `HeaderIncludes.h`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121370/new/

https://reviews.llvm.org/D121370



More information about the cfe-commits mailing list