[cfe-commits] r39193 - in /cfe/cfe/trunk: AST/SemaExpr.cpp AST/StmtPrinter.cpp Sema/SemaExpr.cpp include/clang/AST/Expr.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:40:55 PDT 2007


Author: sabre
Date: Wed Jul 11 11:40:54 2007
New Revision: 39193

URL: http://llvm.org/viewvc/llvm-project?rev=39193&view=rev
Log:
remember referenced decls in our AST's

Modified:
    cfe/cfe/trunk/AST/SemaExpr.cpp
    cfe/cfe/trunk/AST/StmtPrinter.cpp
    cfe/cfe/trunk/Sema/SemaExpr.cpp
    cfe/cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/cfe/trunk/AST/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaExpr.cpp?rev=39193&r1=39192&r2=39193&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/AST/SemaExpr.cpp Wed Jul 11 11:40:54 2007
@@ -253,8 +253,7 @@
     return true;
   }
     
-    
-  return new DeclRefExpr(*(Decl*)0);
+  return new DeclRefExpr(D);
 }
 
 Sema::ExprResult Sema::ParseSimplePrimaryExpr(SourceLocation Loc,

Modified: cfe/cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/StmtPrinter.cpp?rev=39193&r1=39192&r2=39193&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/cfe/trunk/AST/StmtPrinter.cpp Wed Jul 11 11:40:54 2007
@@ -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::VisitDeclRefExpr(DeclRefExpr *Node) {
-  // FIXME: print name.
-  OS << "x";
+  OS << Node->getDecl()->getName();
 }
 
 void StmtPrinter::VisitIntegerConstant(IntegerConstant *Node) {

Modified: cfe/cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaExpr.cpp?rev=39193&r1=39192&r2=39193&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaExpr.cpp Wed Jul 11 11:40:54 2007
@@ -253,8 +253,7 @@
     return true;
   }
     
-    
-  return new DeclRefExpr(*(Decl*)0);
+  return new DeclRefExpr(D);
 }
 
 Sema::ExprResult Sema::ParseSimplePrimaryExpr(SourceLocation Loc,

Modified: cfe/cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Expr.h?rev=39193&r1=39192&r2=39193&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Expr.h Wed Jul 11 11:40:54 2007
@@ -42,10 +42,12 @@
 /// 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);
 };
 





More information about the cfe-commits mailing list