[clang] [clang] All {con, de}structor attributes to use template args (PR #67376)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 17:24:55 PDT 2023


================
@@ -5661,10 +5662,20 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
   setNonAliasAttributes(GD, Fn);
   SetLLVMFunctionAttributesForDefinition(D, Fn);
 
-  if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>())
-    AddGlobalCtor(Fn, CA->getPriority());
+  auto getPrio = [this](auto *Attr) -> int {
+    Expr *E = Attr->getPriority();
+    if (!E)
+      return Attr->DefaultPriority;
+    if (auto CE = E->getIntegerConstantExpr(getContext()))
+      return CE->getExtValue();
+    return Attr->DefaultPriority;
----------------
erichkeane wrote:

This condition seems to me should be an assertion, right?  

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


More information about the cfe-commits mailing list