diff options
author | Gabor Marton <martongabesz@gmail.com> | 2019-02-11 10:27:58 +0000 |
---|---|---|
committer | Gabor Marton <martongabesz@gmail.com> | 2019-02-11 10:27:58 +0000 |
commit | 0e04ebdcda44ef90e25abd0a2e65cc755ae8bc37 (patch) | |
tree | 5d71f228cbde13802d8266d7bd723d1fc28731d4 /clang/unittests/AST/ASTImporterTest.cpp | |
parent | 6bcf6358eb29c33cd0a4e7065a5b0395c053c56f (diff) | |
download | bcm5719-llvm-0e04ebdcda44ef90e25abd0a2e65cc755ae8bc37.tar.gz bcm5719-llvm-0e04ebdcda44ef90e25abd0a2e65cc755ae8bc37.zip |
[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
llvm-svn: 353684
Diffstat (limited to 'clang/unittests/AST/ASTImporterTest.cpp')
-rw-r--r-- | clang/unittests/AST/ASTImporterTest.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 0aadf5693ad..7953cbe58c4 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/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, ); |