diff --git a/clang/lib/DPCT/AnalysisInfo.h b/clang/lib/DPCT/AnalysisInfo.h index 25158d655e55..59867e9b47ca 100644 --- a/clang/lib/DPCT/AnalysisInfo.h +++ b/clang/lib/DPCT/AnalysisInfo.h @@ -1484,7 +1484,7 @@ class DpctGlobalInfo { return FD->getLocation(); } static SourceLocation getLocation(const CallExpr *CE) { - return CE->getEndLoc(); + return getDefinitionRange(CE->getBeginLoc(), CE->getEndLoc()).getEnd(); } // The result will be also stored in KernelCallExpr.BeginLoc static SourceLocation getLocation(const CUDAKernelCallExpr *CKC) { diff --git a/clang/test/dpct/macro_test.cu b/clang/test/dpct/macro_test.cu index 686ef2c27029..eea738d6a670 100644 --- a/clang/test/dpct/macro_test.cu +++ b/clang/test/dpct/macro_test.cu @@ -1385,25 +1385,13 @@ int foo39() { return 0; } -#define STRINGIFY_(...) #__VA_ARGS__ -#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__) - -//CHECK: void foo40_dev_func(const char *file_name, const char *other, -//CHECK-NEXT: const sycl::stream &stream_ct1) { -//CHECK-NEXT: stream_ct1 << "sss\n"; +//CHECK: void foo40_kernel(const sycl::stream &stream_ct1) { +//CHECK-NEXT: FOO40_MACRO; //CHECK-NEXT: } -//CHECK-NEXT: #define FOO40_MACRO \ -//CHECK-NEXT: foo40_dev_func(__FILE__, STRINGIFY(__OTHER_MACRO__), stream_ct1) -__device__ void foo40_dev_func(const char *file_name, const char *other) { - printf("sss\n"); -} -#define FOO40_MACRO foo40_dev_func(__FILE__, STRINGIFY(__OTHER_MACRO__)) - __global__ void foo40_kernel() { FOO40_MACRO; } void foo40() { foo40_kernel<<<1, 1>>>(); } - -#endif \ No newline at end of file +#endif diff --git a/clang/test/dpct/macro_test.h b/clang/test/dpct/macro_test.h index 4dd5c0714231..320a10f95b87 100644 --- a/clang/test/dpct/macro_test.h +++ b/clang/test/dpct/macro_test.h @@ -1,2 +1,16 @@ //CHECK: #define THREAD_IDX_X item_ct1.get_local_id(2) #define THREAD_IDX_X threadIdx.x + +#define STRINGIFY_(...) #__VA_ARGS__ +#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__) + +//CHECK: void foo40_dev_func(const char *file_name, const char *other, +//CHECK-NEXT: const sycl::stream &stream_ct1) { +//CHECK-NEXT: stream_ct1 << "sss\n"; +//CHECK-NEXT: } +//CHECK-NEXT: #define FOO40_MACRO \ +//CHECK-NEXT: foo40_dev_func(__FILE__, STRINGIFY(__OTHER_MACRO__), stream_ct1) +__device__ void foo40_dev_func(const char *file_name, const char *other) { + printf("sss\n"); +} +#define FOO40_MACRO foo40_dev_func(__FILE__, STRINGIFY(__OTHER_MACRO__))