diff --git a/clang/include/clang/Driver/Action.h b/clang/include/clang/Driver/Action.h --- a/clang/include/clang/Driver/Action.h +++ b/clang/include/clang/Driver/Action.h @@ -436,26 +436,6 @@ } }; -class HeaderModulePrecompileJobAction : public PrecompileJobAction { - void anchor() override; - - const char *ModuleName; - -public: - HeaderModulePrecompileJobAction(Action *Input, types::ID OutputType, - const char *ModuleName); - - static bool classof(const Action *A) { - return A->getKind() == HeaderModulePrecompileJobClass; - } - - void addModuleHeaderInput(Action *Input) { - getInputs().push_back(Input); - } - - const char *getModuleName() const { return ModuleName; } -}; - class ExtractAPIJobAction : public JobAction { void anchor() override; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5934,8 +5934,6 @@ HelpText<"Generate pre-compiled module file from a module map">; def emit_module_interface : Flag<["-"], "emit-module-interface">, HelpText<"Generate pre-compiled module file from a C++ module interface">; -def emit_header_module : Flag<["-"], "emit-header-module">, - HelpText<"Generate pre-compiled module file from a set of header files">; def emit_header_unit : Flag<["-"], "emit-header-unit">, HelpText<"Generate C++20 header units from header files">; def emit_pch : Flag<["-"], "emit-pch">, diff --git a/clang/include/clang/Frontend/FrontendActions.h b/clang/include/clang/Frontend/FrontendActions.h --- a/clang/include/clang/Frontend/FrontendActions.h +++ b/clang/include/clang/Frontend/FrontendActions.h @@ -155,19 +155,6 @@ CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; }; -class GenerateHeaderModuleAction : public GenerateModuleAction { - /// The synthesized module input buffer for the current compilation. - std::unique_ptr Buffer; - std::vector ModuleHeaders; - -private: - bool PrepareToExecuteAction(CompilerInstance &CI) override; - bool BeginSourceFileAction(CompilerInstance &CI) override; - - std::unique_ptr - CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; -}; - class GenerateHeaderUnitAction : public GenerateModuleAction { private: diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -87,9 +87,6 @@ /// Generate pre-compiled module from a C++ module interface file. GenerateModuleInterface, - /// Generate pre-compiled module from a set of header files. - GenerateHeaderModule, - /// Generate a C++20 header unit module from a header file. GenerateHeaderUnit, diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h --- a/clang/include/clang/Lex/ModuleMap.h +++ b/clang/include/clang/Lex/ModuleMap.h @@ -566,9 +566,6 @@ /// \returns The newly-created module. Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name); - /// Create a header module from the specified list of headers. - Module *createHeaderModule(StringRef Name, ArrayRef Headers); - /// Create a C++20 header unit. Module *createHeaderUnit(SourceLocation Loc, StringRef Name, Module::Header H); diff --git a/clang/lib/Driver/Action.cpp b/clang/lib/Driver/Action.cpp --- a/clang/lib/Driver/Action.cpp +++ b/clang/lib/Driver/Action.cpp @@ -25,7 +25,6 @@ return "offload"; case PreprocessJobClass: return "preprocessor"; case PrecompileJobClass: return "precompiler"; - case HeaderModulePrecompileJobClass: return "header-module-precompiler"; case ExtractAPIJobClass: return "api-extractor"; case AnalyzeJobClass: return "analyzer"; @@ -352,13 +351,6 @@ assert(isa((Action*)this) && "invalid action kind"); } -void HeaderModulePrecompileJobAction::anchor() {} - -HeaderModulePrecompileJobAction::HeaderModulePrecompileJobAction( - Action *Input, types::ID OutputType, const char *ModuleName) - : PrecompileJobAction(HeaderModulePrecompileJobClass, Input, OutputType), - ModuleName(ModuleName) {} - void ExtractAPIJobAction::anchor() {} ExtractAPIJobAction::ExtractAPIJobAction(Action *Inputs, types::ID OutputType) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3957,7 +3957,6 @@ : nullptr; // Construct the actions to perform. - HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr; ExtractAPIJobAction *ExtractAPIAction = nullptr; ActionList LinkerInputs; ActionList MergerInputs; @@ -4012,16 +4011,6 @@ break; } - // Each precompiled header file after a module file action is a module - // header of that same module file, rather than being compiled to a - // separate PCH. - if (Phase == phases::Precompile && HeaderModuleAction && - getPrecompiledType(InputType) == types::TY_PCH) { - HeaderModuleAction->addModuleHeaderInput(Current); - Current = nullptr; - break; - } - if (Phase == phases::Precompile && ExtractAPIAction) { ExtractAPIAction->addHeaderInput(Current); Current = nullptr; @@ -4038,9 +4027,7 @@ if (NewCurrent == Current) continue; - if (auto *HMA = dyn_cast(NewCurrent)) - HeaderModuleAction = HMA; - else if (auto *EAA = dyn_cast(NewCurrent)) + if (auto *EAA = dyn_cast(NewCurrent)) ExtractAPIAction = EAA; Current = NewCurrent; @@ -4524,9 +4511,6 @@ OutputTy = types::TY_Nothing; } - if (ModName) - return C.MakeAction(Input, OutputTy, - ModName); return C.MakeAction(Input, OutputTy); } case phases::Compile: { @@ -5303,10 +5287,6 @@ if (JA->getType() == types::TY_dSYM) BaseInput = InputInfos[0].getFilename(); - // ... and in header module compilations, which use the module name. - if (auto *ModuleJA = dyn_cast(JA)) - BaseInput = ModuleJA->getModuleName(); - // Append outputs of offload device jobs to the input list if (!OffloadDependencesInputInfo.empty()) InputInfos.append(OffloadDependencesInputInfo.begin(), diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4539,7 +4539,6 @@ bool IsHIP = JA.isOffloading(Action::OFK_HIP); bool IsHIPDevice = JA.isDeviceOffloading(Action::OFK_HIP); bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP); - bool IsHeaderModulePrecompile = isa(JA); bool IsExtractAPI = isa(JA); bool IsDeviceOffloadAction = !(JA.isDeviceOffloading(Action::OFK_None) || JA.isDeviceOffloading(Action::OFK_Host)); @@ -4554,28 +4553,17 @@ bool IsUsingLTO = D.isUsingLTO(IsDeviceOffloadAction); auto LTOMode = D.getLTOMode(IsDeviceOffloadAction); - // A header module compilation doesn't have a main input file, so invent a - // fake one as a placeholder. - const char *ModuleName = [&] { - auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ); - return ModuleNameArg ? ModuleNameArg->getValue() : ""; - }(); - InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName); - // Extract API doesn't have a main input file, so invent a fake one as a // placeholder. InputInfo ExtractAPIPlaceholderInput(Inputs[0].getType(), "extract-api", "extract-api"); const InputInfo &Input = [&]() -> const InputInfo & { - if (IsHeaderModulePrecompile) - return HeaderModuleInput; if (IsExtractAPI) return ExtractAPIPlaceholderInput; return Inputs[0]; }(); - InputInfoList ModuleHeaderInputs; InputInfoList ExtractAPIInputs; InputInfoList HostOffloadingInputs; const InputInfo *CudaDeviceInput = nullptr; @@ -4583,15 +4571,6 @@ for (const InputInfo &I : Inputs) { if (&I == &Input || I.getType() == types::TY_Nothing) { // This is the primary input or contains nothing. - } else if (IsHeaderModulePrecompile && - types::getPrecompiledType(I.getType()) == types::TY_PCH) { - types::ID Expected = HeaderModuleInput.getType(); - if (I.getType() != Expected) { - D.Diag(diag::err_drv_module_header_wrong_kind) - << I.getFilename() << types::getTypeName(I.getType()) - << types::getTypeName(Expected); - } - ModuleHeaderInputs.push_back(I); } else if (IsExtractAPI) { auto ExpectedInputType = ExtractAPIPlaceholderInput.getType(); if (I.getType() != ExpectedInputType) { @@ -4779,9 +4758,7 @@ if (JA.getType() == types::TY_Nothing) CmdArgs.push_back("-fsyntax-only"); else if (JA.getType() == types::TY_ModuleFile) - CmdArgs.push_back(IsHeaderModulePrecompile - ? "-emit-header-module" - : "-emit-module-interface"); + CmdArgs.push_back("-emit-module-interface"); else if (JA.getType() == types::TY_HeaderUnit) CmdArgs.push_back("-emit-header-unit"); else @@ -7376,9 +7353,7 @@ addDashXForInput(Args, Input, CmdArgs); ArrayRef FrontendInputs = Input; - if (IsHeaderModulePrecompile) - FrontendInputs = ModuleHeaderInputs; - else if (IsExtractAPI) + if (IsExtractAPI) FrontendInputs = ExtractAPIInputs; else if (Input.isNothing()) FrontendInputs = {}; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2469,7 +2469,6 @@ {frontend::GenerateModule, OPT_emit_module}, {frontend::GenerateModuleInterface, OPT_emit_module_interface}, - {frontend::GenerateHeaderModule, OPT_emit_header_module}, {frontend::GenerateHeaderUnit, OPT_emit_header_unit}, {frontend::GeneratePCH, OPT_emit_pch}, {frontend::GenerateInterfaceStubs, OPT_emit_interface_stubs}, @@ -4129,7 +4128,6 @@ case frontend::FixIt: case frontend::GenerateModule: case frontend::GenerateModuleInterface: - case frontend::GenerateHeaderModule: case frontend::GenerateHeaderUnit: case frontend::GeneratePCH: case frontend::GenerateInterfaceStubs: diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -265,77 +265,6 @@ return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm"); } -bool GenerateHeaderModuleAction::PrepareToExecuteAction( - CompilerInstance &CI) { - if (!CI.getLangOpts().Modules) { - CI.getDiagnostics().Report(diag::err_header_module_requires_modules); - return false; - } - - auto &Inputs = CI.getFrontendOpts().Inputs; - if (Inputs.empty()) - return GenerateModuleAction::BeginInvocation(CI); - - auto Kind = Inputs[0].getKind(); - - // Convert the header file inputs into a single module input buffer. - SmallString<256> HeaderContents; - ModuleHeaders.reserve(Inputs.size()); - for (const FrontendInputFile &FIF : Inputs) { - // FIXME: We should support re-compiling from an AST file. - if (FIF.getKind().getFormat() != InputKind::Source || !FIF.isFile()) { - CI.getDiagnostics().Report(diag::err_module_header_file_not_found) - << (FIF.isFile() ? FIF.getFile() - : FIF.getBuffer().getBufferIdentifier()); - return true; - } - - HeaderContents += "#include \""; - HeaderContents += FIF.getFile(); - HeaderContents += "\"\n"; - ModuleHeaders.push_back(std::string(FIF.getFile())); - } - Buffer = llvm::MemoryBuffer::getMemBufferCopy( - HeaderContents, Module::getModuleInputBufferName()); - - // Set that buffer up as our "real" input. - Inputs.clear(); - Inputs.push_back( - FrontendInputFile(Buffer->getMemBufferRef(), Kind, /*IsSystem*/ false)); - - return GenerateModuleAction::PrepareToExecuteAction(CI); -} - -bool GenerateHeaderModuleAction::BeginSourceFileAction( - CompilerInstance &CI) { - CI.getLangOpts().setCompilingModule(LangOptions::CMK_HeaderModule); - - // Synthesize a Module object for the given headers. - auto &HS = CI.getPreprocessor().getHeaderSearchInfo(); - SmallVector Headers; - for (StringRef Name : ModuleHeaders) { - Optional FE = HS.LookupFile( - Name, SourceLocation(), /*Angled*/ false, nullptr, nullptr, None, - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); - if (!FE) { - CI.getDiagnostics().Report(diag::err_module_header_file_not_found) - << Name; - continue; - } - Headers.push_back( - {std::string(Name), std::string(Name), &FE->getFileEntry()}); - } - HS.getModuleMap().createHeaderModule(CI.getLangOpts().CurrentModule, Headers); - - return GenerateModuleAction::BeginSourceFileAction(CI); -} - -std::unique_ptr -GenerateHeaderModuleAction::CreateOutputFile(CompilerInstance &CI, - StringRef InFile) { - return CI.createDefaultOutputFile(/*Binary=*/true, InFile, "pcm"); -} - bool GenerateHeaderUnitAction::BeginSourceFileAction(CompilerInstance &CI) { if (!CI.getLangOpts().CPlusPlusModules) { CI.getDiagnostics().Report(diag::err_module_interface_requires_cpp_modules); diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -65,8 +65,6 @@ return std::make_unique(); case GenerateModuleInterface: return std::make_unique(); - case GenerateHeaderModule: - return std::make_unique(); case GenerateHeaderUnit: return std::make_unique(); case GeneratePCH: return std::make_unique(); diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -899,29 +899,6 @@ return Result; } -Module *ModuleMap::createHeaderModule(StringRef Name, - ArrayRef Headers) { - assert(LangOpts.CurrentModule == Name && "module name mismatch"); - assert(!Modules[Name] && "redefining existing module"); - - auto *Result = - new Module(Name, SourceLocation(), nullptr, /*IsFramework*/ false, - /*IsExplicit*/ false, NumCreatedModules++); - Result->Kind = Module::ModuleInterfaceUnit; - Modules[Name] = SourceModule = Result; - - for (const Module::Header &H : Headers) { - auto *M = new Module(H.NameAsWritten, SourceLocation(), Result, - /*IsFramework*/ false, - /*IsExplicit*/ true, NumCreatedModules++); - // Header modules are implicitly 'export *'. - M->Exports.push_back(Module::ExportDecl(nullptr, true)); - addHeader(M, H, NormalHeader); - } - - return Result; -} - Module *ModuleMap::createHeaderUnit(SourceLocation Loc, StringRef Name, Module::Header H) { assert(LangOpts.CurrentModule == Name && "module name mismatch"); diff --git a/clang/test/CXX/cpp/cpp.module/Inputs/attrs.h b/clang/test/CXX/cpp/cpp.module/Inputs/attrs.h deleted file mode 100644 --- a/clang/test/CXX/cpp/cpp.module/Inputs/attrs.h +++ /dev/null @@ -1 +0,0 @@ -#define ATTRS [[ ]] diff --git a/clang/test/CXX/cpp/cpp.module/Inputs/empty.h b/clang/test/CXX/cpp/cpp.module/Inputs/empty.h deleted file mode 100644 diff --git a/clang/test/CXX/cpp/cpp.module/p1.cpp b/clang/test/CXX/cpp/cpp.module/p1.cpp deleted file mode 100644 --- a/clang/test/CXX/cpp/cpp.module/p1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -std=c++2a -emit-header-module -fmodule-name=attrs -x c++-header %S/Inputs/empty.h %S/Inputs/attrs.h -o %t.pcm -// RUN: %clang_cc1 -std=c++2a %s -fmodule-file=%t.pcm -E -verify -I%S/Inputs | FileCheck %s - -#define SEMI ; -// expected-error@+1 {{semicolon terminating header import declaration cannot be produced by a macro}} -import "empty.h" SEMI // CHECK: import attrs.{{.*}}; - -#define IMPORT import "empty.h" -IMPORT; // CHECK: import attrs.{{.*}}; - -#define IMPORT_ANGLED import -IMPORT_ANGLED; // CHECK: import attrs.{{.*}}; - -// Ensure that macros only become visible at the semicolon. -// CHECK: import attrs.{{.*}} ATTRS ; -import "attrs.h" ATTRS ; -// CHECK: {{\[\[}} ]] int n; -ATTRS int n; diff --git a/clang/test/CXX/cpp/cpp.module/p2.cpp b/clang/test/CXX/cpp/cpp.module/p2.cpp deleted file mode 100644 --- a/clang/test/CXX/cpp/cpp.module/p2.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -std=c++2a -emit-header-module -fmodule-name=attrs -x c++-header %S/Inputs/empty.h %S/Inputs/attrs.h -o %t.pcm -// RUN: %clang_cc1 -std=c++2a %s -fmodule-file=%t.pcm -fsyntax-only -verify -I%S/Inputs - -template struct import; // expected-note 2{{previous}} -constexpr struct { int h; } empty = {0}; -struct A; -struct B; -struct C; -template<> struct import<0> { - static A a; - static B b; - static C c; -}; - -// OK, not an import-declaration. -struct A {} -::import -::a; - -// This is invalid: the tokens after 'import' are a header-name, so cannot be -// parsed as a template-argument-list. -struct B {} -import // expected-error {{redefinition of 'import'}} expected-error {{expected ';'}} -::b; // (error recovery skips these tokens) - -// Likewise, this is ill-formed after the tokens are reconstituted into a -// header-name token. -struct C {} -import // expected-error {{redefinition of 'import'}} expected-error {{expected ';'}} -< -empty.h // (error recovery skips these tokens) ->::c; diff --git a/clang/test/CXX/module/module.interface/p2.cpp b/clang/test/CXX/module/module.interface/p2.cpp --- a/clang/test/CXX/module/module.interface/p2.cpp +++ b/clang/test/CXX/module/module.interface/p2.cpp @@ -1,11 +1,11 @@ // RUN: rm -rf %t // RUN: mkdir -p %t -// RUN: %clang_cc1 -std=c++2a -x c++-header %S/Inputs/header.h -emit-header-module -fmodule-name=FIXME -o %t/h.pcm -// RUN: %clang_cc1 -std=c++2a %s -DX_INTERFACE -emit-module-interface -o %t/x.pcm -// RUN: %clang_cc1 -std=c++2a %s -DY_INTERFACE -emit-module-interface -o %t/y.pcm -// RUN: %clang_cc1 -std=c++2a %s -DINTERFACE -fmodule-file=%t/x.pcm -fmodule-file=%t/y.pcm -emit-module-interface -o %t/m.pcm -// RUN: %clang_cc1 -std=c++2a %s -DIMPLEMENTATION -I%S/Inputs -fmodule-file=%t/h.pcm -fmodule-file=%t/m.pcm -verify -// RUN: %clang_cc1 -std=c++2a %s -DUSER -I%S/Inputs -fmodule-file=%t/h.pcm -fmodule-file=%t/m.pcm -verify +// RUN: %clang_cc1 -std=c++20 -x c++-header %S/Inputs/header.h -emit-header-unit -o %t/h.pcm +// RUN: %clang_cc1 -std=c++20 %s -DX_INTERFACE -emit-module-interface -o %t/x.pcm +// RUN: %clang_cc1 -std=c++20 %s -DY_INTERFACE -emit-module-interface -o %t/y.pcm +// RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -fmodule-file=%t/x.pcm -fmodule-file=%t/y.pcm -emit-module-interface -o %t/m.pcm +// RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -I%S/Inputs -fmodule-file=%t/h.pcm -fmodule-file=%t/m.pcm -verify +// RUN: %clang_cc1 -std=c++20 %s -DUSER -I%S/Inputs -fmodule-file=%t/h.pcm -fmodule-file=%t/m.pcm -verify #if defined(X_INTERFACE) export module X; diff --git a/clang/test/Driver/header-module.cpp b/clang/test/Driver/header-module.cpp deleted file mode 100644 --- a/clang/test/Driver/header-module.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Check compiling a header module to a .pcm file. -// -// RUN: %clang -fmodules-ts -fmodule-name=foobar -x c++-header --precompile %S/Inputs/header1.h %S/Inputs/header2.h %S/Inputs/header3.h -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE -// -// CHECK-PRECOMPILE: -cc1 {{.*}} -emit-header-module -// CHECK-PRECOMPILE-SAME: -fmodules-ts -// CHECK-PRECOMPILE-SAME: -fno-implicit-modules -// CHECK-PRECOMPILE-SAME: -fmodule-name=foobar -// CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm -// CHECK-PRECOMPILE-SAME: -x c++-header -// CHECK-PRECOMPILE-SAME: header1.h -// CHECK-PRECOMPILE-SAME: header2.h -// CHECK-PRECOMPILE-SAME: header3.h -// -// RUN: %clang -fmodules-ts -fmodule-name=foobar -x c++-header -fsyntax-only %S/Inputs/header1.h %S/Inputs/header2.h %S/Inputs/header3.h -v 2>&1 | FileCheck %s --check-prefix=CHECK-SYNTAX-ONLY -// CHECK-SYNTAX-ONLY: -cc1 {{.*}} -fsyntax-only -// CHECK-SYNTAX-ONLY-SAME: -fmodules-ts -// CHECK-SYNTAX-ONLY-SAME: -fno-implicit-modules -// CHECK-SYNTAX-ONLY-SAME: -fmodule-name=foobar -// CHECK-SYNTAX-ONLY-NOT: -o{{ }} -// CHECK-SYNTAX-ONLY-SAME: -x c++-header -// CHECK-SYNTAX-ONLY-SAME: header1.h -// CHECK-SYNTAX-ONLY-SAME: header2.h -// CHECK-SYNTAX-ONLY-SAME: header3.h diff --git a/clang/test/Driver/modules.cpp b/clang/test/Driver/modules.cpp --- a/clang/test/Driver/modules.cpp +++ b/clang/test/Driver/modules.cpp @@ -39,37 +39,4 @@ // RUN: cp %s %t/module.cppm // RUN: %clang -std=c++2a --precompile %t/module.cppm -o %t/module.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE -// Check compiling a header unit to a .pcm file. -// -// RUN: echo '#define FOO BAR' > %t/foo.h -// RUN: %clang -std=c++2a --precompile -x c++-header %t/foo.h -fmodule-name=header -o %t/foo.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-HEADER-UNIT -// -// CHECK-HEADER-UNIT: -cc1 -// CHECK-HEADER-UNIT-SAME: -emit-header-module -// CHECK-HEADER-UNIT-SAME: -fmodule-name=header -// CHECK-HEADER-UNIT-SAME: -o {{.*}}foo.pcm -// CHECK-HEADER-UNIT-SAME: -x c++-header -// CHECK-HEADER-UNIT-SAME: foo.h - -// Check use of header unit. -// -// RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -fmodule-file=%t/foo.pcm -I%t -DIMPORT -Dexport= %s -E -o - -v 2>&1 | FileCheck %s --check-prefix=CHECK-HEADER-UNIT-USE -// -// CHECK-HEADER-UNIT-USE: -cc1 -// CHECK-HEADER-UNIT-USE: -E -// CHECK-HEADER-UNIT-USE: -fmodule-file={{.*}}module.pcm -// CHECK-HEADER-UNIT-USE: -fmodule-file={{.*}}foo.pcm - -// Note, we use -Dexport= to make this a module implementation unit when building the implementation. export module foo; - -#ifdef IMPORT -// CHECK-HEADER-UNIT-USE: FOO; -FOO; - -// CHECK-HEADER-UNIT-USE: import header.{{.*}}foo.h{{.*}}; -import "foo.h"; - -// CHECK-HEADER-UNIT-USE: BAR; -FOO; -#endif diff --git a/clang/test/Misc/serialized-diags-emit-header-module-misconfig.c b/clang/test/Misc/serialized-diags-emit-header-module-misconfig.c deleted file mode 100644 --- a/clang/test/Misc/serialized-diags-emit-header-module-misconfig.c +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: rm -rf %t && mkdir %t -// RUN: not %clang_cc1 -emit-header-module %s -o %t/out.pcm -serialize-diagnostic-file %t/diag 2>&1 | FileCheck %s - -// CHECK: error: header module compilation requires '-fmodules', '-std=c++20', or '-fmodules-ts' diff --git a/clang/test/Modules/no-module-map.cpp b/clang/test/Modules/no-module-map.cpp deleted file mode 100644 --- a/clang/test/Modules/no-module-map.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -fmodule-name=ab -x c++-header %S/Inputs/no-module-map/a.h %S/Inputs/no-module-map/b.h -emit-header-module -o %t.pcm -// RUN: %clang_cc1 -fmodules-ts -fmodule-file=%t.pcm %s -I%S/Inputs/no-module-map -verify -// RUN: %clang_cc1 -fmodules-ts -fmodule-file=%t.pcm %s -I%S/Inputs/no-module-map -verify -DA -// RUN: %clang_cc1 -fmodules-ts -fmodule-file=%t.pcm %s -I%S/Inputs/no-module-map -verify -DB -// RUN: %clang_cc1 -fmodules-ts -fmodule-file=%t.pcm %s -I%S/Inputs/no-module-map -verify -DA -DB - -// RUN: %clang_cc1 -E %t.pcm -o - | FileCheck %s -// RUN: %clang_cc1 -frewrite-imports -E %t.pcm -o - | FileCheck %s -// CHECK: # {{.*}}a.h -// CHECK: # {{.*}}b.h - -#ifdef B -// expected-no-diagnostics -#endif - -#ifdef A -#include "a.h" -#endif - -#ifdef B -#include "b.h" -#endif - -#if defined(A) || defined(B) -#ifndef A_H -#error A_H should be defined -#endif -#else -#ifdef A_H -#error A_H should not be defined -#endif -// expected-error@+3 {{must be imported from}} -// expected-note@* {{declaration}} -#endif -void use_a() { a(); } - -#if defined(B) -#ifndef B_H -#error B_H should be defined -#endif -#else -#ifdef B_H -#error B_H should not be defined -#endif -// expected-error@+3 {{must be imported from}} -// expected-note@* {{declaration}} -#endif -void use_b() { b(); }