================
@@ -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() {
+ std::vector<int> ints {};
+})cpp";
+ std::string Expected = R"cpp(// comments
+
+// more comments
+
+module;
+#include <vector>
+export module foo;
+
+int main() {
+ std::vector<int> ints {};
+})cpp";
----------------
ChuanqiXu9 wrote:
Maybe we can do something similar in
https://github.com/llvm/llvm-project/issues/172966
e.g, we should ask the tools to insert `import std;` instead of `#include`.
We can file an issue for it as the first step.
https://github.com/llvm/llvm-project/pull/173724
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits