[clang] [Clang] Add template argument support for {con,de}structor attributes. (PR #151400)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 3 06:23:46 PDT 2025


================
@@ -2154,29 +2156,51 @@ static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL));
 }
 
+static ExprResult sharedGetConstructorDestructorAttrExpr(Sema &S,
+                                                         const ParsedAttr &AL) {
+  // If no Expr node exists on the attribute, return a nullptr result (default
+  // priority to be used). If Expr node exists but is not valid, return an
+  // invalid result. Otherwise, return the Expr.
+  Expr *E = nullptr;
+  if (AL.getNumArgs() == 1) {
+    E = AL.getArgAsExpr(0);
+    if (E->isValueDependent()) {
+      if (!E->isTypeDependent() && !E->getType()->isIntegerType()) {
+        S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+            << AL << AANT_ArgumentIntegerConstant << E->getSourceRange();
+        return ExprResult(/*Invalid=*/true);
+      }
+    } else {
+      uint32_t priority;
+      if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) {
+        return ExprResult(/*Invalid=*/true);
----------------
erichkeane wrote:

```suggestion
        return ExprError();
```

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


More information about the cfe-commits mailing list