https://github.com/balazske created 
https://github.com/llvm/llvm-project/pull/156010

Reverts llvm/llvm-project#155375
Test does not work correctly on MacOS.

From adb312c19578bb2c9605a4929c3afbbff17453ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= <[email protected]>
Date: Fri, 29 Aug 2025 13:51:55 +0200
Subject: [PATCH] =?UTF-8?q?Revert=20"[clang]=20Fix=20of=20a=20crash=20'Can?=
 =?UTF-8?q?not=20get=20layout=20of=20forward=20declarations'=20du=E2=80=A6?=
 =?UTF-8?q?"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit b4fb9aa0f7edb009e1bb44240e75a9141a064b8c.
---
 clang/lib/AST/ASTImporter.cpp                 | 13 +-----
 .../ctu-import-type-decl-definition.c         | 43 -------------------
 2 files changed, 1 insertion(+), 55 deletions(-)
 delete mode 100644 clang/test/Analysis/ctu-import-type-decl-definition.c

diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index d2ea60896094f..6299efaf6bbfc 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1740,21 +1740,10 @@ ExpectedType 
ASTNodeImporter::VisitDeducedTemplateSpecializationType(
 }
 
 ExpectedType ASTNodeImporter::VisitTagType(const TagType *T) {
-  TagDecl *DeclForType = T->getOriginalDecl();
-  Expected<TagDecl *> ToDeclOrErr = import(DeclForType);
+  Expected<TagDecl *> ToDeclOrErr = import(T->getOriginalDecl());
   if (!ToDeclOrErr)
     return ToDeclOrErr.takeError();
 
-  if (DeclForType->isUsed()) {
-    // If there is a definition of the 'OriginalDecl', it should be imported to
-    // have all information for the type in the "To" AST. (In some cases no
-    // other reference may exist to the definition decl and it would not be
-    // imported otherwise.)
-    Expected<TagDecl *> ToDefDeclOrErr = import(DeclForType->getDefinition());
-    if (!ToDefDeclOrErr)
-      return ToDefDeclOrErr.takeError();
-  }
-
   if (T->isCanonicalUnqualified())
     return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);
 
diff --git a/clang/test/Analysis/ctu-import-type-decl-definition.c 
b/clang/test/Analysis/ctu-import-type-decl-definition.c
deleted file mode 100644
index 9855c9d8f5729..0000000000000
--- a/clang/test/Analysis/ctu-import-type-decl-definition.c
+++ /dev/null
@@ -1,43 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir -p %t
-// RUN: split-file %s %t
-
-// RUN: %clang_cc1 -emit-pch -o %t/import.c.ast %t/import.c
-
-// RUN: %clang_extdef_map -- -x c %t/import.c >> %t/externalDefMap.txt
-// RUN: sed -i 's/$/.ast/' %t/externalDefMap.txt
-
-// RUN: %clang_cc1 -analyze \
-// RUN:   -analyzer-checker=core \
-// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
-// RUN:   -analyzer-config display-ctu-progress=true \
-// RUN:   -analyzer-config ctu-dir=%t \
-// RUN:   -verify %t/main.c
-
-//--- main.c
-
-// expected-no-diagnostics
-
-typedef struct X_s X_t;
-unsigned long f_import(struct X_s *xPtr);
-
-static void freeWriteFileResources(struct X_s *xPtr) {
-  f_import(xPtr);
-}
-
-//--- import.c
-
-typedef struct Y_s Y_t;
-
-struct Y_s {
-};
-
-struct X_s {
-  Y_t y;
-};
-
-unsigned long f_import(struct X_s *xPtr) {
-  if (xPtr != 0) {
-  }
-  return 0;
-}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to