summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-11-02 10:50:26 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-11-02 10:50:26 +0000
commitdfc56b43fadf5c4f84cdb8706f29ccf1ba68e5f1 (patch)
tree0bd6f725005d90565af782110bcfd14491692502
parent7d1b77df57fb6a14d2ef15f0e9123650ccee0cc4 (diff)
downloadbcm5719-llvm-dfc56b43fadf5c4f84cdb8706f29ccf1ba68e5f1.tar.gz
bcm5719-llvm-dfc56b43fadf5c4f84cdb8706f29ccf1ba68e5f1.zip
Revert "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"
This reverts commit r345803 and r345915 (a follow-up fix to r345803). Reason: r345803 blocks our internal integrate because of the new warnings showing up in too many places. The fix is actually correct, we will reland it after figuring out how to integrate properly. llvm-svn: 345963
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp10
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp3
-rw-r--r--clang/lib/Lex/ModuleMap.cpp2
-rw-r--r--clang/test/Driver/header-module.cpp13
-rw-r--r--clang/test/Modules/strict-decluse-headers.cpp17
5 files changed, 9 insertions, 36 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 926db3d4f9d..a8ddd8adc32 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3250,15 +3250,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
bool IsHIP = JA.isOffloading(Action::OFK_HIP);
bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
+ bool IsModulePrecompile =
+ isa<PrecompileJobAction>(JA) && JA.getType() == types::TY_ModuleFile;
bool IsHeaderModulePrecompile = isa<HeaderModulePrecompileJobAction>(JA);
// A header module compilation doesn't have a main input file, so invent a
// fake one as a placeholder.
+ // FIXME: Pick the language based on the header file language.
const char *ModuleName = [&]{
auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
return ModuleNameArg ? ModuleNameArg->getValue() : "";
}();
- InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName);
+ InputInfo HeaderModuleInput(types::TY_CXXModule, ModuleName, ModuleName);
const InputInfo &Input =
IsHeaderModulePrecompile ? HeaderModuleInput : Inputs[0];
@@ -3269,9 +3272,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
for (const InputInfo &I : Inputs) {
if (&I == &Input) {
// This is the primary input.
- } else if (IsHeaderModulePrecompile &&
+ } else if (IsModulePrecompile &&
types::getPrecompiledType(I.getType()) == types::TY_PCH) {
- types::ID Expected = HeaderModuleInput.getType();
+ types::ID Expected =
+ types::lookupHeaderTypeForSourceType(Inputs[0].getType());
if (I.getType() != Expected) {
D.Diag(diag::err_drv_module_header_wrong_kind)
<< I.getFilename() << types::getTypeName(I.getType())
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 719474dc765..a9c51d49f65 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -372,9 +372,6 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags,
void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
const PreprocessorOptions &PPOpts = getPreprocessorOpts();
- // The module manager holds a reference to the old preprocessor (if any).
- ModuleManager.reset();
-
// Create a PTH manager if we are using some form of a token cache.
PTHManager *PTHMgr = nullptr;
if (!PPOpts.TokenCache.empty())
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 13d2b728f58..d44bf124ffc 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -523,7 +523,7 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
// At this point, only non-modular includes remain.
- if (RequestingModule && LangOpts.ModulesStrictDeclUse) {
+ if (LangOpts.ModulesStrictDeclUse) {
Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
<< RequestingModule->getTopLevelModule()->Name << Filename;
} else if (RequestingModule && RequestingModuleIsModuleInterface &&
diff --git a/clang/test/Driver/header-module.cpp b/clang/test/Driver/header-module.cpp
index 9a6ba5b108f..2302c495f10 100644
--- a/clang/test/Driver/header-module.cpp
+++ b/clang/test/Driver/header-module.cpp
@@ -7,18 +7,7 @@
// 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: -x c++
// 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/Modules/strict-decluse-headers.cpp b/clang/test/Modules/strict-decluse-headers.cpp
deleted file mode 100644
index deeda2fe7f4..00000000000
--- a/clang/test/Modules/strict-decluse-headers.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
-// RUN: touch %t/foo.h
-// RUN: echo '#include "foo.h"' > %t/bar.h
-// RUN: touch %t/baz.h
-// RUN: echo 'module X { header "bar.h" header "baz.h" }' > %t/map
-//
-// RUN: not %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%t/map -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/bar.h %t/baz.h 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%t/map -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/baz.h %t/bar.h 2>&1 | FileCheck %s
-//
-// Don't crash on this: (FIXME: we should produce an error that the specified module name is not known)
-// RUN: %clang_cc1 -fsyntax-only -fmodules -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/baz.h %t/bar.h
-//
-// Don't crash on this: (FIXME: we should produce an error that the specified file is not part of the specified module)
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%t/map -I%t -fmodules-strict-decluse -fmodule-name=X -x c++ %t/foo.h
-//
-// CHECK: module X does not depend on a module exporting 'foo.h'
OpenPOWER on IntegriCloud