remember referenced decls in our AST's

llvm-svn: 39193
This commit is contained in:
Chris Lattner
2006-11-20 05:01:40 +00:00
parent 17ed487947
commit 5efbb33a6b
4 changed files with 9 additions and 9 deletions

View File

@@ -253,8 +253,7 @@ Sema::ExprResult Sema::ParseIdentifierExpr(SourceLocation Loc,
return true;
}
return new DeclRefExpr(*(Decl*)0);
return new DeclRefExpr(D);
}
Sema::ExprResult Sema::ParseSimplePrimaryExpr(SourceLocation Loc,

View File

@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/Lex/IdentifierTable.h"
#include "llvm/Support/Compiler.h"
@@ -211,8 +212,7 @@ void StmtPrinter::VisitExpr(Expr *Node) {
}
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
// FIXME: print name.
OS << "x";
OS << Node->getDecl()->getName();
}
void StmtPrinter::VisitIntegerConstant(IntegerConstant *Node) {

View File

@@ -253,8 +253,7 @@ Sema::ExprResult Sema::ParseIdentifierExpr(SourceLocation Loc,
return true;
}
return new DeclRefExpr(*(Decl*)0);
return new DeclRefExpr(D);
}
Sema::ExprResult Sema::ParseSimplePrimaryExpr(SourceLocation Loc,

View File

@@ -42,10 +42,12 @@ public:
/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
/// enum, etc.
class DeclRefExpr : public Expr {
// TODO: Union with the decl when resolved.
Decl &D;
Decl *D;
public:
DeclRefExpr(Decl &d) : D(d) {}
DeclRefExpr(Decl *d) : D(d) {}
Decl *getDecl() const { return D; }
virtual void visit(StmtVisitor &Visitor);
};