return MLV_Valid;
}
-/// hasStaticStorage - Return true if this expression has static storage
+/// 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::hasStaticStorage() const {
+bool Expr::hasGlobalStorage() const {
switch (getStmtClass()) {
default:
return false;
case ParenExprClass:
- return cast<ParenExpr>(this)->getSubExpr()->hasStaticStorage();
+ return cast<ParenExpr>(this)->getSubExpr()->hasGlobalStorage();
case ImplicitCastExprClass:
- return cast<ImplicitCastExpr>(this)->getSubExpr()->hasStaticStorage();
+ return cast<ImplicitCastExpr>(this)->getSubExpr()->hasGlobalStorage();
case CompoundLiteralExprClass:
return cast<CompoundLiteralExpr>(this)->isFileScope();
case DeclRefExprClass: {
const Decl *D = cast<DeclRefExpr>(this)->getDecl();
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
- return VD->hasStaticStorage();
+ return VD->hasGlobalStorage();
return false;
}
case MemberExprClass: {
const MemberExpr *M = cast<MemberExpr>(this);
- return !M->isArrow() && M->getBase()->hasStaticStorage();
+ return !M->isArrow() && M->getBase()->hasGlobalStorage();
}
case ArraySubscriptExprClass:
- return cast<ArraySubscriptExpr>(this)->getBase()->hasStaticStorage();
+ return cast<ArraySubscriptExpr>(this)->getBase()->hasGlobalStorage();
case PreDefinedExprClass:
return true;
}
// C99 6.6p9
if (Exp->getOpcode() == UnaryOperator::AddrOf) {
- if (!Exp->getSubExpr()->hasStaticStorage()) {
+ if (!Exp->getSubExpr()->hasGlobalStorage()) {
if (Loc) *Loc = getLocStart();
return false;
}
class VarDecl : public ValueDecl {
public:
enum StorageClass {
- None, Extern, Static, Auto, Register, PrivateExtern
+ None, Auto, Register, Extern, Static, PrivateExtern
};
StorageClass getStorageClass() const { return (StorageClass)SClass; }
const Expr *getInit() const { return Init; }
Expr *getInit() { return Init; }
void setInit(Expr *I) { Init = I; }
-
- /// hasAutoStorage - Returns true if either the implicit or explicit
- /// storage class of a variable is "auto." In particular, variables
- /// declared within a function that lack a storage keyword are
- /// implicitly "auto", but are represented internally with a storage
- /// class of None.
- bool hasAutoStorage() const {
- return getStorageClass() == Auto ||
- (getStorageClass() == None && getKind() != FileVar);
- }
-
- /// hasStaticStorage - Returns true if either the implicit or
- /// explicit storage class of a variable is "static." In
- /// particular, variables declared within a file (outside of a
- /// function) that lack a storage keyword are implicitly "static,"
- /// but are represented internally with a storage class of "None".
- bool hasStaticStorage() const {
- if (getStorageClass() == Static) return true;
- return getKind() == FileVar;
- }
/// hasLocalStorage - Returns true if a variable with function scope
/// is a non-static local variable.
bool hasLocalStorage() const {
- return hasAutoStorage() || getStorageClass() == Register;
+ if (getStorageClass() == None)
+ return getKind() != FileVar;
+
+ // Return true for: Auto, Register.
+ // Return false for: Extern, Static, PrivateExtern.
+
+ return getStorageClass() <= Register;
}
/// hasGlobalStorage - Returns true for all variables that do not
/// isConstantExpr - Return true if this expression is a valid constant expr.
bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const;
- /// hasStaticStorage - Return true if this expression has static storage
+ /// hasGlobalStorage - Return true if this expression has static storage
/// duration. This means that the address of this expression is a link-time
/// constant.
- bool hasStaticStorage() const;
+ bool hasGlobalStorage() const;
/// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return
/// its subexpression. If that subexpression is also a ParenExpr,