[PATCH] D49296: [ASTImporter] Fix import of unnamed structs
    Balázs Kéri via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Mon Jul 16 00:08:19 PDT 2018
    
    
  
balazske added inline comments.
================
Comment at: lib/AST/ASTStructuralEquivalence.cpp:913
 
-  if (D1->isAnonymousStructOrUnion() && D2->isAnonymousStructOrUnion()) {
+  if (!D1->getDeclName() && !D2->getDeclName()) {
     // If both anonymous structs/unions are in a record context, make sure
----------------
The problem was that value of `isAnonymousStructOrUnion` is not (or not yet) set correctly during the import? But `getDeclName` is always correct (if it is a `false` the record is anonymous struct)?
================
Comment at: unittests/AST/StructuralEquivalenceTest.cpp:486
 struct StructuralEquivalenceRecordTest : StructuralEquivalenceTest {
+  RecordDecl* getRecordDecl(FieldDecl *FD) {
+    auto *ET = cast<ElaboratedType>(FD->getType().getTypePtr());
----------------
`RecordDecl *`
================
Comment at: unittests/AST/StructuralEquivalenceTest.cpp:578
+
+  ASSERT_TRUE(R0);
+  ASSERT_TRUE(R1);
----------------
Is it possible at all that getRecordDecl returns nullptr? It uses cast (nor cast_or_null and not dyn_cast).
================
Comment at: unittests/AST/StructuralEquivalenceTest.cpp:581
+  ASSERT_NE(R0, R1);
+  EXPECT_TRUE(testStructuralMatch(R0, R0));
+  EXPECT_TRUE(testStructuralMatch(R1, R1));
----------------
a_sidorin wrote:
> Do we really want to test the equivalence of decl to itself, not to its imported version?
I think this is correct: `R0` should be equivalent with itself but not with `R1`.
Repository:
  rC Clang
https://reviews.llvm.org/D49296
    
    
More information about the cfe-commits
mailing list