forked from OSchip/llvm-project
add several cases that Expr::hasStaticStorage missed, pointed out by Oliver Hunt
llvm-svn: 44376
This commit is contained in:
parent
1a6bb70ad0
commit
da22eeca44
|
@ -360,10 +360,17 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue() const {
|
|||
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 @@ bool Expr::hasStaticStorage() const {
|
|||
case MemberExprClass:
|
||||
const MemberExpr *M = cast<MemberExpr>(this);
|
||||
return !M->isArrow() && M->getBase()->hasStaticStorage();
|
||||
case ArraySubscriptExprClass:
|
||||
return cast<ArraySubscriptExpr>(this)->getBase()->hasStaticStorage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,8 @@ public:
|
|||
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) {
|
||||
|
|
|
@ -4,3 +4,7 @@ typedef void (* fp)(void);
|
|||
void foo(void);
|
||||
fp a[1] = { foo };
|
||||
|
||||
int myArray[5] = {1, 2, 3, 4, 5};
|
||||
int *myPointer2 = myArray;
|
||||
int *myPointer = &(myArray[2]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue