[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 13:15:40 PST 2024
================
@@ -570,3 +780,20 @@ void HLSLExternalSemaSource::CompleteType(TagDecl *Tag) {
return;
It->second(Record);
}
+
+static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) {
+ IdentifierInfo &II =
+ S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
+ DeclarationNameInfo NameInfo =
+ DeclarationNameInfo(DeclarationName(&II), SourceLocation());
+ LookupResult R(S, NameInfo, Sema::LookupOrdinaryName);
+ // AllowBuiltinCreation is false but LookupDirect will create
+ // the builtin when searching the global scope anyways...
+ S.LookupName(R, S.getCurScope());
+ // FIXME: If the builtin function was user-declared in global scope,
+ // this assert *will* fail. Should this call LookupBuiltin instead?
+ assert(R.isSingleResult() &&
+ "Since this is a builtin it should always resolve!");
+ assert(isa<FunctionDecl>(R.getFoundDecl()));
+ return cast<FunctionDecl>(R.getFoundDecl());
----------------
bogner wrote:
The assert here is redundant - `cast` does this assert internally
https://github.com/llvm/llvm-project/pull/114148
More information about the llvm-commits
mailing list