Fix our semantic analysis of
unqualified-id '('
in C++. The unqualified-id might not refer to any declaration in our
current scope, but declarations by that name might be found via
argument-dependent lookup. We now do so properly.
As part of this change, CXXDependentNameExpr, which was previously
designed to express the unqualified-id in the above constructor within
templates, has become UnresolvedFunctionNameExpr, which does
effectively the same thing but will work for both templates and
non-templates.
Additionally, we cope with all unqualified-ids, since ADL also applies
in cases like
operator+(x, y)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63733 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index b21b413..dbc811a 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -120,11 +120,11 @@
Stmt::child_iterator CXXDeleteExpr::child_begin() { return &Argument; }
Stmt::child_iterator CXXDeleteExpr::child_end() { return &Argument+1; }
-// CXXDependentNameExpr
-Stmt::child_iterator CXXDependentNameExpr::child_begin() {
+// UnresolvedFunctionNameExpr
+Stmt::child_iterator UnresolvedFunctionNameExpr::child_begin() {
return child_iterator();
}
-Stmt::child_iterator CXXDependentNameExpr::child_end() {
+Stmt::child_iterator UnresolvedFunctionNameExpr::child_end() {
return child_iterator();
}
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 27bab20..1f07db7 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -1101,8 +1101,8 @@
PrintExpr(E->getArgument());
}
-void StmtPrinter::VisitCXXDependentNameExpr(CXXDependentNameExpr *E) {
- OS << E->getName()->getName();
+void StmtPrinter::VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *E) {
+ OS << E->getName().getAsString();
}
static const char *getTypeTraitName(UnaryTypeTrait UTT) {
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index 8599a7a..3bb98b4 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -245,8 +245,8 @@
case CXXDeleteExprClass:
return CXXDeleteExpr::CreateImpl(D, C);
- case CXXDependentNameExprClass:
- return CXXDependentNameExpr::CreateImpl(D, C);
+ case UnresolvedFunctionNameExprClass:
+ return UnresolvedFunctionNameExpr::CreateImpl(D, C);
case CXXCatchStmtClass:
return CXXCatchStmt::CreateImpl(D, C);
@@ -1528,18 +1528,18 @@
cast<Expr>(Argument), Loc);
}
-void CXXDependentNameExpr::EmitImpl(llvm::Serializer& S) const {
+void UnresolvedFunctionNameExpr::EmitImpl(llvm::Serializer& S) const {
S.Emit(getType());
- S.EmitPtr(Name);
+ S.EmitPtr(Name.getAsIdentifierInfo()); // FIXME: WRONG!
S.Emit(Loc);
}
-CXXDependentNameExpr *
-CXXDependentNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
+UnresolvedFunctionNameExpr *
+UnresolvedFunctionNameExpr::CreateImpl(llvm::Deserializer& D, ASTContext& C) {
QualType Ty = QualType::ReadVal(D);
IdentifierInfo *N = D.ReadPtr<IdentifierInfo>();
SourceLocation L = SourceLocation::ReadVal(D);
- return new CXXDependentNameExpr(N, Ty, L);
+ return new UnresolvedFunctionNameExpr(N, Ty, L);
}
void UnaryTypeTraitExpr::EmitImpl(llvm::Serializer& S) const {