@@ -3322,21 +3322,6 @@ static const char *paramKind2Str(KernelParamKind K) {
3322
3322
#undef CASE
3323
3323
}
3324
3324
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
-
3340
3325
// Emits a forward declaration
3341
3326
void SYCLIntegrationHeader::emitFwdDecl (raw_ostream &O, const Decl *D,
3342
3327
SourceLocation KernelLocation) {
@@ -3555,13 +3540,6 @@ void SYCLIntegrationHeader::emitForwardClassDecls(
3555
3540
}
3556
3541
}
3557
3542
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
-
3565
3543
class SYCLKernelNameTypePrinter
3566
3544
: public TypeVisitor<SYCLKernelNameTypePrinter>,
3567
3545
public ConstTemplateArgumentVisitor<SYCLKernelNameTypePrinter> {
@@ -3684,6 +3662,11 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
3684
3662
3685
3663
O << " \n " ;
3686
3664
3665
+ LangOptions LO;
3666
+ PrintingPolicy Policy (LO);
3667
+ Policy.SuppressTypedefs = true ;
3668
+ Policy.SuppressUnwrittenScope = true ;
3669
+
3687
3670
if (SpecConsts.size () > 0 ) {
3688
3671
// Remove duplicates.
3689
3672
std::sort (SpecConsts.begin (), SpecConsts.end (),
@@ -3701,7 +3684,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
3701
3684
O << " // Specialization constants IDs:\n " ;
3702
3685
for (const auto &P : llvm::make_range (SpecConsts.begin (), End)) {
3703
3686
O << " template <> struct sycl::detail::SpecConstantInfo<" ;
3704
- emitCPPTypeString (O, P.first );
3687
+ O << P.first . getAsString (Policy );
3705
3688
O << " > {\n " ;
3706
3689
O << " static constexpr const char* getName() {\n " ;
3707
3690
O << " return \" " << P.second << " \" ;\n " ;
@@ -3769,12 +3752,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
3769
3752
O << " ', '" << c;
3770
3753
O << " '> {\n " ;
3771
3754
} else {
3772
- LangOptions LO;
3773
- PrintingPolicy P (LO);
3774
- P.SuppressTypedefs = true ;
3775
- P.SuppressUnwrittenScope = true ;
3776
3755
O << " template <> struct KernelInfo<" ;
3777
- SYCLKernelNameTypePrinter Printer (O, P );
3756
+ SYCLKernelNameTypePrinter Printer (O, Policy );
3778
3757
Printer.Visit (K.NameType );
3779
3758
O << " > {\n " ;
3780
3759
}
0 commit comments