@@ -659,6 +659,15 @@ static void populateIntHeader(SYCLIntegrationHeader &H, const StringRef Name,
659
659
visitKernelLambdaCaptures (Lambda, Vis);
660
660
}
661
661
662
+ // Removes all "(anonymous namespace)::" substrings from given string
663
+ static std::string eraseAnonNamespace (std::string S) {
664
+ const char S1[] = " (anonymous namespace)::" ;
665
+
666
+ for (auto Pos = S.find (S1); Pos != StringRef::npos; Pos = S.find (S1, Pos))
667
+ S.erase (Pos, sizeof (S1)-1 );
668
+ return S;
669
+ }
670
+
662
671
// Creates a kernel name for given kernel name type which is unique across all
663
672
// instantiations of the type if it is templated. If it is not templated,
664
673
// uniqueueness is prescribed by the SYCL spec. 'class' and 'struct' keywords
@@ -670,10 +679,10 @@ static std::string constructKernelName(QualType KernelNameType) {
670
679
std::string TStr = KernelNameType.getAsString ();
671
680
672
681
for (const std::string &Kwd : Kwds) {
673
- for (size_t Pos = TStr.find (Kwd); Pos != StringRef::npos;
682
+ for (auto Pos = TStr.find (Kwd); Pos != StringRef::npos;
674
683
Pos = TStr.find (Kwd, Pos)) {
675
684
676
- size_t EndPos = Pos + Kwd.length ();
685
+ auto EndPos = Pos + Kwd.length ();
677
686
if ((Pos == 0 || !llvm::isAlnum (TStr[Pos - 1 ])) &&
678
687
(EndPos == TStr.length () || !llvm::isAlnum (TStr[EndPos]))) {
679
688
// keyword is a separate word - erase
@@ -682,7 +691,7 @@ static std::string constructKernelName(QualType KernelNameType) {
682
691
Pos = EndPos;
683
692
}
684
693
}
685
- return StringRef (TStr). trim (). str ();
694
+ return StringRef (eraseAnonNamespace ( TStr)). trim ();
686
695
}
687
696
688
697
void Sema::ConstructSYCLKernel (FunctionDecl *KernelCallerFunc) {
@@ -961,8 +970,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
961
970
962
971
for (const KernelDesc &K : KernelDescs) {
963
972
const size_t N = K.Params .size ();
964
- O << " template <> struct KernelInfo<" << K. NameType . getAsString ()
965
- << " > {\n " ;
973
+ O << " template <> struct KernelInfo<"
974
+ << eraseAnonNamespace (K. NameType . getAsString ()) << " > {\n " ;
966
975
O << " static constexpr const char* getName() { return \" " << K.Name
967
976
<< " \" ; }\n " ;
968
977
O << " static constexpr unsigned getNumParams() { return " << N << " ; }\n " ;
0 commit comments