From 6f3a117f8162bb5fc1eea1054e94a6a557dc8661 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 24 Aug 2006 05:19:28 +0000 Subject: [PATCH] switch MemberExpr to holding a field decl instead of a raw identifier. llvm-svn: 38948 --- clang/AST/Expr.cpp | 6 +++++- clang/AST/Sema.cpp | 6 ++++-- clang/Parse/ParseExpr.cpp | 1 - clang/Sema/Sema.cpp | 6 ++++-- clang/include/clang/AST/Expr.h | 11 +++++------ clang/include/clang/Parse/Action.h | 2 ++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp index ffa5d3f90480..71415b73f613 100644 --- a/clang/AST/Expr.cpp +++ b/clang/AST/Expr.cpp @@ -119,7 +119,11 @@ CallExprLOC::CallExprLOC(Expr *Fn, SourceLocation lparenloc, Expr **Args, void MemberExpr::dump_impl() const { Base->dump(); - std::cerr << (isArrow ? "->" : ".") << MemberII->getName(); + std::cerr << (isArrow ? "->" : "."); + + if (MemberDecl) + /*TODO: Print MemberDecl*/; + std::cerr << "member"; } /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it diff --git a/clang/AST/Sema.cpp b/clang/AST/Sema.cpp index 7711d183281f..48c879d924f6 100644 --- a/clang/AST/Sema.cpp +++ b/clang/AST/Sema.cpp @@ -211,11 +211,13 @@ Action::ExprResult ASTBuilder:: ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc, tok::TokenKind OpKind, SourceLocation MemberLoc, IdentifierInfo &Member) { + Decl *MemberDecl = 0; + // TODO: Look up MemberDecl. if (!FullLocInfo) - return new MemberExpr((Expr*)Base, OpKind == tok::arrow, Member); + return new MemberExpr((Expr*)Base, OpKind == tok::arrow, MemberDecl); else return new MemberExprLOC((Expr*)Base, OpLoc, OpKind == tok::arrow, - MemberLoc, Member); + MemberLoc, MemberDecl); } /// ParseCallExpr - Handle a call to Fn with the specified array of arguments. diff --git a/clang/Parse/ParseExpr.cpp b/clang/Parse/ParseExpr.cpp index aae3e44721ef..0d56cf83995a 100644 --- a/clang/Parse/ParseExpr.cpp +++ b/clang/Parse/ParseExpr.cpp @@ -559,7 +559,6 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { /// argument-expression-list ',' assignment-expression /// Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { - assert(!LHS.isInvalid && "LHS is invalid already!"); // Now that the primary-expression piece of the postfix-expression has been // parsed, see if there are any postfix-expression pieces here. diff --git a/clang/Sema/Sema.cpp b/clang/Sema/Sema.cpp index 7711d183281f..48c879d924f6 100644 --- a/clang/Sema/Sema.cpp +++ b/clang/Sema/Sema.cpp @@ -211,11 +211,13 @@ Action::ExprResult ASTBuilder:: ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc, tok::TokenKind OpKind, SourceLocation MemberLoc, IdentifierInfo &Member) { + Decl *MemberDecl = 0; + // TODO: Look up MemberDecl. if (!FullLocInfo) - return new MemberExpr((Expr*)Base, OpKind == tok::arrow, Member); + return new MemberExpr((Expr*)Base, OpKind == tok::arrow, MemberDecl); else return new MemberExprLOC((Expr*)Base, OpLoc, OpKind == tok::arrow, - MemberLoc, Member); + MemberLoc, MemberDecl); } /// ParseCallExpr - Handle a call to Fn with the specified array of arguments. diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index dc8d895bec76..99c3f7900c1e 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -177,12 +177,11 @@ public: /// class MemberExpr : public Expr { Expr *Base; - // TODO: union { Decl *MemberDecl; IdentifierInfo *MemberII; }; - IdentifierInfo *MemberII; + Decl *MemberDecl; bool isArrow; // True if this is "X->F", false if this is "X.F". public: - MemberExpr(Expr *base, bool isarrow, IdentifierInfo &memberii) - : Base(base), MemberII(&memberii), isArrow(isarrow) { + MemberExpr(Expr *base, bool isarrow, Decl *memberdecl) + : Base(base), MemberDecl(memberdecl), isArrow(isarrow) { } virtual void dump_impl() const; }; @@ -191,8 +190,8 @@ class MemberExprLOC : public MemberExpr { SourceLocation OpLoc, MemberLoc; public: MemberExprLOC(Expr *Base, SourceLocation oploc, bool isArrow, - SourceLocation memberLoc, IdentifierInfo &MemberII) - : MemberExpr(Base, isArrow, MemberII), OpLoc(oploc), MemberLoc(memberLoc) { + SourceLocation memberLoc, Decl *MemberDecl) + : MemberExpr(Base, isArrow, MemberDecl), OpLoc(oploc), MemberLoc(memberLoc){ } }; diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h index d459c5642d16..c95ff1159067 100644 --- a/clang/include/clang/Parse/Action.h +++ b/clang/include/clang/Parse/Action.h @@ -57,6 +57,8 @@ public: bool isInvalid; ExprResult(bool Invalid = false) : Val(0), isInvalid(Invalid) {} + template + ExprResult(ActualExprTy *val) : Val(val), isInvalid(false) {} const ExprResult &operator=(ExprTy *RHS) { Val = RHS;