Skip to content

Commit 6fab2bb

Browse files
authored
[SYCLomatic] Fix the issue that explicit template instantiation type argument is not migrated in macro scenario (#2611)
Signed-off-by: intwanghao <hao3.wang@intel.com>
1 parent 8b31cc7 commit 6fab2bb

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

clang/lib/DPCT/RuleInfra/ExprAnalysis.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ class ExprAnalysis {
221221
}
222222

223223
inline void analyze(const TemplateArgumentLoc &TAL) {
224-
initSourceRange(TAL.getSourceRange());
224+
auto SR = TAL.getSourceRange();
225+
initSourceRange(getDefinitionRange(SR.getBegin(), SR.getEnd()));
225226
analyzeTemplateArgument(TAL);
226227
}
227228

clang/test/dpct/macro_test.cu

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,14 @@ void foo44(float *x, int size, int d3, int d2) {
15041504
FROMDEV2(x)
15051505
}
15061506

1507+
template<typename T>
1508+
void foo45(){}
1509+
1510+
#define EXPLICIT_DECL(T) template void foo45<T>()
1511+
1512+
// CHECK: extern EXPLICIT_DECL(sycl::half);
1513+
extern EXPLICIT_DECL(half);
1514+
15071515
#undef TODEV
15081516
#undef FROMDEV
15091517
#undef FREE

0 commit comments

Comments
 (0)