================
@@ -86,19 +125,48 @@ TEST(FeatureModulesTest, SuppressDiags) {
   }
 }
 
+TEST(FeatureModulesTest, BeforePPCallbacks) {
+  struct IncludeRecorder : public PPCallbacks {
+    IncludeRecorder(std::vector<std::string> &Includes) : Includes(Includes) {}
+
+    void InclusionDirective(SourceLocation, const Token &, StringRef FileName,
+                            bool, CharSourceRange, OptionalFileEntryRef,
+                            StringRef, StringRef, const clang::Module *, bool,
+                            SrcMgr::CharacteristicKind) override {
+      Includes.push_back(FileName.str());
+    }
+
+  private:
+    std::vector<std::string> &Includes;
+  };
+  std::vector<std::string> Includes;
+  auto Module = std::make_unique<TestModule>();
+  Module->BeforePPCallbacks = [&Includes](CompilerInstance &CI) {
+    // The preamble build sees this include directly. Register only during the
+    // main-file build to verify the callback sees the replayed event.
----------------
timon-ul wrote:

Again I am lacking some basic knowledge and would appreciate some explanation. 
I know we first build a preamble (so the includes iirc) and then the main file 
itself, this is done because we usually reuse the preamble (the so called 
preamble optimization). But where I get lost here is what does the preamble 
build see, in my naive world it only looks at the includes themselves and not 
the main file at all, but that is seemingly wrong? Also what is meant by 
"replayed events"?

https://github.com/llvm/llvm-project/pull/221054
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to