Index: clang/include/clang/Frontend/FrontendActions.h =================================================================== --- clang/include/clang/Frontend/FrontendActions.h +++ 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: Index: clang/include/clang/Frontend/FrontendOptions.h =================================================================== --- clang/include/clang/Frontend/FrontendOptions.h +++ 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, Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ 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: Index: clang/lib/Frontend/FrontendActions.cpp =================================================================== --- clang/lib/Frontend/FrontendActions.cpp +++ 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); Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp =================================================================== --- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ 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(); Index: clang/test/CXX/cpp/cpp.module/Inputs/attrs.h =================================================================== --- clang/test/CXX/cpp/cpp.module/Inputs/attrs.h +++ /dev/null @@ -1 +0,0 @@ -#define ATTRS [[ ]] Index: clang/test/CXX/cpp/cpp.module/p1.cpp =================================================================== --- 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; Index: clang/test/CXX/cpp/cpp.module/p2.cpp =================================================================== --- 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; Index: clang/test/CXX/module/module.interface/p2.cpp =================================================================== --- clang/test/CXX/module/module.interface/p2.cpp +++ 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; Index: clang/test/Driver/header-module.cpp =================================================================== --- clang/test/Driver/header-module.cpp +++ clang/test/Driver/header-module.cpp @@ -1,17 +1,5 @@ // 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 Index: clang/test/Driver/modules.cpp =================================================================== --- clang/test/Driver/modules.cpp +++ 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 Index: clang/test/Misc/serialized-diags-emit-header-module-misconfig.c =================================================================== --- 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' Index: clang/test/Modules/no-module-map.cpp =================================================================== --- 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(); }