[clang] Insert headers in global module fragment (PR #151624)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 2 23:17:44 PDT 2025


================
@@ -83,13 +83,13 @@ bool checkAndConsumeModuleDecl(const SourceManager &SM, Lexer &Lex,
   return Matched;
 }
 
-// Returns the offset after header guard directives and any comments
-// before/after header guards (e.g. #ifndef/#define pair, #pragma once). If no
-// header guard is present in the code, this will return the offset after
-// skipping all comments from the start of the code.
-unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName,
-                                               StringRef Code,
-                                               const IncludeStyle &Style) {
+// Determines the minimum offset into the file where we want to insert header
+// includes. This will be put (when available):
+// - after `#pragma once`
+// - after header guards (`#ifdef` and `#define`)
+// - after opening global module (`module;`)
----------------
HighCommander4 wrote:

Can we add "after any comments at the start of the file or immediately following one of the above constructs"?

https://github.com/llvm/llvm-project/pull/151624


More information about the cfe-commits mailing list