[clang] Make -frewrite-includes put an endif at the end of the included text (PR #67613)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 28 07:36:33 PDT 2023
================
@@ -332,12 +346,14 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex,
// OutputContentUpTo() would not output anything anyway.
return;
}
- OS << "#if 0 /* expanded by -frewrite-includes */" << MainEOL;
+ OS << "#if 0 /* " << getIncludedFileName(Inc)
----------------
erichkeane wrote:
I DO think there is at least a good attempt that could be made to get a unique set of names for each (perhaps a stringify of the path, ala how `#line` does it?), but I think this is a good stand-alone feature here.
One thing I MIGHT suggest anyway though is replacing the '0' with `defined(__CLANG_REWRITTEN_INCLUDES)`, so that turning on the `#include` version would be trivial.
I might also suggest for certain lines, `defined(__CLANG_REWRITTEN_SYSTEM_INCLUDES)` such that only the system headers are used from the test machine.
So that is, a system header would be:
```#if defined(__CLANG_REWRITTEN_INCLUDES) || defined(__CLANG_REWRITTEN_SYSTEM_INCLUDES) /* vector expanded by -frewrite-includes */```
https://github.com/llvm/llvm-project/pull/67613
More information about the cfe-commits
mailing list