Skip to content

Commit 4f1f330

Browse files
authored
[SYCLomatic]Fix the issue where the header file surrounded by quotes is not found in the search path. (#2877)
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
1 parent 8807950 commit 4f1f330

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,6 +3409,13 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
34093409
&Opts](const llvm::opt::Arg *A,
34103410
bool IsFramework = false) -> std::string {
34113411
assert(A->getNumValues() && "Unexpected empty search path flag!");
3412+
#ifdef SYCLomatic_CUSTOMIZATION
3413+
if (A->getValue()[0] == '"') {
3414+
std::string str(A->getValue());
3415+
str.erase(std::remove(str.begin(), str.end(), '"'), str.end());
3416+
return str;
3417+
}
3418+
#endif
34123419
if (IsSysrootSpecified && !IsFramework && A->getValue()[0] == '=') {
34133420
SmallString<32> Buffer;
34143421
llvm::sys::path::append(Buffer, Opts.Sysroot,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: cd %T
2+
// RUN: cat %S/compile_commands.json > %T/compile_commands.json
3+
// RUN: cat %S/case_in_db.c > %T/case_in_db.c
4+
5+
// RUN: dpct --format-range=none -in-root=%T -out-root=%T/out case_in_db.c --format-range=none --cuda-include-path="%cuda-path/include"
6+
// RUN: FileCheck %T/case_in_db.c --match-full-lines --input-file %T/out/case_in_db.c.dp.cpp
7+
8+
9+
// CHECK: #include <sycl/sycl.hpp>
10+
// CHECK-NEXT: #include <dpct/dpct.hpp>
11+
#include <cuda_runtime.h>
12+
#include <test.h>
13+
14+
15+
int main() {
16+
print_test();
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"command": "nvcc -c -I \"./test\" -isystem \"./test\" ./case_in_db.c",
4+
"directory": ".",
5+
"file": "./case_in_db.c"
6+
}
7+
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include <stdio.h>
2+
void print_test() {
3+
printf("XXXXXXXXX\n");
4+
}

0 commit comments

Comments
 (0)