Skip to content

Commit ce719b2

Browse files
committed
code review feedback - add arg comments, use Sema for name lookup
1 parent cdc85ca commit ce719b2

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,11 @@ BuiltinTypeMethodBuilder &BuiltinTypeMethodBuilder::returnValue(T ReturnValue) {
600600
CXXConstructorDecl *CD = lookupCopyConstructor(Ty);
601601
assert(CD && "no copy constructor found");
602602
ReturnValueExpr = CXXConstructExpr::Create(
603-
AST, Ty, SourceLocation(), CD, false, {ICE}, false, false, false, false,
604-
CXXConstructionKind::Complete, SourceRange());
603+
AST, Ty, SourceLocation(), CD, /*Elidable=*/false, {ICE},
604+
/*HadMultipleCandidates=*/false, /*ListInitialization=*/false,
605+
/*StdInitListInitialization=*/false,
606+
/*ZeroInitListInitialization=*/false, CXXConstructionKind::Complete,
607+
SourceRange());
605608
}
606609
StmtsList.push_back(
607610
ReturnStmt::Create(AST, SourceLocation(), ReturnValueExpr, nullptr));

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)