Skip to content

Commit c74601e

Browse files
openeuler-ci-botgitee-org
authored andcommitted
!131 [clang] Set default prefix for search path when prefix is empty
From: @luofeng14 Reviewed-by: @cf-zhao Signed-off-by: @cf-zhao
2 parents 7d5f23c + ae28a7e commit c74601e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,6 +4689,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
46894689
#ifdef BUILD_FOR_OPENEULER
46904690
if (Args.hasFlag(options::OPT_fgcc_compatible,
46914691
options::OPT_fno_gcc_compatible, false)) {
4692+
if (Args.hasArg(options::OPT_nostdinc) && !Args.hasArg(options::OPT_iprefix)) {
4693+
SmallString<128> P(D.ResourceDir);
4694+
P += llvm::sys::path::get_separator();
4695+
CmdArgs.insert(CmdArgs.begin() + 1, "-iprefix");
4696+
CmdArgs.insert(CmdArgs.begin() + 2, Args.MakeArgString(P));
4697+
}
46924698
// compatibility relevent warnings
46934699
CmdArgs.push_back("-Wno-error=unknown-warning-option");
46944700
CmdArgs.push_back("-Wno-error=ignored-attributes");

clang/test/Driver/prefix.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: build_for_openeuler
2+
3+
// RUN: %clang %s
4+
// RUN: %clang -iprefix $(dirname `which clang`)/../lib/clang/*/ -iwithprefix include %s
5+
// RUN: %clang -iwithprefix include %s
6+
// RUN: %clang -nostdinc -iwithprefix include %s -fgcc-compatible
7+
// RUN: %clang -nostdinc -iprefix $(dirname `which clang`)/../lib/clang/*/ -iwithprefix include %s -fgcc-compatible
8+
// RUN: not %clang -nostdinc -iwithprefix include %s
9+
// RUN: not %clang -nostdinc -iprefix "" -iwithprefix include %s
10+
11+
#include <stdarg.h>
12+
int main(void) {
13+
return 0;
14+
}

0 commit comments

Comments
 (0)