[clang] [HLSL][NFC] Use method builder to create default resource constructor (PR #131384)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 24 16:50:54 PDT 2025


================
@@ -453,11 +481,11 @@ BuiltinTypeMethodBuilder &BuiltinTypeMethodBuilder::dereference(T Ptr) {
   return *this;
 }
 
-BuiltinTypeDeclBuilder &BuiltinTypeMethodBuilder::finalizeMethod() {
+BuiltinTypeDeclBuilder &BuiltinTypeMethodBuilder::finalize() {
   assert(!DeclBuilder.Record->isCompleteDefinition() &&
          "record is already complete");
-  assert(Method != nullptr &&
-         "method decl not created; are you missing a call to build the body?");
+
+  ensureCompleteDecl();
----------------
hekota wrote:

Previously this assert would fail if the method or constructor had no body statements, and therefore no Method decl was created. Updating it to call `ensureCompleteDecl` created the decl and allows the body to be empty, which is what the current default constructor on resource classes has.

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


More information about the cfe-commits mailing list