@@ -706,8 +706,7 @@ static QualType calculateKernelNameType(ASTContext &Ctx,
706
706
const TemplateArgumentList *TAL =
707
707
KernelCallerFunc->getTemplateSpecializationArgs ();
708
708
assert (TAL && " No template argument info" );
709
- return TypeName::getFullyQualifiedType (TAL->get (0 ).getAsType (), Ctx,
710
- /* WithGlobalNSPrefix=*/ true );
709
+ return TAL->get (0 ).getAsType ().getCanonicalType ();
711
710
}
712
711
713
712
// Gets a name for the OpenCL kernel function, calculated from the first
@@ -1761,10 +1760,7 @@ class SyclKernelIntHeaderCreator
1761
1760
" Incorrect template args for Accessor Type" );
1762
1761
// Get specialization constant ID type, which is the second template
1763
1762
// argument.
1764
- QualType SpecConstIDTy =
1765
- TypeName::getFullyQualifiedType (TemplateArgs.get (1 ).getAsType (),
1766
- SemaRef.getASTContext (), true )
1767
- .getCanonicalType ();
1763
+ QualType SpecConstIDTy = TemplateArgs.get (1 ).getAsType ().getCanonicalType ();
1768
1764
const std::string SpecConstName = PredefinedExpr::ComputeName (
1769
1765
SemaRef.getASTContext (), PredefinedExpr::UniqueStableNameType,
1770
1766
SpecConstIDTy);
@@ -2446,40 +2442,42 @@ static void printTemplateArguments(ASTContext &Ctx, raw_ostream &ArgOS,
2446
2442
ArgOS << " >" ;
2447
2443
}
2448
2444
2449
- static std::string getKernelNameTypeString (QualType T, ASTContext &Ctx,
2450
- const PrintingPolicy &TypePolicy) {
2451
-
2452
- QualType FullyQualifiedType = TypeName::getFullyQualifiedType (T, Ctx, true );
2453
-
2454
- const CXXRecordDecl *RD = T->getAsCXXRecordDecl ();
2455
-
2456
- if (!RD)
2457
- return eraseAnonNamespace (FullyQualifiedType.getAsString (TypePolicy));
2458
-
2459
- // If kernel name type is a template specialization with enum type
2460
- // template parameters, enumerators in name type string should be
2461
- // replaced with their underlying value since the enum definition
2462
- // is not visible in integration header.
2463
- if (const auto *TSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
2464
- SmallString<64 > Buf;
2465
- llvm::raw_svector_ostream ArgOS (Buf);
2466
-
2467
- // Print the qualifiers for the type.
2468
- FullyQualifiedType.getQualifiers ().print (ArgOS, TypePolicy,
2445
+ static std::string printRecordType (QualType T, const CXXRecordDecl *RD,
2446
+ const PrintingPolicy &TypePolicy) {
2447
+ SmallString<64 > Buf;
2448
+ llvm::raw_svector_ostream OS (Buf);
2449
+ T.getCanonicalType ().getQualifiers ().print (OS, TypePolicy,
2469
2450
/* appendSpaceIfNotEmpty*/ true );
2451
+ if (const auto *TSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
2470
2452
2471
2453
// Print template class name
2472
- TSD->printQualifiedName (ArgOS , TypePolicy, /* WithGlobalNsPrefix*/ true );
2454
+ TSD->printQualifiedName (OS , TypePolicy, /* WithGlobalNsPrefix*/ true );
2473
2455
2474
2456
// Print template arguments substituting enumerators
2475
2457
ASTContext &Ctx = RD->getASTContext ();
2476
2458
const TemplateArgumentList &Args = TSD->getTemplateArgs ();
2477
- printTemplateArguments (Ctx, ArgOS , Args.asArray (), TypePolicy);
2459
+ printTemplateArguments (Ctx, OS , Args.asArray (), TypePolicy);
2478
2460
2479
- return eraseAnonNamespace (ArgOS .str ().str ());
2461
+ return eraseAnonNamespace (OS .str ().str ());
2480
2462
}
2463
+ if (RD->getDeclContext ()->isFunctionOrMethod ())
2464
+ return eraseAnonNamespace (T.getCanonicalType ().getAsString (TypePolicy));
2465
+ const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(RD->getDeclContext ());
2466
+ RD->printQualifiedName (OS, TypePolicy, !(NS && NS->isAnonymousNamespace ()));
2467
+ return eraseAnonNamespace (OS.str ().str ());
2468
+ }
2481
2469
2482
- return eraseAnonNamespace (FullyQualifiedType.getAsString (TypePolicy));
2470
+ static std::string getKernelNameTypeString (QualType T, ASTContext &Ctx,
2471
+ const PrintingPolicy &TypePolicy) {
2472
+ if (T->isRecordType ())
2473
+ return printRecordType (T, T->getAsCXXRecordDecl (), TypePolicy);
2474
+ if (T->isEnumeralType ()) {
2475
+ SmallString<64 > Buf;
2476
+ llvm::raw_svector_ostream OS (Buf);
2477
+ OS << " ::" << T.getCanonicalType ().getAsString (TypePolicy);
2478
+ return eraseAnonNamespace (OS.str ().str ());
2479
+ }
2480
+ return eraseAnonNamespace (T.getCanonicalType ().getAsString (TypePolicy));
2483
2481
}
2484
2482
2485
2483
void SYCLIntegrationHeader::emit (raw_ostream &O) {
0 commit comments