r345915 - When building a header module, treat inputs as headers rather than
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 1 17:24:40 PDT 2018
Author: rsmith
Date: Thu Nov 1 17:24:40 2018
New Revision: 345915
URL: http://llvm.org/viewvc/llvm-project?rev=345915&view=rev
Log:
When building a header module, treat inputs as headers rather than
source files.
This suppresses certain warnings (eg, '#include_next in main source
file').
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/header-module.cpp
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=345915&r1=345914&r2=345915&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Nov 1 17:24:40 2018
@@ -3254,12 +3254,11 @@ void Clang::ConstructJob(Compilation &C,
// 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(types::TY_CXXModule, ModuleName, ModuleName);
+ InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName);
const InputInfo &Input =
IsHeaderModulePrecompile ? HeaderModuleInput : Inputs[0];
@@ -3272,8 +3271,7 @@ void Clang::ConstructJob(Compilation &C,
// This is the primary input.
} else if (IsHeaderModulePrecompile &&
types::getPrecompiledType(I.getType()) == types::TY_PCH) {
- types::ID Expected =
- types::lookupHeaderTypeForSourceType(Inputs[0].getType());
+ types::ID Expected = HeaderModuleInput.getType();
if (I.getType() != Expected) {
D.Diag(diag::err_drv_module_header_wrong_kind)
<< I.getFilename() << types::getTypeName(I.getType())
Modified: cfe/trunk/test/Driver/header-module.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/header-module.cpp?rev=345915&r1=345914&r2=345915&view=diff
==============================================================================
--- cfe/trunk/test/Driver/header-module.cpp (original)
+++ cfe/trunk/test/Driver/header-module.cpp Thu Nov 1 17:24:40 2018
@@ -7,7 +7,7 @@
// CHECK-PRECOMPILE-SAME: -fno-implicit-modules
// CHECK-PRECOMPILE-SAME: -fmodule-name=foobar
// CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
-// CHECK-PRECOMPILE-SAME: -x c++
+// CHECK-PRECOMPILE-SAME: -x c++-header
// CHECK-PRECOMPILE-SAME: header1.h
// CHECK-PRECOMPILE-SAME: header2.h
// CHECK-PRECOMPILE-SAME: header3.h
@@ -18,7 +18,7 @@
// 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++
+// 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
More information about the cfe-commits
mailing list