[clang] [HLSL] Add static methods for resource initialization (PR #155866)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 8 10:56:52 PDT 2025


================
@@ -431,15 +464,31 @@ Expr *BuiltinTypeMethodBuilder::getResourceHandleExpr() {
                                     OK_Ordinary);
 }
 
+BuiltinTypeMethodBuilder &
+BuiltinTypeMethodBuilder::createLocalVar(StringRef Name, QualType Ty) {
+  ensureCompleteDecl();
+
+  ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
+  VarDecl *VD =
+      VarDecl::Create(AST, Method, SourceLocation(), SourceLocation(),
+                      &AST.Idents.get(Name, tok::TokenKind::identifier), Ty,
+                      AST.getTrivialTypeSourceInfo(Ty), SC_None);
+  LocalVars.push_back(VD);
+  DeclStmt *DS = new (AST)
+      clang::DeclStmt(DeclGroupRef(VD), SourceLocation(), SourceLocation());
+  StmtsList.push_back(DS);
+  return *this;
+}
+
 template <typename... Ts>
 BuiltinTypeMethodBuilder &
 BuiltinTypeMethodBuilder::callBuiltin(StringRef BuiltinName,
                                       QualType ReturnType, Ts... ArgSpecs) {
+  ensureCompleteDecl();
----------------
hekota wrote:

Yes, this move was intentional. We need a complete method declaration (=all parameters created) before `convertPlaceHolder` can refer to them.

https://github.com/llvm/llvm-project/pull/155866


More information about the cfe-commits mailing list