@@ -11817,86 +11817,3 @@ StringRef ASTContext::getCUIDHash() const {
1181711817 CUIDHash = llvm::utohexstr (llvm::MD5Hash (LangOpts.CUID ), /* LowerCase=*/ true );
1181811818 return CUIDHash;
1181911819}
11820-
11821- // Get the closest named parent, so we can order the sycl naming decls somewhere
11822- // that mangling is meaningful.
11823- static const DeclContext *GetNamedParent (const CXXRecordDecl *RD) {
11824- const DeclContext *DC = RD->getDeclContext ();
11825-
11826- while (!isa<NamedDecl, TranslationUnitDecl>(DC))
11827- DC = DC->getParent ();
11828- return DC;
11829- }
11830-
11831- void ASTContext::AddSYCLKernelNamingDecl (const CXXRecordDecl *RD) {
11832- assert (getLangOpts ().isSYCL () && " Only valid for SYCL programs" );
11833- RD = RD->getCanonicalDecl ();
11834- const DeclContext *DC = GetNamedParent (RD);
11835-
11836- assert (RD->getLocation ().isValid () &&
11837- " Invalid location on kernel naming decl" );
11838-
11839- (void )SYCLKernelNamingTypes[DC].insert (RD);
11840- }
11841-
11842- bool ASTContext::IsSYCLKernelNamingDecl (const NamedDecl *ND) const {
11843- assert (getLangOpts ().isSYCL () && " Only valid for SYCL programs" );
11844- const auto *RD = dyn_cast<CXXRecordDecl>(ND);
11845- if (!RD)
11846- return false ;
11847- RD = RD->getCanonicalDecl ();
11848- const DeclContext *DC = GetNamedParent (RD);
11849-
11850- auto Itr = SYCLKernelNamingTypes.find (DC);
11851-
11852- if (Itr == SYCLKernelNamingTypes.end ())
11853- return false ;
11854-
11855- return Itr->getSecond ().count (RD);
11856- }
11857-
11858- // Filters the Decls list to those that share the lambda mangling with the
11859- // passed RD.
11860- void ASTContext::FilterSYCLKernelNamingDecls (
11861- const CXXRecordDecl *RD,
11862- llvm::SmallVectorImpl<const CXXRecordDecl *> &Decls) {
11863-
11864- if (!SYCLKernelFilterContext)
11865- SYCLKernelFilterContext.reset (
11866- ItaniumMangleContext::create (*this , getDiagnostics ()));
11867-
11868- llvm::SmallString<128 > LambdaSig;
11869- llvm::raw_svector_ostream Out (LambdaSig);
11870- SYCLKernelFilterContext->mangleLambdaSig (RD, Out);
11871-
11872- llvm::erase_if (Decls, [this , &LambdaSig](const CXXRecordDecl *LocalRD) {
11873- llvm::SmallString<128 > LocalLambdaSig;
11874- llvm::raw_svector_ostream LocalOut (LocalLambdaSig);
11875- SYCLKernelFilterContext->mangleLambdaSig (LocalRD, LocalOut);
11876- return LambdaSig != LocalLambdaSig;
11877- });
11878- }
11879-
11880- unsigned ASTContext::GetSYCLKernelNamingIndex (const NamedDecl *ND) {
11881- assert (getLangOpts ().isSYCL () && " Only valid for SYCL programs" );
11882- assert (IsSYCLKernelNamingDecl (ND) &&
11883- " Lambda not involved in mangling asked for a naming index?" );
11884-
11885- const CXXRecordDecl *RD = cast<CXXRecordDecl>(ND)->getCanonicalDecl ();
11886- const DeclContext *DC = GetNamedParent (RD);
11887-
11888- auto Itr = SYCLKernelNamingTypes.find (DC);
11889- assert (Itr != SYCLKernelNamingTypes.end () && " Not a valid DeclContext?" );
11890-
11891- const llvm::SmallPtrSet<const CXXRecordDecl *, 4 > &Set = Itr->getSecond ();
11892-
11893- llvm::SmallVector<const CXXRecordDecl *> Decls{Set.begin (), Set.end ()};
11894-
11895- FilterSYCLKernelNamingDecls (RD, Decls);
11896-
11897- llvm::sort (Decls, [](const CXXRecordDecl *LHS, const CXXRecordDecl *RHS) {
11898- return LHS->getLambdaManglingNumber () < RHS->getLambdaManglingNumber ();
11899- });
11900-
11901- return llvm::find (Decls, RD) - Decls.begin ();
11902- }
0 commit comments