]> granicus.if.org Git - clang/commitdiff
When building a header module, treat inputs as headers rather than
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 2 Nov 2018 00:24:40 +0000 (00:24 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 2 Nov 2018 00:24:40 +0000 (00:24 +0000)
source files.

This suppresses certain warnings (eg, '#include_next in main source
file').

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345915 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Clang.cpp
test/Driver/header-module.cpp

index eda8912156ce7b9d2584c220d71709f85535d1fb..926db3d4f9d5a4fb17e64a924ed23ab2dc29ca71 100644 (file)
@@ -3254,12 +3254,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &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(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, const JobAction &JA,
       // 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())
index 776584004207b03eb6a87cfc7ad7931fb0d14f62..9a6ba5b108fc573190b76c14d6514c5718d8bb82 100644 (file)
@@ -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