[C++20] [Modules] Remove hardcoded path to imported module in BMIs

Close https://github.com/llvm/llvm-project/issues/62707

As we discussed before, we'll forbid the use of implicit generated path
for C++20 modules. And as I mentioned in
https://github.com/llvm/llvm-project/issues/62707, we've emitted a
warning for clang17 and we'll make it a hard error in clang18. And the
patch addresses the decision.
This commit is contained in:
Chuanqi Xu 2024-01-12 13:19:07 +08:00
parent aa2a96a24a
commit dc4e85bd79
20 changed files with 123 additions and 118 deletions

View File

@ -74,6 +74,10 @@ C/C++ Language Potentially Breaking Changes
outlined in "The Equality Operator You Are Looking For" (`P2468 <http://wg21.link/p2468r2>`_).
Fixes (`#68901: <https://github.com/llvm/llvm-project/issues/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: <https://github.com/llvm/llvm-project/issues/62707>`_).
C++ Specific Potentially Breaking Changes
-----------------------------------------
- The name mangling rules for function templates has been changed to take into

View File

@ -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<ModuleConflict>;
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<DiagGroup<"read-modules-implicitly">>;
def err_failed_to_find_module_file : Error<
"failed to find module file for module '%0'">;
} // let CategoryName
let CategoryName = "AST Serialization Issue" in {

View File

@ -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);

View File

@ -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);
}

View File

@ -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.

View File

@ -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"

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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}}

View File

@ -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;

View File

@ -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

View File

@ -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'}}
}

View File

@ -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;

View File

@ -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

View File

@ -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 {

View File

@ -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;