]> granicus.if.org Git - clang/commitdiff
Revert "[ASTImporter][Structural Eq] Check for isBeingDefined"
authorShafik Yaghmour <syaghmour@apple.com>
Wed, 31 Oct 2018 21:53:15 +0000 (21:53 +0000)
committerShafik Yaghmour <syaghmour@apple.com>
Wed, 31 Oct 2018 21:53:15 +0000 (21:53 +0000)
This reverts commit r345760

because it caused an assertion in the lldb test suite. This is the log from the build bot: http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/12003/

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

lib/AST/ASTStructuralEquivalence.cpp
unittests/AST/ASTImporterTest.cpp

index b6ed7578c3800c1044e819f1a8221028432ece22..9149006a204bd6d892ee6ecf9d37de6083b8dc37 100644 (file)
@@ -1016,8 +1016,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
     return false;
 
   // Compare the definitions of these two records. If either or both are
-  // incomplete (i.e. it is a forward decl), we assume that they are
-  // equivalent.
+  // incomplete, we assume that they are equivalent.
   D1 = D1->getDefinition();
   D2 = D2->getDefinition();
   if (!D1 || !D2)
@@ -1032,11 +1031,6 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
     if (D1->hasExternalLexicalStorage() || D2->hasExternalLexicalStorage())
       return true;
 
-  // If one definition is currently being defined, we do not compare for
-  // equality and we assume that the decls are equal.
-  if (D1->isBeingDefined() || D2->isBeingDefined())
-    return true;
-
   if (auto *D1CXX = dyn_cast<CXXRecordDecl>(D1)) {
     if (auto *D2CXX = dyn_cast<CXXRecordDecl>(D2)) {
       if (D1CXX->hasExternalLexicalStorage() &&
index 53078b68dbc850b82d90588d7eb0b4a59a62db27..d1683cd0a678400ce3055df0de662b851f07f4ad 100644 (file)
@@ -3726,45 +3726,6 @@ TEST_P(ImportFunctionTemplateSpecializations, DefinitionThenPrototype) {
   EXPECT_EQ(To1->getPreviousDecl(), To0);
 }
 
-TEST_P(ASTImporterTestBase,
-    ImportShouldNotReportFalseODRErrorWhenRecordIsBeingDefined) {
-  {
-    Decl *FromTU = getTuDecl(
-        R"(
-            template <typename T>
-            struct B;
-            )",
-        Lang_CXX, "input0.cc");
-    auto *FromD = FirstDeclMatcher<ClassTemplateDecl>().match(
-        FromTU, classTemplateDecl(hasName("B")));
-
-    Import(FromD, Lang_CXX);
-  }
-
-  {
-    Decl *FromTU = getTuDecl(
-        R"(
-            template <typename T>
-            struct B {
-              void f();
-              B* b;
-            };
-            )",
-        Lang_CXX, "input1.cc");
-    FunctionDecl *FromD = FirstDeclMatcher<FunctionDecl>().match(
-        FromTU, functionDecl(hasName("f")));
-    Import(FromD, Lang_CXX);
-    auto *FromCTD = FirstDeclMatcher<ClassTemplateDecl>().match(
-        FromTU, classTemplateDecl(hasName("B")));
-    auto *ToCTD = cast<ClassTemplateDecl>(Import(FromCTD, Lang_CXX));
-    EXPECT_TRUE(ToCTD->isThisDeclarationADefinition());
-
-    // We expect no (ODR) warning during the import.
-    auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
-    EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
-  }
-}
-
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
                         ::testing::Values(ArgVector()), );