From 9914c3a2bae84bb92e5269165c4d098140549b46 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 2 Nov 2018 00:24:40 +0000 Subject: [PATCH] When building a header module, treat inputs as headers rather than source files. This suppresses certain warnings (eg, '#include_next in main source file'). llvm-svn: 345915 --- clang/lib/Driver/ToolChains/Clang.cpp | 6 ++---- clang/test/Driver/header-module.cpp | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index eda8912..926db3d 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -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()) diff --git a/clang/test/Driver/header-module.cpp b/clang/test/Driver/header-module.cpp index 7765840..9a6ba5b 100644 --- a/clang/test/Driver/header-module.cpp +++ b/clang/test/Driver/header-module.cpp @@ -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 -- 2.7.4