forked from OSchip/llvm-project
[ASTImporter] Import member expr with explicit template args
Summary: Member expressions with explicit template arguments were not imported correctly: the DeclRefExpr was missing. This patch fixes. Reviewers: a_sidorin, shafik, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58830 llvm-svn: 355596
This commit is contained in:
parent
e7ec39c123
commit
5caba3069e
|
@ -7129,15 +7129,19 @@ ExpectedStmt ASTNodeImporter::VisitMemberExpr(MemberExpr *E) {
|
||||||
|
|
||||||
DeclarationNameInfo ToMemberNameInfo(ToName, ToLoc);
|
DeclarationNameInfo ToMemberNameInfo(ToName, ToLoc);
|
||||||
|
|
||||||
|
TemplateArgumentListInfo ToTAInfo, *ResInfo = nullptr;
|
||||||
if (E->hasExplicitTemplateArgs()) {
|
if (E->hasExplicitTemplateArgs()) {
|
||||||
// FIXME: handle template arguments
|
if (Error Err =
|
||||||
return make_error<ImportError>(ImportError::UnsupportedConstruct);
|
ImportTemplateArgumentListInfo(E->getLAngleLoc(), E->getRAngleLoc(),
|
||||||
|
E->template_arguments(), ToTAInfo))
|
||||||
|
return std::move(Err);
|
||||||
|
ResInfo = &ToTAInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MemberExpr::Create(
|
return MemberExpr::Create(
|
||||||
Importer.getToContext(), ToBase, E->isArrow(), ToOperatorLoc,
|
Importer.getToContext(), ToBase, E->isArrow(), ToOperatorLoc,
|
||||||
ToQualifierLoc, ToTemplateKeywordLoc, ToMemberDecl, ToFoundDecl,
|
ToQualifierLoc, ToTemplateKeywordLoc, ToMemberDecl, ToFoundDecl,
|
||||||
ToMemberNameInfo, nullptr, ToType, E->getValueKind(), E->getObjectKind());
|
ToMemberNameInfo, ResInfo, ToType, E->getValueKind(), E->getObjectKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpectedStmt
|
ExpectedStmt
|
||||||
|
|
|
@ -2604,6 +2604,56 @@ TEST_P(ImportFunctions, ImportImplicitFunctionsInLambda) {
|
||||||
EXPECT_TRUE(LambdaRec->getDestructor());
|
EXPECT_TRUE(LambdaRec->getDestructor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(ImportFunctions,
|
||||||
|
CallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
|
||||||
|
Decl *FromTU = getTuDecl(
|
||||||
|
R"(
|
||||||
|
struct X {
|
||||||
|
template <typename T>
|
||||||
|
void foo(){}
|
||||||
|
};
|
||||||
|
void f() {
|
||||||
|
X x;
|
||||||
|
x.foo<int>();
|
||||||
|
}
|
||||||
|
)",
|
||||||
|
Lang_CXX);
|
||||||
|
auto *FromD = FirstDeclMatcher<FunctionDecl>().match(
|
||||||
|
FromTU, functionDecl(hasName("f")));
|
||||||
|
auto *ToD = Import(FromD, Lang_CXX);
|
||||||
|
EXPECT_TRUE(ToD);
|
||||||
|
EXPECT_TRUE(MatchVerifier<FunctionDecl>().match(
|
||||||
|
ToD, functionDecl(hasName("f"), hasDescendant(declRefExpr()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(ImportFunctions,
|
||||||
|
DependentCallExprOfMemberFunctionTemplateWithExplicitTemplateArgs) {
|
||||||
|
Decl *FromTU = getTuDecl(
|
||||||
|
R"(
|
||||||
|
struct X {
|
||||||
|
template <typename T>
|
||||||
|
void foo(){}
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
void f() {
|
||||||
|
X x;
|
||||||
|
x.foo<T>();
|
||||||
|
}
|
||||||
|
void g() {
|
||||||
|
f<int>();
|
||||||
|
}
|
||||||
|
)",
|
||||||
|
Lang_CXX);
|
||||||
|
auto *FromD = FirstDeclMatcher<FunctionDecl>().match(
|
||||||
|
FromTU, functionDecl(hasName("g")));
|
||||||
|
auto *ToD = Import(FromD, Lang_CXX);
|
||||||
|
EXPECT_TRUE(ToD);
|
||||||
|
Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
|
||||||
|
EXPECT_TRUE(MatchVerifier<TranslationUnitDecl>().match(
|
||||||
|
ToTU, translationUnitDecl(hasDescendant(
|
||||||
|
functionDecl(hasName("f"), hasDescendant(declRefExpr()))))));
|
||||||
|
}
|
||||||
|
|
||||||
struct ImportFriendFunctions : ImportFunctions {};
|
struct ImportFriendFunctions : ImportFunctions {};
|
||||||
|
|
||||||
TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
|
TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainProto) {
|
||||||
|
|
Loading…
Reference in New Issue