[clang] 1b19f90 - Revert "[AST] Pick last tentative definition as the acting definition"

Benson Chu via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 24 09:42:19 PDT 2021


Author: Benson Chu
Date: 2021-08-24T11:41:50-05:00
New Revision: 1b19f90a2390b60852c0ff5e1671c76dd82dac83

URL: https://github.com/llvm/llvm-project/commit/1b19f90a2390b60852c0ff5e1671c76dd82dac83
DIFF: https://github.com/llvm/llvm-project/commit/1b19f90a2390b60852c0ff5e1671c76dd82dac83.diff

LOG: Revert "[AST] Pick last tentative definition as the acting definition"

This reverts commit 9a5f3888505630cea88f8372d3068b2d63cfb381.

The written test breaks some builds on Mach-O.

Added: 
    

Modified: 
    clang/lib/AST/Decl.cpp

Removed: 
    clang/test/CodeGen/attr-tentative-definition.c


################################################################################
diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 835e28c0bc9fc..aa9fba519642a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2216,18 +2216,14 @@ VarDecl *VarDecl::getActingDefinition() {
     return nullptr;
 
   VarDecl *LastTentative = nullptr;
-
-  // Loop through the declaration chain, starting with the most recent.
-  for (VarDecl *Decl = getMostRecentDecl(); Decl;
-       Decl = Decl->getPreviousDecl()) {
-    Kind = Decl->isThisDeclarationADefinition();
+  VarDecl *First = getFirstDecl();
+  for (auto I : First->redecls()) {
+    Kind = I->isThisDeclarationADefinition();
     if (Kind == Definition)
       return nullptr;
-    // Record the first (most recent) TentativeDefinition that is encountered.
-    if (Kind == TentativeDefinition && !LastTentative)
-      LastTentative = Decl;
+    if (Kind == TentativeDefinition)
+      LastTentative = I;
   }
-
   return LastTentative;
 }
 

diff  --git a/clang/test/CodeGen/attr-tentative-definition.c b/clang/test/CodeGen/attr-tentative-definition.c
deleted file mode 100644
index 7405e8079b220..0000000000000
--- a/clang/test/CodeGen/attr-tentative-definition.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// 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


        


More information about the cfe-commits mailing list