diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 59732962caac65..4aba054e252af2 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -74,6 +74,10 @@ C/C++ Language Potentially Breaking Changes outlined in "The Equality Operator You Are Looking For" (`P2468 `_). Fixes (`#68901: `_). +- Remove the hardcoded path to the imported modules for C++20 named modules. Now we + require all the dependent modules to specified from the command line. + See (`#62707: `_). + C++ Specific Potentially Breaking Changes ----------------------------------------- - The name mangling rules for function templates has been changed to take into diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index 3cb2cd32cf6d09..11c706ebf84b54 100644 --- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td @@ -129,10 +129,8 @@ def warn_module_system_bit_conflict : Warning< "as a non-system module; any difference in diagnostic options will be ignored">, InGroup; -def warn_reading_std_cxx_module_by_implicit_paths : Warning< - "it is deprecated to read module '%0' implicitly; it is going to be removed in clang 18; " - "consider to specify the dependencies explicitly">, - InGroup>; +def err_failed_to_find_module_file : Error< + "failed to find module file for module '%0'">; } // let CategoryName let CategoryName = "AST Serialization Issue" in { diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 9effd333daccdb..287f9a0300be5c 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -3037,12 +3037,17 @@ ASTReader::ReadControlBlock(ModuleFile &F, // location info are setup, in ReadAST. SourceLocation ImportLoc = ReadUntranslatedSourceLocation(Record[Idx++]); - off_t StoredSize = (off_t)Record[Idx++]; - time_t StoredModTime = (time_t)Record[Idx++]; - auto FirstSignatureByte = Record.begin() + Idx; - ASTFileSignature StoredSignature = ASTFileSignature::create( - FirstSignatureByte, FirstSignatureByte + ASTFileSignature::size); - Idx += ASTFileSignature::size; + off_t StoredSize = !IsImportingStdCXXModule ? (off_t)Record[Idx++] : 0; + time_t StoredModTime = + !IsImportingStdCXXModule ? (time_t)Record[Idx++] : 0; + + ASTFileSignature StoredSignature; + if (!IsImportingStdCXXModule) { + auto FirstSignatureByte = Record.begin() + Idx; + StoredSignature = ASTFileSignature::create( + FirstSignatureByte, FirstSignatureByte + ASTFileSignature::size); + Idx += ASTFileSignature::size; + } std::string ImportedName = ReadString(Record, Idx); std::string ImportedFile; @@ -3057,18 +3062,19 @@ ASTReader::ReadControlBlock(ModuleFile &F, ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName( ImportedName, /*FileMapOnly*/ !IsImportingStdCXXModule); - if (ImportedFile.empty()) { - // It is deprecated for C++20 Named modules to use the implicitly - // paths. - if (IsImportingStdCXXModule) - Diag(clang::diag::warn_reading_std_cxx_module_by_implicit_paths) - << ImportedName; - - // Use BaseDirectoryAsWritten to ensure we use the same path in the - // ModuleCache as when writing. - ImportedFile = ReadPath(BaseDirectoryAsWritten, Record, Idx); - } else - SkipPath(Record, Idx); + // For C++20 Modules, we won't record the path to the imported modules + // in the BMI + if (!IsImportingStdCXXModule) { + if (ImportedFile.empty()) { + // Use BaseDirectoryAsWritten to ensure we use the same path in the + // ModuleCache as when writing. + ImportedFile = ReadPath(BaseDirectoryAsWritten, Record, Idx); + } else + SkipPath(Record, Idx); + } else if (ImportedFile.empty()) { + Diag(clang::diag::err_failed_to_find_module_file) << ImportedName; + return Missing; + } // If our client can't cope with us being out of date, we can't cope with // our dependency being missing. @@ -5584,8 +5590,23 @@ bool ASTReader::readASTFileControlBlock( while (Idx < N) { // Read information about the AST file. - // Kind, StandardCXXModule, ImportLoc, Size, ModTime, Signature - Idx += 1 + 1 + 1 + 1 + 1 + ASTFileSignature::size; + // Skip Kind + Idx++; + bool IsStandardCXXModule = Record[Idx++]; + + // Skip ImportLoc + Idx++; + + // In C++20 Modules, we don't record the path to imported + // modules in the BMI files. + if (IsStandardCXXModule) { + std::string ModuleName = ReadString(Record, Idx); + Listener.visitImport(ModuleName, /*Filename=*/""); + continue; + } + + // Skip Size, ModTime and Signature + Idx += 1 + 1 + ASTFileSignature::size; std::string ModuleName = ReadString(Record, Idx); std::string Filename = ReadString(Record, Idx); ResolveImportedPath(Filename, ModuleDir); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 78939bfd533ffa..9950fa9c08faaa 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1411,15 +1411,20 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, Record.push_back(M.StandardCXXModule); AddSourceLocation(M.ImportLoc, Record); - // If we have calculated signature, there is no need to store - // the size or timestamp. - Record.push_back(M.Signature ? 0 : M.File.getSize()); - Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File)); - - llvm::append_range(Record, M.Signature); + // We don't want to hard code the information about imported modules + // in the C++20 named modules. + if (!M.StandardCXXModule) { + // If we have calculated signature, there is no need to store + // the size or timestamp. + Record.push_back(M.Signature ? 0 : M.File.getSize()); + Record.push_back(M.Signature ? 0 : getTimestampForOutput(M.File)); + llvm::append_range(Record, M.Signature); + } AddString(M.ModuleName, Record); - AddPath(M.FileName, Record); + + if (!M.StandardCXXModule) + AddPath(M.FileName, Record); } Stream.EmitRecord(IMPORTS, Record); } diff --git a/clang/test/CodeGenCXX/module-initializer-guard-elision.cpp b/clang/test/CodeGenCXX/module-initializer-guard-elision.cpp index bae7c930b51029..53e4b909ee2a17 100644 --- a/clang/test/CodeGenCXX/module-initializer-guard-elision.cpp +++ b/clang/test/CodeGenCXX/module-initializer-guard-elision.cpp @@ -8,9 +8,9 @@ // RUN: -o - | FileCheck %s --check-prefix=CHECK-O // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 P.cpp \ -// RUN: -emit-module-interface -fmodule-file=O=O.pcm -o P.pcm +// RUN: -emit-module-interface -fprebuilt-module-path=%t -o P.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 P.pcm -S -emit-llvm \ -// RUN: -o - | FileCheck %s --check-prefix=CHECK-P +// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-P // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 Q.cpp \ // RUN: -emit-module-interface -o Q.pcm @@ -18,24 +18,24 @@ // RUN: -o - | FileCheck %s --check-prefix=CHECK-Q // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 R.cpp \ -// RUN: -emit-module-interface -fmodule-file=Q=Q.pcm -o R.pcm +// RUN: -emit-module-interface -fprebuilt-module-path=%t -o R.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 R.pcm -S -emit-llvm \ -// RUN: -o - | FileCheck %s --check-prefix=CHECK-R +// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-R // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 S.cpp \ -// RUN: -emit-module-interface -fmodule-file=Q=Q.pcm -fmodule-file=R=R.pcm -o S.pcm +// RUN: -emit-module-interface -fprebuilt-module-path=%t -o S.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 S.pcm -S -emit-llvm \ -// RUN: -o - | FileCheck %s --check-prefix=CHECK-S +// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-S // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 T.cpp \ -// RUN: -emit-module-interface -fmodule-file=S=S.pcm -fmodule-file=R=R.pcm -o T.pcm +// RUN: -emit-module-interface -fprebuilt-module-path=%t -o T.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 T.pcm -S -emit-llvm \ -// RUN: -o - | FileCheck %s --check-prefix=CHECK-T +// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-T // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 U.cpp \ -// RUN: -emit-module-interface -fmodule-file=T=T.pcm -fmodule-file=R=R.pcm -o U.pcm +// RUN: -emit-module-interface -fprebuilt-module-path=%t -o U.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 U.pcm -S -emit-llvm \ -// RUN: -o - | FileCheck %s --check-prefix=CHECK-U +// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-U // Testing cases where we can elide the module initializer guard variable. diff --git a/clang/test/CodeGenCXX/module-intializer.cpp b/clang/test/CodeGenCXX/module-intializer.cpp index d365d180ac59d1..8a464ae7403d66 100644 --- a/clang/test/CodeGenCXX/module-intializer.cpp +++ b/clang/test/CodeGenCXX/module-intializer.cpp @@ -12,24 +12,23 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.pcm -S -emit-llvm \ // RUN: -o - | FileCheck %s --check-prefix=CHECK-O -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-part.cpp \ -// RUN: -emit-module-interface -o M-part.pcm -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-part.pcm -S \ -// RUN: -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-P +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-Part.cpp \ +// RUN: -emit-module-interface -o M-Part.pcm +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-Part.pcm -S \ +// RUN: -emit-module-interface -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-P // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.cpp \ -// RUN: -fmodule-file=N=N.pcm -fmodule-file=O=O.pcm -fmodule-file=M:Part=M-part.pcm \ -// RUN: -emit-module-interface -o M.pcm +// RUN: -fprebuilt-module-path=%t -emit-module-interface -o M.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.pcm -S -emit-llvm \ -// RUN: -o - | FileCheck %s --check-prefix=CHECK-M +// RUN: -fprebuilt-module-path=%t -o - | FileCheck %s --check-prefix=CHECK-M // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 useM.cpp \ -// RUN: -fmodule-file=M=M.pcm -S -emit-llvm -o - \ -// RUN: | FileCheck %s --check-prefix=CHECK-USE +// RUN: -fprebuilt-module-path=%t -S -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefix=CHECK-USE // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-impl.cpp \ -// RUN: -fmodule-file=M=M.pcm -S -emit-llvm -o - \ -// RUN: | FileCheck %s --check-prefix=CHECK-IMPL +// RUN: -fprebuilt-module-path=%t -S -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefix=CHECK-IMPL // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 N.cpp -S -emit-llvm \ // RUN: -o - | FileCheck %s --check-prefix=CHECK-N @@ -37,12 +36,11 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.cpp -S -emit-llvm \ // RUN: -o - | FileCheck %s --check-prefix=CHECK-O -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-part.cpp -S -emit-llvm \ +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-Part.cpp -S -emit-llvm \ // RUN: -o - | FileCheck %s --check-prefix=CHECK-P // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.cpp \ -// RUN: -fmodule-file=N.pcm -fmodule-file=O=O.pcm -fmodule-file=M:Part=M-part.pcm \ -// RUN: -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-M +// RUN: -fprebuilt-module-path=%t -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-M //--- N-h.h @@ -112,7 +110,7 @@ struct Croak { Croak Frog; -//--- M-part.cpp +//--- M-Part.cpp module; #include "P-h.h" diff --git a/clang/test/CodeGenCXX/partitions.cpp b/clang/test/CodeGenCXX/partitions.cpp index b58e88fafdc6b1..3b3e69271e7c7b 100644 --- a/clang/test/CodeGenCXX/partitions.cpp +++ b/clang/test/CodeGenCXX/partitions.cpp @@ -4,14 +4,14 @@ // RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/parta.cppm -o %t/mod-parta.pcm // RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/partb.cppm -o %t/mod-partb.pcm -// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple -fmodule-file=%t/mod-parta.pcm \ -// RUN: -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -triple %itanium_abi_triple %t/mod.cppm \ +// RUN: -fprebuilt-module-path=%t -o %t/mod.pcm // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \ -// RUN: | FileCheck %t/mod.cppm -// RUN: %clang_cc1 -std=c++20 -O2 -emit-module-interface -triple %itanium_abi_triple -fmodule-file=%t/mod-parta.pcm \ -// RUN: -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm -// RUN: %clang_cc1 -std=c++20 -O2 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \ -// RUN: | FileCheck %t/mod.cppm -check-prefix=CHECK-OPT +// RUN: -fprebuilt-module-path=%t | FileCheck %t/mod.cppm +// RUN: %clang_cc1 -std=c++20 -O2 -emit-module-interface -triple %itanium_abi_triple \ +// RUN: -fprebuilt-module-path=%t %t/mod.cppm -o %t/mod.pcm +// RUN: %clang_cc1 -std=c++20 -O2 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm \ +// RUN: -fprebuilt-module-path=%t -disable-llvm-passes -o - | FileCheck %t/mod.cppm -check-prefix=CHECK-OPT //--- parta.cppm export module mod:parta; diff --git a/clang/test/Modules/cxx20-10-1-ex1.cpp b/clang/test/Modules/cxx20-10-1-ex1.cpp index b9a5e8023d035f..b330e0a6c9a9d8 100644 --- a/clang/test/Modules/cxx20-10-1-ex1.cpp +++ b/clang/test/Modules/cxx20-10-1-ex1.cpp @@ -9,13 +9,15 @@ // RUN: -o %t/A_Internals.pcm // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu2.cpp \ -// RUN: -fmodule-file=%t/A_Internals.pcm -o %t/A_Foo.pcm +// RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm -o %t/A_Foo.pcm // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu3.cpp \ -// RUN: -fmodule-file=%t/A_Foo.pcm -o %t/A.pcm +// RUN: -fmodule-file=A:Foo=%t/A_Foo.pcm -fmodule-file=A:Internals=%t/A_Internals.pcm \ +// RUN: -o %t/A.pcm // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex1-tu4.cpp \ -// RUN: -fmodule-file=%t/A.pcm -o %t/ex1.o +// RUN: -fmodule-file=A=%t/A.pcm -fmodule-file=A:Foo=%t/A_Foo.pcm \ +// RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm -o %t/ex1.o // expected-no-diagnostics diff --git a/clang/test/Modules/cxx20-importing-function-bodies.cppm b/clang/test/Modules/cxx20-importing-function-bodies.cppm index f1b8f9a8f0c911..c34e48aaa3f671 100644 --- a/clang/test/Modules/cxx20-importing-function-bodies.cppm +++ b/clang/test/Modules/cxx20-importing-function-bodies.cppm @@ -9,7 +9,8 @@ // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.cppm \ // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.pcm -S \ -// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cppm +// RUN: -fprebuilt-module-path=%t -emit-llvm -disable-llvm-passes -o - \ +// RUN: | FileCheck %t/c.cppm // // Be sure that we keep the same behavior as if optization not enabled. // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/a.cppm \ @@ -19,7 +20,8 @@ // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/c.cppm \ // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/c.pcm \ -// RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cppm +// RUN: -fprebuilt-module-path=%t -S -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %t/c.cppm //--- a.cppm export module a; diff --git a/clang/test/Modules/cxx20-module-file-info.cpp b/clang/test/Modules/cxx20-module-file-info.cpp index 99a215645e8fe7..9ef061f076330c 100644 --- a/clang/test/Modules/cxx20-module-file-info.cpp +++ b/clang/test/Modules/cxx20-module-file-info.cpp @@ -14,13 +14,14 @@ // RUN: -o %t/B.pcm // RUN: %clang_cc1 -std=c++20 -module-file-info %t/B.pcm | FileCheck \ -// RUN: --check-prefix=CHECK-B %s +// RUN: --check-prefix=CHECK-B %s // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu3.cpp \ -// RUN: -fmodule-file=%t/A.pcm -fmodule-file=%t/B.pcm -o %t/Foo.pcm +// RUN: -fmodule-file=A=%t/A.pcm -fmodule-file=B=%t/B.pcm -o %t/Foo.pcm -// RUN: %clang_cc1 -std=c++20 -module-file-info %t/Foo.pcm | FileCheck \ -// RUN: --check-prefix=CHECK-FOO %s +// RUN: %clang_cc1 -std=c++20 -module-file-info %t/Foo.pcm -fmodule-file=A=%t/A.pcm \ +// RUN: -fmodule-file=B=%t/B.pcm | FileCheck \ +// RUN: --check-prefix=CHECK-FOO %s // expected-no-diagnostics diff --git a/clang/test/Modules/cxx20-partition-redeclarations.cpp b/clang/test/Modules/cxx20-partition-redeclarations.cpp index f99ef009a79af8..03658ba92534d3 100644 --- a/clang/test/Modules/cxx20-partition-redeclarations.cpp +++ b/clang/test/Modules/cxx20-partition-redeclarations.cpp @@ -7,10 +7,10 @@ // RUN: %clang_cc1 -std=c++20 A-interface.cpp -emit-module-interface \ // RUN: -fmodule-file=A-PubPart.pcm -o A.pcm -// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fmodule-file=A.pcm -// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fmodule-file=A.pcm -// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fmodule-file=A.pcm -// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fmodule-file=A.pcm +// RUN: %clang_cc1 -std=c++20 A-impl-top.cpp -fsyntax-only -fprebuilt-module-path=%t +// RUN: %clang_cc1 -std=c++20 A-impl-part.cpp -fsyntax-only -fprebuilt-module-path=%t +// RUN: %clang_cc1 -std=c++20 A-impl-1.cpp -fsyntax-only -fprebuilt-module-path=%t +// RUN: %clang_cc1 -std=c++20 A-impl-2.cpp -fsyntax-only -fprebuilt-module-path=%t //--- A-interface.cpp export module A; diff --git a/clang/test/Modules/eagerly-load-cxx-named-modules.cppm b/clang/test/Modules/eagerly-load-cxx-named-modules.cppm index febda6ef0f5730..ab2ac891fb400c 100644 --- a/clang/test/Modules/eagerly-load-cxx-named-modules.cppm +++ b/clang/test/Modules/eagerly-load-cxx-named-modules.cppm @@ -7,8 +7,8 @@ // RUN: 2>&1 | FileCheck %t/user.cpp // RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \ // RUN: -fprebuilt-module-path=%t -// RUN: %clang_cc1 -std=c++20 %t/b.pcm -Wno-read-modules-implicitly -S \ -// RUN: -emit-llvm 2>&1 -o - | FileCheck %t/b.cppm +// RUN: %clang_cc1 -std=c++20 %t/b.pcm -S \ +// RUN: -fprebuilt-module-path=%t -emit-llvm 2>&1 -o - | FileCheck %t/b.cppm //--- a.cppm export module a; diff --git a/clang/test/Modules/implicit-module-with-missing-path.cpp b/clang/test/Modules/implicit-module-with-missing-path.cpp index 851a4401df0b6c..d167f742e7b21e 100644 --- a/clang/test/Modules/implicit-module-with-missing-path.cpp +++ b/clang/test/Modules/implicit-module-with-missing-path.cpp @@ -6,7 +6,7 @@ // RUN: echo -e "export module B;\nimport C;" >> %t/B.cppm // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/subdir/C.cppm -o %t/subdir/C.pcm // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t/subdir %t/B.cppm -o %t/B.pcm -// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify -Wno-read-modules-implicitly +// RUN: %clang_cc1 -std=c++20 -fmodule-file=B=%t/B.pcm %s -fsyntax-only -verify -import B; -import C; // expected-error {{module 'C' is needed but has not been provided, and implicit use of module files is disabled}} +import B; // expected-error {{failed to find module file for module 'C'}} +import C; // expected-error {{module 'C' not found}} diff --git a/clang/test/Modules/module-init-duplicated-import.cppm b/clang/test/Modules/module-init-duplicated-import.cppm index de0ce1962f1008..7adce11779566e 100644 --- a/clang/test/Modules/module-init-duplicated-import.cppm +++ b/clang/test/Modules/module-init-duplicated-import.cppm @@ -7,7 +7,7 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.cppm \ // RUN: -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/m.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.pcm \ -// RUN: -S -emit-llvm -o - | FileCheck %t/m.cppm +// RUN: -fmodule-file=a=%t/a.pcm -S -emit-llvm -o - | FileCheck %t/m.cppm //--- a.cppm export module a; diff --git a/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm b/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm index e4d06415fabd45..a743b64cb18d6e 100644 --- a/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm +++ b/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm @@ -7,7 +7,8 @@ // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/A.cppm -emit-module-interface -o %t/A.pcm // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.cppm -emit-module-interface -o %t/B.pcm \ // RUN: -fprebuilt-module-path=%t -// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.pcm -S -emit-llvm -o - | FileCheck %t/B.cppm +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.pcm -S -emit-llvm -o - \ +// RUN: -fprebuilt-module-path=%t | FileCheck %t/B.cppm //--- foo.h diff --git a/clang/test/Modules/no-implicit-std-cxx-module.cppm b/clang/test/Modules/no-implicit-std-cxx-module.cppm index 0432159fed1801..2df8b5cf5d8484 100644 --- a/clang/test/Modules/no-implicit-std-cxx-module.cppm +++ b/clang/test/Modules/no-implicit-std-cxx-module.cppm @@ -6,21 +6,6 @@ // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -fmodule-file=b=%t/b.pcm \ // RUN: -o %t/a.pcm // RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only -// RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only \ -// RUN: -Wno-read-modules-implicitly -DNO_DIAG -// RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ -// RUN: -DNO_DIAG -verify -fsyntax-only -// -// RUN: %clang_cc1 -std=c++20 %t/a.pcm -S -emit-llvm -o - 2>&1 | FileCheck %t/a.cppm -// RUN: %clang_cc1 -std=c++20 %t/a.pcm -fmodule-file=b=%t/b.pcm -S -emit-llvm -o - 2>&1 \ -// RUN: | FileCheck %t/a.cppm -check-prefix=CHECK-CORRECT -// -// RUN: mkdir -p %t/tmp -// RUN: mv %t/b.pcm %t/tmp/b.pcm -// RUN: not %clang_cc1 -std=c++20 %t/a.pcm -S -emit-llvm -o - 2>&1 \ -// RUN: | FileCheck %t/a.cppm -check-prefix=CHECK-ERROR -// RUN: %clang_cc1 -std=c++20 %t/a.pcm -S -emit-llvm -o - 2>&1 -fmodule-file=b=%t/tmp/b.pcm \ -// RUN: | FileCheck %t/a.cppm -check-prefix=CHECK-CORRECT //--- b.cppm export module b; @@ -35,21 +20,8 @@ export int a() { return b() + 43; } -// CHECK: it is deprecated to read module 'b' implicitly; - -// CHECK-CORRECT-NOT: warning -// CHECK-CORRECT-NOT: error - -// CHECK-ERROR: error: module file{{.*}}not found: module file not found - - //--- user.cpp -#ifdef NO_DIAG -// expected-no-diagnostics -#else - // expected-warning@+2 {{it is deprecated to read module 'b' implicitly;}} -#endif -import a; +import a; // expected-error {{failed to find module file for module 'b'}} int use() { - return a(); + return a(); // expected-error {{use of undeclared identifier 'a'}} } diff --git a/clang/test/Modules/no-import-func-body.cppm b/clang/test/Modules/no-import-func-body.cppm index 6c7292b1e469bd..af7c3a3ad84b36 100644 --- a/clang/test/Modules/no-import-func-body.cppm +++ b/clang/test/Modules/no-import-func-body.cppm @@ -9,7 +9,8 @@ // RUN: %clang_cc1 -std=c++20 -O1 -triple %itanium_abi_triple %t/c.cppm \ // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm // RUN: %clang_cc1 -std=c++20 -O1 -triple %itanium_abi_triple %t/c.pcm -S \ -// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cppm +// RUN: -fprebuilt-module-path=%t -emit-llvm -disable-llvm-passes -o - \ +// RUN: | FileCheck %t/c.cppm //--- a.cppm export module a; diff --git a/clang/test/Modules/pr61067.cppm b/clang/test/Modules/pr61067.cppm index 8469a1db1f1c8d..baee4b83de5660 100644 --- a/clang/test/Modules/pr61067.cppm +++ b/clang/test/Modules/pr61067.cppm @@ -8,7 +8,7 @@ // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \ // RUN: -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/b.pcm // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.pcm -S \ -// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %t/b.cppm +// RUN: -emit-llvm -fmodule-file=a=%t/a.pcm -disable-llvm-passes -o - | FileCheck %t/b.cppm // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.cpp -fmodule-file=a=%t/a.pcm \ // RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cpp diff --git a/clang/test/Modules/pr62705.cppm b/clang/test/Modules/pr62705.cppm index a09bdf2563e84b..00769d2277f4f1 100644 --- a/clang/test/Modules/pr62705.cppm +++ b/clang/test/Modules/pr62705.cppm @@ -8,7 +8,7 @@ // RUN: -emit-module-interface -o %t/b.pcm \ // RUN: -fmodule-file=a=%t/a.pcm // RUN: %clang_cc1 %t/b.pcm -std=c++20 -triple %itanium_abi_triple \ -// RUN: -emit-llvm -o - | FileCheck %t/b.cppm +// RUN: -fmodule-file=a=%t/a.pcm -emit-llvm -o - | FileCheck %t/b.cppm //--- foo.h namespace n { diff --git a/clang/test/Modules/pr67893.cppm b/clang/test/Modules/pr67893.cppm index 7d4e4c1dc5d843..00b024ecc2eb11 100644 --- a/clang/test/Modules/pr67893.cppm +++ b/clang/test/Modules/pr67893.cppm @@ -5,9 +5,9 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/a.cppm \ // RUN: -emit-module-interface -o %t/a.pcm // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.cppm \ -// RUN: -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/m.pcm +// RUN: -emit-module-interface -fprebuilt-module-path=%t // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/m.pcm \ -// RUN: -S -emit-llvm -o - | FileCheck %t/m.cppm +// RUN: -fprebuilt-module-path=%t -S -emit-llvm -o - | FileCheck %t/m.cppm //--- a.cppm export module a;