diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-04 15:01:18 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-04 15:01:18 +0000 |
commit | b8a9a41dd6ea0b0d652edb5be0a78dd21e0e271d (patch) | |
tree | 73af2a895cd623e0261648fcb2cb3d7c31e9c9ee /clang/include | |
parent | 82b7372941c4273d0bc4180b2b60c681fbcf63d1 (diff) | |
download | bcm5719-llvm-b8a9a41dd6ea0b0d652edb5be0a78dd21e0e271d.tar.gz bcm5719-llvm-b8a9a41dd6ea0b0d652edb5be0a78dd21e0e271d.zip |
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)
llvm-svn: 63733
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/AST/ExprCXX.h | 39 | ||||
-rw-r--r-- | clang/include/clang/AST/StmtNodes.def | 2 |
2 files changed, 24 insertions, 17 deletions
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 4f48eb3716a..26f3b6c1610 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -727,28 +727,35 @@ public: static CXXDeleteExpr * CreateImpl(llvm::Deserializer& D, ASTContext& C); }; -/// CXXDependentNameExpr - Represents a dependent name in C++ for -/// which we could not locate any definition. These names can only -/// occur as in the example below, with an unqualified call to a -/// function name whose arguments are dependent. +/// \brief Represents the name of a function that has not been +/// resolved to any declaration. +/// +/// Unresolved function names occur when a function name is +/// encountered prior to an open parentheses ('(') in a C++ function +/// call, and the function name itself did not resolve to a +/// declaration. These function names can only be resolved when they +/// form the postfix-expression of a function call, so that +/// argument-dependent lookup finds declarations corresponding to +/// these functions. + /// @code /// template<typename T> void f(T x) { -/// g(x); // g is a dependent name. +/// g(x); // g is an unresolved function name (that is also a dependent name) /// } /// @endcode -class CXXDependentNameExpr : public Expr { - /// Name - The name that was present in the source code. - IdentifierInfo *Name; +class UnresolvedFunctionNameExpr : public Expr { + /// The name that was present in the source + DeclarationName Name; - /// Loc - The location + /// The location of this name in the source code SourceLocation Loc; public: - CXXDependentNameExpr(IdentifierInfo *N, QualType T, SourceLocation L) - : Expr(CXXDependentNameExprClass, T, true, true), Name(N), Loc(L) { } + UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L) + : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { } - /// getName - Retrieves the name that occurred in the source code. - IdentifierInfo *getName() const { return Name; } + /// \brief Retrieves the name that occurred in the source code. + DeclarationName getName() const { return Name; } /// getLocation - Retrieves the location in the source code where /// the name occurred. @@ -757,16 +764,16 @@ public: virtual SourceRange getSourceRange() const { return SourceRange(Loc); } static bool classof(const Stmt *T) { - return T->getStmtClass() == CXXDependentNameExprClass; + return T->getStmtClass() == UnresolvedFunctionNameExprClass; } - static bool classof(const CXXDependentNameExpr *) { return true; } + static bool classof(const UnresolvedFunctionNameExpr *) { return true; } // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); virtual void EmitImpl(llvm::Serializer& S) const; - static CXXDependentNameExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C); + static UnresolvedFunctionNameExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C); }; /// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the diff --git a/clang/include/clang/AST/StmtNodes.def b/clang/include/clang/AST/StmtNodes.def index 18b8dbebfed..0d289f55f3b 100644 --- a/clang/include/clang/AST/StmtNodes.def +++ b/clang/include/clang/AST/StmtNodes.def @@ -115,7 +115,7 @@ STMT(CXXZeroInitValueExpr , Expr) STMT(CXXConditionDeclExpr , DeclRefExpr) STMT(CXXNewExpr , Expr) STMT(CXXDeleteExpr , Expr) -STMT(CXXDependentNameExpr , Expr) +STMT(UnresolvedFunctionNameExpr , Expr) STMT(UnaryTypeTraitExpr , Expr) STMT(QualifiedDeclRefExpr , DeclRefExpr) |