[all-commits] [llvm/llvm-project] 9d0b55: [clang][ASTImporter] Fix import of typedef with un...

Balázs Kéri via All-commits all-commits at lists.llvm.org
Thu Apr 13 00:25:56 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9d0b55f0e4ca55d04ee8abfdf021913ea3c30082
      https://github.com/llvm/llvm-project/commit/9d0b55f0e4ca55d04ee8abfdf021913ea3c30082
  Author: Balázs Kéri <1.int32 at gmail.com>
  Date:   2023-04-13 (Thu, 13 Apr 2023)

  Changed paths:
    M clang/lib/AST/ASTImporter.cpp
    M clang/unittests/AST/ASTImporterTest.cpp

  Log Message:
  -----------
  [clang][ASTImporter] Fix import of typedef with unnamed structures

Fix crash in ASTImporter related to import of unnamed structures and typedefs
to these maybe with pointer.
There was a series of problems exposed by https://reviews.llvm.org/D133468
(commit 69a6417406a1b0316a1fa6aeb63339d0e1d2abbd) in the ASTImporter breaking
cross-translation unit analysis. This change fixes one of the problems exposed
by that change for importing unnamed structures. The problem was
discovered when running clang static analysis on open source projects
using cross-translation unit analysis.

Simple test command. Produces crash without change, passes all tests
with change.

```
ninja ASTTests && ./tools/clang/unittests/AST/ASTTests
  --gtest_filter="*/*ImportAnonymousStruct/0"
```

Formatted crash stack:

```
ASTTests: <root>/clang/lib/AST/ASTContext.cpp:4787:
  clang::QualType clang::ASTContext::getTypedefType(const clang::TypedefNameDecl*,
  clang::QualType) const: Assertion `hasSameType(Decl->getUnderlyingType(), Underlying)' failed.
...
 #9 <addr> clang::ASTContext::getTypedefType(clang::TypedefNameDecl const*, clang::QualType) const
             <root>/clang/lib/AST/ASTContext.cpp:4789:26
             <root>/clang/lib/AST/ASTImporter.cpp:1374:71
             <root>/tools/clang/include/clang/AST/TypeNodes.inc:75:1
             <root>/clang/lib/AST/ASTImporter.cpp:8663:8
```

Reviewed By: donat.nagy

Differential Revision: https://reviews.llvm.org/D145868




More information about the All-commits mailing list