]> granicus.if.org Git - clang/commitdiff
In the ASTImporter, when checking whether two
authorSean Callanan <scallanan@apple.com>
Fri, 26 Apr 2013 22:49:25 +0000 (22:49 +0000)
committerSean Callanan <scallanan@apple.com>
Fri, 26 Apr 2013 22:49:25 +0000 (22:49 +0000)
structs are compatible, check whether the fields
of the structs have the same name.  This prevents
erroneous coalescing of (in particular) anonymous
structs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTImporter.cpp

index 8b5f21ddda006b72cedc234848e0f8db57291459..20b905c376b4b529d13b7c523a8bee0d6dc8dc05 100644 (file)
@@ -839,6 +839,12 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
     RecordDecl *D2 = Field2->getType()->castAs<RecordType>()->getDecl();
     return IsStructurallyEquivalent(Context, D1, D2);
   }
+    
+  // Check for equivalent field names.
+  IdentifierInfo *Name1 = Field1->getIdentifier();
+  IdentifierInfo *Name2 = Field2->getIdentifier();
+  if (!::IsStructurallyEquivalent(Name1, Name2))
+    return false;
 
   if (!IsStructurallyEquivalent(Context,
                                 Field1->getType(), Field2->getType())) {