aboutsummaryrefslogtreecommitdiff
path: root/unittests/AST/ASTImporterTest.cpp
diff options
context:
space:
mode:
authorGabor Marton <martongabesz@gmail.com>2019-02-11 10:27:58 +0000
committerGabor Marton <martongabesz@gmail.com>2019-02-11 10:27:58 +0000
commitfd8b7d75ce67ef3c7366072f1d63af563f058d85 (patch)
treed3582c5aa6609bcc257e7c4a6f05a44e9fec693d /unittests/AST/ASTImporterTest.cpp
parent1940ede73f448c9dcb00a223412e2ae5ed1ca6d8 (diff)
[ASTImporter] Add test RedeclChainShouldBeCorrectAmongstNamespaces
Summary: We add a new test to show that redecl chains are not handled properly amongst namespaces. We cannot pass this test now, so this is disabled. Subsequent patches will make this test pass. Reviewers: a_sidorin, shafik, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57901 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/AST/ASTImporterTest.cpp')
-rw-r--r--unittests/AST/ASTImporterTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/unittests/AST/ASTImporterTest.cpp b/unittests/AST/ASTImporterTest.cpp
index 0aadf5693a..7953cbe58c 100644
--- a/unittests/AST/ASTImporterTest.cpp
+++ b/unittests/AST/ASTImporterTest.cpp
@@ -5143,6 +5143,47 @@ INSTANTIATE_TEST_CASE_P(
ParameterizedTests, CanonicalRedeclChain,
::testing::Values(ArgVector()),);
+// FIXME This test is disabled currently, upcoming patches will make it
+// possible to enable.
+TEST_P(ASTImporterOptionSpecificTestBase,
+ DISABLED_RedeclChainShouldBeCorrectAmongstNamespaces) {
+ Decl *FromTU = getTuDecl(
+ R"(
+ namespace NS {
+ struct X;
+ struct Y {
+ static const int I = 3;
+ };
+ }
+ namespace NS {
+ struct X { // <--- To be imported
+ void method(int i = Y::I) {}
+ int f;
+ };
+ }
+ )",
+ Lang_CXX);
+ auto *FromFwd = FirstDeclMatcher<CXXRecordDecl>().match(
+ FromTU, cxxRecordDecl(hasName("X"), unless(isImplicit())));
+ auto *FromDef = LastDeclMatcher<CXXRecordDecl>().match(
+ FromTU,
+ cxxRecordDecl(hasName("X"), isDefinition(), unless(isImplicit())));
+ ASSERT_NE(FromFwd, FromDef);
+ ASSERT_FALSE(FromFwd->isThisDeclarationADefinition());
+ ASSERT_TRUE(FromDef->isThisDeclarationADefinition());
+ ASSERT_EQ(FromFwd->getCanonicalDecl(), FromDef->getCanonicalDecl());
+
+ auto *ToDef = cast_or_null<CXXRecordDecl>(Import(FromDef, Lang_CXX));
+ auto *ToFwd = cast_or_null<CXXRecordDecl>(Import(FromFwd, Lang_CXX));
+ EXPECT_NE(ToFwd, ToDef);
+ EXPECT_FALSE(ToFwd->isThisDeclarationADefinition());
+ EXPECT_TRUE(ToDef->isThisDeclarationADefinition());
+ EXPECT_EQ(ToFwd->getCanonicalDecl(), ToDef->getCanonicalDecl());
+ auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+ // We expect no (ODR) warning during the import.
+ EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
+}
+
INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
DefaultTestValuesForRunOptions, );