Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/AST/ASTImporterTest.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 7,493 Lines • ▼ Show 20 Lines | TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) { | ||||
Decl *FromTU = getTuDecl( | Decl *FromTU = getTuDecl( | ||||
R"( | R"( | ||||
void declToImport(int N) { | void declToImport(int N) { | ||||
int VLA[N]; | int VLA[N]; | ||||
[&VLA] {}; // FieldDecl inside the lambda. | [&VLA] {}; // FieldDecl inside the lambda. | ||||
} | } | ||||
)", | )", | ||||
Lang_CXX14); | Lang_CXX14); | ||||
auto *FromFD = FirstDeclMatcher<FieldDecl>().match(FromTU, fieldDecl()); | |||||
auto *FromF = FirstDeclMatcher<FunctionDecl>().match( | |||||
FromTU, functionDecl(hasName("declToImport"))); | |||||
CXXRecordDecl *FromLambda = | |||||
cast<LambdaExpr>((cast<CompoundStmt>(FromF->getBody())->body_back())) | |||||
->getLambdaClass(); | |||||
auto *FromFD = *FromLambda->field_begin(); | |||||
ASSERT_TRUE(FromFD); | ASSERT_TRUE(FromFD); | ||||
ASSERT_TRUE(FromFD->hasCapturedVLAType()); | ASSERT_TRUE(FromFD->hasCapturedVLAType()); | ||||
auto *ToFD = Import(FromFD, Lang_CXX14); | auto *ToFD = Import(FromFD, Lang_CXX14); | ||||
EXPECT_TRUE(ToFD); | EXPECT_TRUE(ToFD); | ||||
EXPECT_TRUE(ToFD->hasCapturedVLAType()); | EXPECT_TRUE(ToFD->hasCapturedVLAType()); | ||||
EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType()); | EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 559 Lines • ▼ Show 20 Lines | TEST_P(ASTImporterOptionSpecificTestBase, isNewDecl) { | ||||
auto *ToBar = FirstDeclMatcher<FunctionDecl>().match( | auto *ToBar = FirstDeclMatcher<FunctionDecl>().match( | ||||
ToTU, functionDecl(hasName("bar"))); | ToTU, functionDecl(hasName("bar"))); | ||||
EXPECT_TRUE(SharedStatePtr->isNewDecl(ToOther)); | EXPECT_TRUE(SharedStatePtr->isNewDecl(ToOther)); | ||||
EXPECT_FALSE(SharedStatePtr->isNewDecl(ToBar)); | EXPECT_FALSE(SharedStatePtr->isNewDecl(ToBar)); | ||||
} | } | ||||
TEST_P(ASTImporterOptionSpecificTestBase, VaList) { | |||||
Decl *FromTU = getTuDecl(R"(typedef __builtin_va_list va_list;)", Lang_C99); | |||||
auto *FromVaList = FirstDeclMatcher<TypedefDecl>().match( | |||||
FromTU, typedefDecl(hasName("va_list"))); | |||||
ASSERT_TRUE(FromVaList); | |||||
auto *ToVaList = Import(FromVaList, Lang_C99); | |||||
ASSERT_TRUE(ToVaList); | |||||
auto *ToBuiltinVaList = FirstDeclMatcher<TypedefDecl>().match( | |||||
ToAST->getASTContext().getTranslationUnitDecl(), | |||||
typedefDecl(hasName("__builtin_va_list"))); | |||||
ASSERT_TRUE(ToAST->getASTContext().hasSameType( | |||||
ToVaList->getUnderlyingType(), ToBuiltinVaList->getUnderlyingType())); | |||||
} | |||||
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest, | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest, | ||||
DefaultTestValuesForRunOptions); | DefaultTestValuesForRunOptions); | ||||
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportPath, | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportPath, | ||||
::testing::Values(std::vector<std::string>())); | ::testing::Values(std::vector<std::string>())); | ||||
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportExpr, | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportExpr, | ||||
DefaultTestValuesForRunOptions); | DefaultTestValuesForRunOptions); | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |