================ @@ -2152,29 +2152,49 @@ static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL)); } +static std::optional<Expr *> +sharedGetConstructorDestructorAttrExpr(Sema &S, const ParsedAttr &AL) { + // If no Expr node exists on the attribute, return a nullptr (default priority to be used). + // If Expr node exists but is not valid, return a nullopt. + // 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 std::nullopt; + } + } else { + uint32_t priority; + if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) { ---------------- tynasello wrote:
@erichkeane is this something like `return ConstantExpr::Create(S.Context, E, APValue(llvm::APSInt(llvm::APInt(32, priority))));`? https://github.com/llvm/llvm-project/pull/151400 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits