@@ -3322,21 +3322,6 @@ static const char *paramKind2Str(KernelParamKind K) {
33223322#undef CASE
33233323}
33243324
3325- // Removes all "(anonymous namespace)::" substrings from given string, and emits
3326- // it.
3327- static void emitWithoutAnonNamespaces (llvm::raw_ostream &OS, StringRef Source) {
3328- const char S1[] = " (anonymous namespace)::" ;
3329-
3330- size_t Pos;
3331-
3332- while ((Pos = Source.find (S1)) != StringRef::npos) {
3333- OS << Source.take_front (Pos);
3334- Source = Source.drop_front (Pos + sizeof (S1) - 1 );
3335- }
3336-
3337- OS << Source;
3338- }
3339-
33403325// Emits a forward declaration
33413326void SYCLIntegrationHeader::emitFwdDecl (raw_ostream &O, const Decl *D,
33423327 SourceLocation KernelLocation) {
@@ -3555,13 +3540,6 @@ void SYCLIntegrationHeader::emitForwardClassDecls(
35553540 }
35563541}
35573542
3558- static void emitCPPTypeString (raw_ostream &OS, QualType Ty) {
3559- LangOptions LO;
3560- PrintingPolicy P (LO);
3561- P.SuppressTypedefs = true ;
3562- emitWithoutAnonNamespaces (OS, Ty.getAsString (P));
3563- }
3564-
35653543class SYCLKernelNameTypePrinter
35663544 : public TypeVisitor<SYCLKernelNameTypePrinter>,
35673545 public ConstTemplateArgumentVisitor<SYCLKernelNameTypePrinter> {
@@ -3684,6 +3662,11 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
36843662
36853663 O << " \n " ;
36863664
3665+ LangOptions LO;
3666+ PrintingPolicy Policy (LO);
3667+ Policy.SuppressTypedefs = true ;
3668+ Policy.SuppressUnwrittenScope = true ;
3669+
36873670 if (SpecConsts.size () > 0 ) {
36883671 // Remove duplicates.
36893672 std::sort (SpecConsts.begin (), SpecConsts.end (),
@@ -3701,7 +3684,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
37013684 O << " // Specialization constants IDs:\n " ;
37023685 for (const auto &P : llvm::make_range (SpecConsts.begin (), End)) {
37033686 O << " template <> struct sycl::detail::SpecConstantInfo<" ;
3704- emitCPPTypeString (O, P.first );
3687+ O << P.first . getAsString (Policy );
37053688 O << " > {\n " ;
37063689 O << " static constexpr const char* getName() {\n " ;
37073690 O << " return \" " << P.second << " \" ;\n " ;
@@ -3769,12 +3752,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
37693752 O << " ', '" << c;
37703753 O << " '> {\n " ;
37713754 } else {
3772- LangOptions LO;
3773- PrintingPolicy P (LO);
3774- P.SuppressTypedefs = true ;
3775- P.SuppressUnwrittenScope = true ;
37763755 O << " template <> struct KernelInfo<" ;
3777- SYCLKernelNameTypePrinter Printer (O, P );
3756+ SYCLKernelNameTypePrinter Printer (O, Policy );
37783757 Printer.Visit (K.NameType );
37793758 O << " > {\n " ;
37803759 }
0 commit comments