adamcz added inline comments.

================
Comment at: clang/test/PCH/preamble-modules.cpp:8
+
+#ifndef MAIN_FILE
+#define MAIN_FILE
----------------
sammccall wrote:
> what are these ifdefs about? you never seem to define this symbol
> 
> (Possible you're copying from a test that is doing something tricky like 
> being run in two modes or including itself? Or did you mean to give different 
> flags for the include vs emit pch?)
Oh, I stole this trick from Kadir. You compile this file twice. First one is to 
generate a PCH for preamble. MAIN_FILE is not set, so it only reads the 
preamble section. The second one has -include-pch. That means MAIN_FILE is now 
set (from the preamble PCH file), so we only compile the main section.

It's a creative solution to a problem I wish I didn't have ;-)
Is there a better way to do this, without splitting the file in two? 
preamble_bytes seems fragile.


================
Comment at: clang/test/PCH/preamble-modules.cpp:14
+// Main section.
+MyType foo;
+#endif
----------------
sammccall wrote:
> This seems like currently it's never getting parsed as MAIN_FILE is never 
> defined.
It's parsed. Without this fix, there's a warning generated here. See comment 
above for explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86069

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to