diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Expr.h | 13 | ||||
-rw-r--r-- | include/clang/AST/ExprCXX.h | 25 | ||||
-rw-r--r-- | include/clang/AST/StmtNodes.def | 1 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticKinds.def | 7 |
4 files changed, 43 insertions, 3 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 48267bafa6..62a93b51e8 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -31,7 +31,9 @@ namespace clang { class NamedDecl; class ValueDecl; class BlockDecl; - + class CXXOperatorCallExpr; + class CXXMemberCallExpr; + /// Expr - This represents one expression. Note that Expr's are subclasses of /// Stmt. This allows an expression to be transparently used any place a Stmt /// is required. @@ -815,10 +817,13 @@ public: static bool classof(const Stmt *T) { return T->getStmtClass() == CallExprClass || - T->getStmtClass() == CXXOperatorCallExprClass; + T->getStmtClass() == CXXOperatorCallExprClass || + T->getStmtClass() == CXXMemberCallExprClass; } static bool classof(const CallExpr *) { return true; } - + static bool classof(const CXXOperatorCallExpr *) { return true; } + static bool classof(const CXXMemberCallExpr *) { return true; } + // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); @@ -841,8 +846,10 @@ public: : Expr(MemberExprClass, ty), Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow) {} + void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast<Expr>(Base); } NamedDecl *getMemberDecl() const { return MemberDecl; } + void setMemberDecl(NamedDecl *D) { MemberDecl = D; } bool isArrow() const { return IsArrow; } virtual SourceRange getSourceRange() const { diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 74df215293..31dfd25833 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -54,6 +54,31 @@ public: static bool classof(const CXXOperatorCallExpr *) { return true; } }; +/// CXXMemberCallExpr - Represents a call to a member function that +/// may be written either with member call syntax (e.g., "obj.func()" +/// or "objptr->func()") or with normal function-call syntax +/// ("func()") within a member function that ends up calling a member +/// function. The callee in either case is a MemberExpr that contains +/// both the object argument and the member function, while the +/// arguments are the arguments within the parentheses (not including +/// the object argument). +class CXXMemberCallExpr : public CallExpr { +public: + CXXMemberCallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t, + SourceLocation rparenloc) + : CallExpr(CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) { } + + /// getImplicitObjectArgument - Retrieves the implicit object + /// argument for the member call. For example, in "x.f(5)", this + /// operation would return "x". + Expr *getImplicitObjectArgument(); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == CXXMemberCallExprClass; + } + static bool classof(const CXXMemberCallExpr *) { return true; } +}; + /// CXXNamedCastExpr - Abstract class common to all of the C++ "named" /// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c /// const_cast. diff --git a/include/clang/AST/StmtNodes.def b/include/clang/AST/StmtNodes.def index b49ad8a232..939325ac1f 100644 --- a/include/clang/AST/StmtNodes.def +++ b/include/clang/AST/StmtNodes.def @@ -92,6 +92,7 @@ STMT(GNUNullExpr , Expr) // C++ Expressions. STMT(CXXOperatorCallExpr , CallExpr) +STMT(CXXMemberCallExpr , CallExpr) STMT(CXXNamedCastExpr , ExplicitCastExpr) STMT(CXXStaticCastExpr , CXXNamedCastExpr) STMT(CXXDynamicCastExpr , CXXNamedCastExpr) diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def index 510f3ff916..bad9819ec8 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/include/clang/Basic/DiagnosticKinds.def @@ -937,8 +937,13 @@ DIAG(err_ovl_static_nonstatic_member, ERROR, DIAG(err_ovl_no_viable_function_in_call, ERROR, "no matching function for call to %0" "%plural{0:|1:; candidate is|:; candidates are:}1") +DIAG(err_ovl_no_viable_member_function_in_call, ERROR, + "no matching member function for call to %0" + "%plural{0:|1:; candidate is|:; candidates are:}1") DIAG(err_ovl_ambiguous_call, ERROR, "call to %0 is ambiguous; candidates are:") +DIAG(err_ovl_ambiguous_member_call, ERROR, + "call to member function %0 is ambiguous; candidates are:") DIAG(err_ovl_candidate, NOTE, "candidate function") DIAG(err_ovl_builtin_candidate, NOTE, @@ -959,6 +964,8 @@ DIAG(err_ovl_ambiguous_object_call, ERROR, "call to object of type %0 is ambiguous; candidates are:") DIAG(err_ovl_surrogate_cand, NOTE, "conversion candidate of type %0") +DIAG(err_member_call_without_object, ERROR, + "call to non-static member function without an object argument") /// C++ Templates Semantic Analysis DIAG(err_template_param_shadow, ERROR, |