@@ -1212,12 +1212,13 @@ struct PerVisibilityBindingChecker {
12121212 }
12131213};
12141214
1215- static CXXMethodDecl *lookupMethod (CXXRecordDecl *Record, StringRef Name,
1216- StorageClass SC = SC_None) {
1217- for (auto *Method : Record->methods ())
1218- if (Method->getStorageClass () == SC && Method->getName () == Name)
1219- return Method;
1220- return nullptr ;
1215+ static CXXMethodDecl *lookupMethod (Sema &S, CXXRecordDecl *RecordDecl,
1216+ StringRef Name, SourceLocation Loc) {
1217+ DeclarationName DeclName (&S.getASTContext ().Idents .get (Name));
1218+ LookupResult Result (S, DeclName, Loc, Sema::LookupMemberName);
1219+ if (!S.LookupQualifiedName (Result, static_cast <DeclContext *>(RecordDecl)))
1220+ return nullptr ;
1221+ return cast<CXXMethodDecl>(Result.getFoundDecl ());
12211222}
12221223
12231224} // end anonymous namespace
@@ -3825,15 +3826,17 @@ bool SemaHLSL::initGlobalResourceDecl(VarDecl *VD) {
38253826
38263827 if (RegisterSlot.has_value ()) {
38273828 // The resource has explicit binding.
3828- CreateMethod = lookupMethod (ResourceDecl, " __createFromBinding" , SC_Static);
3829+ CreateMethod = lookupMethod (SemaRef, ResourceDecl, " __createFromBinding" ,
3830+ VD->getLocation ());
38293831 IntegerLiteral *RegSlot = IntegerLiteral::Create (
38303832 AST, llvm::APInt (UIntTySize, RegisterSlot.value ()), AST.UnsignedIntTy ,
38313833 SourceLocation ());
38323834 Args.push_back (RegSlot);
38333835 } else {
38343836 // The resource has implicit binding.
38353837 CreateMethod =
3836- lookupMethod (ResourceDecl, " __createFromImplicitBinding" , SC_Static);
3838+ lookupMethod (SemaRef, ResourceDecl, " __createFromImplicitBinding" ,
3839+ VD->getLocation ());
38373840 uint32_t OrderID = (RBA && RBA->hasImplicitBindingOrderID ())
38383841 ? RBA->getImplicitBindingOrderID ()
38393842 : getNextImplicitBindingOrderID ();
0 commit comments