[PATCH] D99732: [AST] Pick last tentative definition as the acting definition
Benson Chu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 24 06:52:18 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a5f38885056: [AST] Pick last tentative definition as the acting definition (authored by pestctrl).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99732/new/
https://reviews.llvm.org/D99732
Files:
clang/lib/AST/Decl.cpp
clang/test/CodeGen/attr-tentative-definition.c
Index: clang/test/CodeGen/attr-tentative-definition.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/attr-tentative-definition.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+char arr[10];
+char arr[10] __attribute__((section("datadata")));
+char arr[10] __attribute__((aligned(16)));
+
+// CHECK: @arr ={{.*}}section "datadata", align 16
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -2216,14 +2216,18 @@
return nullptr;
VarDecl *LastTentative = nullptr;
- VarDecl *First = getFirstDecl();
- for (auto I : First->redecls()) {
- Kind = I->isThisDeclarationADefinition();
+
+ // Loop through the declaration chain, starting with the most recent.
+ for (VarDecl *Decl = getMostRecentDecl(); Decl;
+ Decl = Decl->getPreviousDecl()) {
+ Kind = Decl->isThisDeclarationADefinition();
if (Kind == Definition)
return nullptr;
- if (Kind == TentativeDefinition)
- LastTentative = I;
+ // Record the first (most recent) TentativeDefinition that is encountered.
+ if (Kind == TentativeDefinition && !LastTentative)
+ LastTentative = Decl;
}
+
return LastTentative;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99732.368333.patch
Type: text/x-patch
Size: 1313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210824/8ea3ba79/attachment.bin>
More information about the cfe-commits
mailing list