Skip to content

Conversation

balazske
Copy link
Collaborator

Reverts #155375
Test does not work correctly on MacOS.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:static analyzer labels Aug 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 29, 2025

@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Balázs Kéri (balazske)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/156010.diff

2 Files Affected:

  • (modified) clang/lib/AST/ASTImporter.cpp (+1-12)
  • (removed) clang/test/Analysis/ctu-import-type-decl-definition.c (-43)
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;
-}

@balazske balazske merged commit ea4ec00 into main Aug 29, 2025
11 of 13 checks passed
@balazske balazske deleted the revert-155375-astimporter_tagtypedecldef branch August 29, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants