// and to be able to use a name based on the module name.
// At this point, we should know if we are building a non-header C++20 module.
- if (S.getLangOpts().CPlusPlusModules && !S.getLangOpts().IsHeaderFile &&
- S.getLangOpts().isCompilingModuleInterface()) {
+ if (S.getLangOpts().CPlusPlusModules) {
// If we are building the module from source, then the top level module
// will be here.
Module *CodegenModule = S.getCurrentModule();
bool Interface = true;
if (CodegenModule)
- // We only use module initializers for interfaces (including partition
- // implementation units).
+ // We only use module initializers for importable module (including
+ // partition implementation units).
Interface = S.currentModuleIsInterface();
- else
+ else if (S.getLangOpts().isCompilingModuleInterface())
// If we are building the module from a PCM file, then the module can be
// found here.
CodegenModule = S.getPreprocessor().getCurrentModule();
- // If neither. then ....
- assert(CodegenModule && "codegen for a module, but don't know which?");
- if (Interface)
+
+ if (Interface && CodegenModule)
S.getASTContext().setModuleForCodeGen(CodegenModule);
}
Consumer->HandleTranslationUnit(S.getASTContext());
// RUN: -fmodule-file=M.pcm -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
+
+// 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: -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.pcm -fmodule-file=M-part.pcm \
+// RUN: -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-M
+
//--- N-h.h
struct Oink {