зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
5c06121dda
Коммит
2e5f54aa1d
16
AST/Expr.cpp
16
AST/Expr.cpp
|
@ -436,31 +436,31 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue() const {
|
||||||
return MLV_Valid;
|
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
|
/// duration. This means that the address of this expression is a link-time
|
||||||
/// constant.
|
/// constant.
|
||||||
bool Expr::hasStaticStorage() const {
|
bool Expr::hasGlobalStorage() const {
|
||||||
switch (getStmtClass()) {
|
switch (getStmtClass()) {
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
case ParenExprClass:
|
case ParenExprClass:
|
||||||
return cast<ParenExpr>(this)->getSubExpr()->hasStaticStorage();
|
return cast<ParenExpr>(this)->getSubExpr()->hasGlobalStorage();
|
||||||
case ImplicitCastExprClass:
|
case ImplicitCastExprClass:
|
||||||
return cast<ImplicitCastExpr>(this)->getSubExpr()->hasStaticStorage();
|
return cast<ImplicitCastExpr>(this)->getSubExpr()->hasGlobalStorage();
|
||||||
case CompoundLiteralExprClass:
|
case CompoundLiteralExprClass:
|
||||||
return cast<CompoundLiteralExpr>(this)->isFileScope();
|
return cast<CompoundLiteralExpr>(this)->isFileScope();
|
||||||
case DeclRefExprClass: {
|
case DeclRefExprClass: {
|
||||||
const Decl *D = cast<DeclRefExpr>(this)->getDecl();
|
const Decl *D = cast<DeclRefExpr>(this)->getDecl();
|
||||||
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
|
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
|
||||||
return VD->hasStaticStorage();
|
return VD->hasGlobalStorage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case MemberExprClass: {
|
case MemberExprClass: {
|
||||||
const MemberExpr *M = cast<MemberExpr>(this);
|
const MemberExpr *M = cast<MemberExpr>(this);
|
||||||
return !M->isArrow() && M->getBase()->hasStaticStorage();
|
return !M->isArrow() && M->getBase()->hasGlobalStorage();
|
||||||
}
|
}
|
||||||
case ArraySubscriptExprClass:
|
case ArraySubscriptExprClass:
|
||||||
return cast<ArraySubscriptExpr>(this)->getBase()->hasStaticStorage();
|
return cast<ArraySubscriptExpr>(this)->getBase()->hasGlobalStorage();
|
||||||
case PreDefinedExprClass:
|
case PreDefinedExprClass:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
|
||||||
|
|
||||||
// C99 6.6p9
|
// C99 6.6p9
|
||||||
if (Exp->getOpcode() == UnaryOperator::AddrOf) {
|
if (Exp->getOpcode() == UnaryOperator::AddrOf) {
|
||||||
if (!Exp->getSubExpr()->hasStaticStorage()) {
|
if (!Exp->getSubExpr()->hasGlobalStorage()) {
|
||||||
if (Loc) *Loc = getLocStart();
|
if (Loc) *Loc = getLocStart();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,38 +292,24 @@ protected:
|
||||||
class VarDecl : public ValueDecl {
|
class VarDecl : public ValueDecl {
|
||||||
public:
|
public:
|
||||||
enum StorageClass {
|
enum StorageClass {
|
||||||
None, Extern, Static, Auto, Register, PrivateExtern
|
None, Auto, Register, Extern, Static, PrivateExtern
|
||||||
};
|
};
|
||||||
StorageClass getStorageClass() const { return (StorageClass)SClass; }
|
StorageClass getStorageClass() const { return (StorageClass)SClass; }
|
||||||
|
|
||||||
const Expr *getInit() const { return Init; }
|
const Expr *getInit() const { return Init; }
|
||||||
Expr *getInit() { return Init; }
|
Expr *getInit() { return Init; }
|
||||||
void setInit(Expr *I) { Init = I; }
|
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
|
/// hasLocalStorage - Returns true if a variable with function scope
|
||||||
/// is a non-static local variable.
|
/// is a non-static local variable.
|
||||||
bool hasLocalStorage() const {
|
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
|
/// 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.
|
/// isConstantExpr - Return true if this expression is a valid constant expr.
|
||||||
bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const;
|
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
|
/// duration. This means that the address of this expression is a link-time
|
||||||
/// constant.
|
/// constant.
|
||||||
bool hasStaticStorage() const;
|
bool hasGlobalStorage() const;
|
||||||
|
|
||||||
/// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return
|
/// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return
|
||||||
/// its subexpression. If that subexpression is also a ParenExpr,
|
/// its subexpression. If that subexpression is also a ParenExpr,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче