[PATCH] D27033: [ASTImporter] Support importing UnresolvedLookupExpr nodes
Kareem Khazem via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 22 20:02:20 PST 2016
khazem created this revision.
khazem added reviewers: spyffe, dergachev.a.
khazem added subscribers: cfe-commits, phosek, seanklein.
This patch adds support for importing AST nodes of type UnresolvedLookupExpr, as well as a test for such an import. This resolves an issue where attempting to import UnresolvedLookupExprs would cause Clang to error out with "cannot import unsupported AST node UnresolvedLookupExpr".
https://reviews.llvm.org/D27033
Files:
lib/AST/ASTImporter.cpp
unittests/AST/ASTImporterTest.cpp
Index: unittests/AST/ASTImporterTest.cpp
===================================================================
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -474,5 +474,25 @@
}
+TEST(ImportExpr, ImportUnresolvedLookupExpr) {
+ MatchVerifier<Decl> Verifier;
+ EXPECT_TRUE(
+ testImport(
+ "template <typename T> int foo();"
+ "template <typename T> void declToImport() {"
+ " ::foo<T>;"
+ " ::template foo<T>;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(
+ has(
+ functionDecl(
+ has(
+ compoundStmt(
+ has(
+ unresolvedLookupExpr()))))))));
+}
+
+
} // end namespace ast_matchers
} // end namespace clang
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -271,6 +271,7 @@
Expr *VisitCXXThisExpr(CXXThisExpr *E);
Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
Expr *VisitMemberExpr(MemberExpr *E);
+ Expr *VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
Expr *VisitCallExpr(CallExpr *E);
Expr *VisitInitListExpr(InitListExpr *E);
Expr *VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E);
@@ -6478,6 +6479,31 @@
E->getObjectKind());
}
+Expr *ASTNodeImporter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+ CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
+ Importer.Import(E->getNamingClass()));
+ if (!NamingClass)
+ return nullptr;
+
+ DeclarationNameInfo NameInfo(E->getName(), E->getNameLoc());
+ ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+ UnresolvedSet<8> ToDecls;
+ for (UnresolvedLookupExpr::decls_iterator S = E->decls_begin(),
+ F = E->decls_end();
+ S != F; ++S){
+ if (NamedDecl *To = cast_or_null<NamedDecl>(Importer.Import(*S)))
+ ToDecls.addDecl(To);
+ else
+ return nullptr;
+ }
+
+ return UnresolvedLookupExpr::Create(Importer.getToContext(), NamingClass,
+ E->getQualifierLoc(), NameInfo,
+ E->requiresADL(), E->isOverloaded(),
+ ToDecls.begin(), ToDecls.end());
+}
+
Expr *ASTNodeImporter::VisitCallExpr(CallExpr *E) {
QualType T = Importer.Import(E->getType());
if (T.isNull())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27033.79019.patch
Type: text/x-patch
Size: 2537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161123/206378ce/attachment.bin>
More information about the cfe-commits
mailing list