summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTStructuralEquivalence.cpp
diff options
context:
space:
mode:
authorGabor Marton <martongabesz@gmail.com>2018-08-09 12:36:25 +0000
committerGabor Marton <martongabesz@gmail.com>2018-08-09 12:36:25 +0000
commit6b01e1c190fe45568d69d3ca5230f4c186cb46a2 (patch)
treec1bdf6463cd4ea64a6d60e5593f0276b54967fa6 /clang/lib/AST/ASTStructuralEquivalence.cpp
parent01ae462fef748212bfe42c2555bc3eb1f4309d0f (diff)
downloadbcm5719-llvm-6b01e1c190fe45568d69d3ca5230f4c186cb46a2.tar.gz
bcm5719-llvm-6b01e1c190fe45568d69d3ca5230f4c186cb46a2.zip
Fix structural inequivalency of forward EnumDecl
Summary: Currently we consider one forward declared RecordDecl and another with a definition equal. We have to do the same in case of enums. Reviewers: a_sidorin, r.stahl, xazax.hun Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D50444 llvm-svn: 339336
Diffstat (limited to 'clang/lib/AST/ASTStructuralEquivalence.cpp')
-rw-r--r--clang/lib/AST/ASTStructuralEquivalence.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp
index 7fc3239b03d..1a3fb4063b9 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1178,6 +1178,14 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
/// Determine structural equivalence of two enums.
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
EnumDecl *D1, EnumDecl *D2) {
+
+ // Compare the definitions of these two enums. If either or both are
+ // incomplete (i.e. forward declared), we assume that they are equivalent.
+ D1 = D1->getDefinition();
+ D2 = D2->getDefinition();
+ if (!D1 || !D2)
+ return true;
+
EnumDecl::enumerator_iterator EC2 = D2->enumerator_begin(),
EC2End = D2->enumerator_end();
for (EnumDecl::enumerator_iterator EC1 = D1->enumerator_begin(),
OpenPOWER on IntegriCloud