forked from OSchip/llvm-project
enable -save-temps with -finclude-defult-header
Currently the two flags can not work together. To illustrate the issue, we can have an one line file a.cl contains only an empty function cat a.cl void test(){} Then use clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c a.cl we will get redefinition errors for various things. The reason is that the -finclude-default-header flag is not meant to be on cc1 command other than the preprocessor. The fix is modeled after the code just below the change to filter the -finclude-default-header flag out when we are not in the preprocess phase. Differential Revision: https://reviews.llvm.org/D30743 llvm-svn: 297890
This commit is contained in:
parent
718e8ad239
commit
4747cf5677
|
@ -4268,7 +4268,19 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
// Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
|
||||
// parser.
|
||||
Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
|
||||
// -finclude-default-header flag is for preprocessor,
|
||||
// do not pass it to other cc1 commands when save-temps is enabled
|
||||
if (C.getDriver().isSaveTempsEnabled() &&
|
||||
!isa<PreprocessJobAction>(JA)) {
|
||||
for (auto Arg : Args.filtered(options::OPT_Xclang)) {
|
||||
Arg->claim();
|
||||
if (StringRef(Arg->getValue()) != "-finclude-default-header")
|
||||
CmdArgs.push_back(Arg->getValue());
|
||||
}
|
||||
}
|
||||
else {
|
||||
Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
|
||||
}
|
||||
for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
|
||||
A->claim();
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// RUN: %clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c %s
|
||||
|
||||
void test() {}
|
||||
|
Loading…
Reference in New Issue