Author: Balázs Kéri Date: 2025-08-29T13:51:55+02:00 New Revision: adb312c19578bb2c9605a4929c3afbbff17453ab
URL: https://github.com/llvm/llvm-project/commit/adb312c19578bb2c9605a4929c3afbbff17453ab DIFF: https://github.com/llvm/llvm-project/commit/adb312c19578bb2c9605a4929c3afbbff17453ab.diff LOG: Revert "[clang] Fix of a crash 'Cannot get layout of forward declarations' du…" This reverts commit b4fb9aa0f7edb009e1bb44240e75a9141a064b8c. Added: Modified: clang/lib/AST/ASTImporter.cpp Removed: 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; -} _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
