Skip to content

Commit 477dd77

Browse files
authored
[SYCLomatic][CMake] Fix bug that file names with pattern "src/*foo*.cu" in CMake script are not migrated well (#2854)
Signed-off-by: chenwei.sun <chenwei.sun@intel.com>
1 parent 6af8716 commit 477dd77

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

clang/lib/DPCT/UserDefinedRules/PatternRewriter.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -384,29 +384,34 @@ static int parseCodeElement(const MatchPattern &Suffix,
384384
continue;
385385
}
386386

387-
if (Character == '/' && Index < (Size - 1) && Input[Index + 1] == '/') {
388-
Index += 2;
389-
while (Index < Size && Input[Index] != '\n') {
387+
if (SrcFileType != SourceFileType::SFT_CMakeScript &&
388+
SrcFileType != SourceFileType::SFT_PySetupScript) {
389+
// Skip single line comment for C/C++
390+
if (Character == '/' && Index < (Size - 1) && Input[Index + 1] == '/') {
391+
Index += 2;
392+
while (Index < Size && Input[Index] != '\n') {
393+
Index++;
394+
}
395+
if (Index >= Size) {
396+
return -1;
397+
}
390398
Index++;
399+
continue;
391400
}
392-
if (Index >= Size) {
393-
return -1;
394-
}
395-
Index++;
396-
continue;
397-
}
398401

399-
if (Character == '/' && Index < (Size - 1) && Input[Index + 1] == '*') {
400-
Index += 2;
401-
while (Index < Size &&
402-
!(Input[Index - 1] == '*' && Input[Index] == '/')) {
402+
// Skip multi-line comments for C/C++
403+
if (Character == '/' && Index < (Size - 1) && Input[Index + 1] == '*') {
404+
Index += 2;
405+
while (Index < Size &&
406+
!(Input[Index - 1] == '*' && Input[Index] == '/')) {
407+
Index++;
408+
}
409+
if (Index >= Size) {
410+
return -1;
411+
}
403412
Index++;
413+
continue;
404414
}
405-
if (Index >= Size) {
406-
return -1;
407-
}
408-
Index++;
409-
continue;
410415
}
411416

412417
Index++;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
file(GLOB REL_CUDA_SRC "file1.dp.cpp" "${CMAKE_SOURCE_DIR}/src/*.dp.cpp")
22
file(GLOB SRCS *.cc *.dp.cpp *.dp.hpp)
3+
file(GLOB_RECURSE DECODE_KERNELS_SRCS
4+
${PROJECT_SOURCE_DIR}/src/generated/d*decode_head*.dp.cpp)
5+
file(GLOB_RECURSE PREFILL_KERNELS_SRCS
6+
${PROJECT_SOURCE_DIR}/src/generated/*prefill_head*.dp.cpp)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
file(GLOB REL_CUDA_SRC "file1.cu" "${CMAKE_SOURCE_DIR}/src/*.cu")
22
file(GLOB SRCS *.cc *.cu *.cuh)
3+
file(GLOB_RECURSE DECODE_KERNELS_SRCS
4+
${PROJECT_SOURCE_DIR}/src/generated/d*decode_head*.cu)
5+
file(GLOB_RECURSE PREFILL_KERNELS_SRCS
6+
${PROJECT_SOURCE_DIR}/src/generated/*prefill_head*.cu)

0 commit comments

Comments
 (0)