Skip to content

Commit

Permalink
[SYCL] Fix -Wstring-concatenation in integration headers (#15197)
Browse files Browse the repository at this point in the history
A sentinel value added in #15175 fixed the problem of empty arrays, but
for non-empty arrays was just concatenated to the last valid value. This
produced warnings when compiling SYCL applications, and also meant that
there is no sentinel value in the non-empty arrays.
  • Loading branch information
al42and authored Sep 3, 2024
1 parent 16ee2e8 commit 45b2ce3
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
6 changes: 1 addition & 5 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6188,11 +6188,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
O << "const char* const kernel_names[] = {\n";

for (unsigned I = 0; I < KernelDescs.size(); I++) {
O << " \"" << KernelDescs[I].Name << "\"";

if (I < KernelDescs.size() - 1)
O << ",";
O << "\n";
O << " \"" << KernelDescs[I].Name << "\",\n";
}
// Add a sentinel to avoid warning if the collection is empty
// (similar to what we do for kernel_signatures below).
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/int-header-empty-signatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// CHECK: static constexpr
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "_ZTSZ4mainE1K"
// CHECK-NEXT: "_ZTSZ4mainE1K",
// CHECK-NEXT: ""
// CHECK-NEXT: };

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// CHECK: static constexpr
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "_ZTSZ4mainE8kernel_A"
// CHECK-NEXT: "_ZTSZ4mainE8kernel_A",
// CHECK-NEXT: ""
// CHECK-NEXT: };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// CHECK: static constexpr
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "_ZTSZ4mainE8kernel_C"
// CHECK-NEXT: "_ZTSZ4mainE8kernel_C",
// CHECK-NEXT: ""
// CHECK-NEXT: };

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "_ZTSZ4mainE8kernel_B",
// CHECK-NEXT: "_ZTSZ4mainE8kernel_C",
// CHECK-NEXT: "_ZTSZ4mainE8kernel_D"
// CHECK-NEXT: "_ZTSZ4mainE8kernel_D",
// CHECK-NEXT: ""
// CHECK-NEXT: };

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/union-kernel-param-ih.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// CHECK: static constexpr
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "_ZTSZ4mainE8kernel_A"
// CHECK-NEXT: "_ZTSZ4mainE8kernel_A",
// CHECK-NEXT: ""
// CHECK-NEXT: };

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/wrapped-accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// CHECK: static constexpr
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "_ZTSZ4mainE14wrapped_access"
// CHECK-NEXT: "_ZTSZ4mainE14wrapped_access",
// CHECK-NEXT: ""
// CHECK-NEXT: };

Expand Down

0 comments on commit 45b2ce3

Please sign in to comment.