This patch addresses a problem encountered by the
authorSean Callanan <scallanan@apple.com>
Wed, 9 Oct 2013 21:45:11 +0000 (21:45 +0000)
committerSean Callanan <scallanan@apple.com>
Wed, 9 Oct 2013 21:45:11 +0000 (21:45 +0000)
commitc665c9ecf446092cab5af76f48a72f5dc6480e5c
tree0fe41f87aa4aa79a9aae1e8ed09bd8a0bc7a82dc
parentb0e33d416516508341c36551f8f21b75fa7c9908
This patch addresses a problem encountered by the
ASTImporter when importing the following types:

typedef struct {
} A;

typedef struct {
  A a;
} B;

Suppose we have imported B, but we did not at that
time need to complete it.  Then later we want to
import A.  The struct is anonymous, so the first
thing we want to do is make sure no other anonymous
struct already matches it.  So we set up an
StructuralEquivalenceContext and compare B with A.

This happens at ASTImporter.cpp:2179.

Now, in this scenario, B is not complete.  So we go
and import its fields, including a, which causes A
to be imported.  The ASTImporter doesn’t yet have A
in its list of already-imported things, so we
import A.

After the StructuralEquivalenceContext is finished
determining that A and B are different, the
ASTImporter concludes that A must be imported
because no equivalent exists, so it imports a second
copy of A.  Now we have two different structs
representing A.  This is really bad news.

The patch allows the StructuralEquivalenceContext to
use the original version of B when making its
comparison, obviating the need for an import and
cutting this loop.

llvm-svn: 192324
clang/include/clang/AST/ASTImporter.h
clang/lib/AST/ASTImporter.cpp