[cfe-commits] r44376 - in /cfe/trunk: AST/Expr.cpp include/clang/AST/Expr.h test/Sema/init.c

Chris Lattner sabre at nondot.org
Tue Nov 27 13:35:28 PST 2007


Author: lattner
Date: Tue Nov 27 15:35:27 2007
New Revision: 44376

URL: http://llvm.org/viewvc/llvm-project?rev=44376&view=rev
Log:
add several cases that Expr::hasStaticStorage missed, pointed out by Oliver Hunt

Modified:
    cfe/trunk/AST/Expr.cpp
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/test/Sema/init.c

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

==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Tue Nov 27 15:35:27 2007
@@ -360,10 +360,17 @@
   return MLV_Valid;    
 }
 
+/// hasStaticStorage - Return true if this expression has static storage
+/// duration.  This means that the address of this expression is a link-time
+/// constant.
 bool Expr::hasStaticStorage() const {
   switch (getStmtClass()) {
   default:
     return false;
+  case ParenExprClass:
+    return cast<ParenExpr>(this)->getSubExpr()->hasStaticStorage();
+  case ImplicitCastExprClass:
+    return cast<ImplicitCastExpr>(this)->getSubExpr()->hasStaticStorage();
   case DeclRefExprClass: {
     const Decl *D = cast<DeclRefExpr>(this)->getDecl();
     if (const VarDecl *VD = dyn_cast<VarDecl>(D))
@@ -373,6 +380,8 @@
   case MemberExprClass:
     const MemberExpr *M = cast<MemberExpr>(this);
     return !M->isArrow() && M->getBase()->hasStaticStorage();
+  case ArraySubscriptExprClass:
+    return cast<ArraySubscriptExpr>(this)->getBase()->hasStaticStorage();
   }
 }
 

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Nov 27 15:35:27 2007
@@ -106,7 +106,8 @@
   bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const;
   
   /// hasStaticStorage - Return true if this expression has static storage
-  /// duration.
+  /// duration.  This means that the address of this expression is a link-time
+  /// constant.
   bool hasStaticStorage() const;
 
   static bool classof(const Stmt *T) { 

Modified: cfe/trunk/test/Sema/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init.c?rev=44376&r1=44375&r2=44376&view=diff

==============================================================================
--- cfe/trunk/test/Sema/init.c (original)
+++ cfe/trunk/test/Sema/init.c Tue Nov 27 15:35:27 2007
@@ -4,3 +4,7 @@
 void foo(void);
 fp a[1] = { foo };
 
+int myArray[5] = {1, 2, 3, 4, 5};
+int *myPointer2 = myArray;
+int *myPointer = &(myArray[2]);
+





More information about the cfe-commits mailing list