Removed VarDecl::hasStaticStorage() (redundant with hasGlobalStorage())

Removed VarDecl::hasAutoStorage() (only used by hasLocalStorage())

Merged logic from VarDecl::hasAutoStorage() into VarDecl::hasLocalStorage(),
and expanded (fixed) the logic of hasLocalStorage() to handle Extern and PrivateExtern.

Renamed Expr::hasStaticStorage() to Expr::hasGlobalStorage().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2008-02-27 18:39:48 +00:00
Родитель 5c06121dda
Коммит 2e5f54aa1d
3 изменённых файлов: 18 добавлений и 32 удалений

Просмотреть файл

@ -436,31 +436,31 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue() const {
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;
}
@ -539,7 +539,7 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
// C99 6.6p9
if (Exp->getOpcode() == UnaryOperator::AddrOf) {
if (!Exp->getSubExpr()->hasStaticStorage()) {
if (!Exp->getSubExpr()->hasGlobalStorage()) {
if (Loc) *Loc = getLocStart();
return false;
}

Просмотреть файл

@ -292,7 +292,7 @@ protected:
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; }
@ -300,30 +300,16 @@ public:
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

Просмотреть файл

@ -106,10 +106,10 @@ public:
/// 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,