[cfe-commits] r80432 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/AST/ExprConstant.cpp

Eli Friedman eli.friedman at gmail.com
Sat Aug 29 12:10:00 PDT 2009


Author: efriedma
Date: Sat Aug 29 14:09:59 2009
New Revision: 80432

URL: http://llvm.org/viewvc/llvm-project?rev=80432&view=rev
Log:
Get rid of mostly-unused, buggy method.


Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/ExprConstant.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Aug 29 14:09:59 2009
@@ -257,11 +257,6 @@
   /// cast to void*.
   bool isNullPointerConstant(ASTContext &Ctx) const;
 
-  /// hasGlobalStorage - Return true if this expression has static storage
-  /// duration.  This means that the address of this expression is a link-time
-  /// constant.
-  bool hasGlobalStorage() const;  
-
   /// isOBJCGCCandidate - Return true if this expression may be used in a read/
   /// write barrier. 
   bool isOBJCGCCandidate(ASTContext &Ctx) const;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=80432&r1=80431&r2=80432&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Aug 29 14:09:59 2009
@@ -926,44 +926,6 @@
   return MLV_Valid;    
 }
 
-/// hasGlobalStorage - Return true if this expression has static storage
-/// duration.  This means that the address of this expression is a link-time
-/// constant.
-bool Expr::hasGlobalStorage() const {
-  switch (getStmtClass()) {
-  default:
-    return false;
-  case BlockExprClass:
-    return true;
-  case ParenExprClass:
-    return cast<ParenExpr>(this)->getSubExpr()->hasGlobalStorage();
-  case ImplicitCastExprClass:
-    return cast<ImplicitCastExpr>(this)->getSubExpr()->hasGlobalStorage();
-  case CompoundLiteralExprClass:
-    return cast<CompoundLiteralExpr>(this)->isFileScope();
-  case DeclRefExprClass:
-  case QualifiedDeclRefExprClass: {
-    const Decl *D = cast<DeclRefExpr>(this)->getDecl();
-    if (const VarDecl *VD = dyn_cast<VarDecl>(D))
-      return VD->hasGlobalStorage();
-    if (isa<FunctionDecl>(D))
-      return true;
-    return false;
-  }
-  case MemberExprClass:
-  case CXXQualifiedMemberExprClass: {
-    const MemberExpr *M = cast<MemberExpr>(this);
-    return !M->isArrow() && M->getBase()->hasGlobalStorage();
-  }
-  case ArraySubscriptExprClass:
-    return cast<ArraySubscriptExpr>(this)->getBase()->hasGlobalStorage();
-  case PredefinedExprClass:
-    return true;
-  case CXXDefaultArgExprClass:
-    return cast<CXXDefaultArgExpr>(this)->getExpr()->hasGlobalStorage();
-  }
-}
-
 /// isOBJCGCCandidate - Check if an expression is objc gc'able.
 ///
 bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=80432&r1=80431&r2=80432&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Aug 29 14:09:59 2009
@@ -187,14 +187,14 @@
 
 APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E)
 {
-  if (!E->hasGlobalStorage())
-    return APValue();
-
   if (isa<FunctionDecl>(E->getDecl())) {
     return APValue(E, 0);
   } else if (VarDecl* VD = dyn_cast<VarDecl>(E->getDecl())) {
+    if (!VD->hasGlobalStorage())
+      return APValue();
     if (!VD->getType()->isReferenceType())
       return APValue(E, 0);
+    // FIXME: Check whether VD might be overridden!
     if (VD->getInit())
       return Visit(VD->getInit());
   }





More information about the cfe-commits mailing list