From aad244dfc566236e9d3ef48c7aea3616bb6aab14 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 21 Oct 2021 07:08:18 -0400 Subject: Revert "AddGlobalAnnotations for function with or without function body." This reverts commit 121b2252de0eed68f2ddf5f09e924a6c35423d47. The following code causes a crash in some circumstances: struct k { ~k() __attribute__((annotate(""))) {} }; void m() { k(); } --- clang/lib/CodeGen/CodeGenModule.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e53a8a36974a..74c4490d5422 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2200,9 +2200,6 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, CalleeIdx, PayloadIndices, /* VarArgsArePassed */ false)})); } - - if (FD->hasAttr()) - AddGlobalAnnotations(FD, F); } void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) { @@ -4900,6 +4897,8 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, AddGlobalCtor(Fn, CA->getPriority()); if (const DestructorAttr *DA = D->getAttr()) AddGlobalDtor(Fn, DA->getPriority(), true); + if (D->hasAttr()) + AddGlobalAnnotations(D, Fn); } void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) { -- cgit v1.2.3