curdeius added inline comments.
================
Comment at: clang/lib/Format/Format.cpp:2685
const char CppIncludeRegexPattern[] =
- R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+ R"(^[\t\ ]*[@#]?[\t\ ]*(import|include)[^"<]*[\t\n\
\\]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
----------------
I'd rather see handling separately the `#import`/`#include` case on one hand
and `@import` on the other.
IIUC, `@import` is followed by `ns1.ns2.something` without quotes nor `<>`. And
it ends with a `;`.
Trying to put everything together is IMO error-prone and not very readable.
You could just do (pseudo-code):
```
CppIncludeRegexPattern = (current_regex) | "@\s*import\s+[^;]+;"
```
(`\s` is probably not supported, but we could use character class `[:space:]`
for clarity, cf. llvm\lib\Support\regcomp.c)
Not sure whether whitespace is allowed after `@`.
Could you please post a link to the specification of `@import` syntax?
Not sure fixing `<"` / `">` issue is worth it, but in all cases I'd prefer
seeing it in a different patch.
================
Comment at: clang/lib/Format/Format.cpp:2759
+ IncludeName =
+ StringRef(Twine("<", IncludeName).concat(Twine(">")).str());
+ }
----------------
HazardyKnusperkeks wrote:
> How does that not go out of scope and I have a dangling reference?
Why not doing it the other way round, i.e. trimming `<>"` from include name?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121370/new/
https://reviews.llvm.org/D121370
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits