[clang] [clang][Tooling] Insert global module fragment during header insertion (PR #173724)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 29 07:14:35 PST 2025
================
@@ -594,6 +594,66 @@ TEST_F(HeaderIncludesTest, CanDeleteAfterCode) {
EXPECT_EQ(Expected, remove(Code, "\"b.h\""));
}
+TEST_F(HeaderIncludesTest, InsertGlobalModuleFragmentDeclInterfaceUnit) {
+ // Ensure the header insertion comes with a global module fragment decl (i.e.
+ // a 'module;' line) when:
+ // - the input file is an module interface unit, and
+ // - no tokens excluding comments and whitespaces exist before the module
+ // declaration.
+ std::string Code = R"cpp(// comments
+
+// more comments
+
+export module foo;
+
+int main() {
----------------
Lancern wrote:
Oops... didn't really notice this. Changed.
https://github.com/llvm/llvm-project/pull/173724
More information about the cfe-commits
mailing list