[cfe-commits] r145845 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/ExprConstant.cpp
Lang Hames
lhames at gmail.com
Mon Dec 5 12:16:26 PST 2011
Author: lhames
Date: Mon Dec 5 14:16:26 2011
New Revision: 145845
URL: http://llvm.org/viewvc/llvm-project?rev=145845&view=rev
Log:
Make isWeakDecl available as a method on ValueDecl.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=145845&r1=145844&r2=145845&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Dec 5 14:16:26 2011
@@ -508,6 +508,12 @@
QualType getType() const { return DeclType; }
void setType(QualType newType) { DeclType = newType; }
+ /// \brief Determine whether this symbol is weakly-imported,
+ /// or declared with the weak or weak-ref attr.
+ bool isWeak() const {
+ return hasAttr<WeakAttr>() || hasAttr<WeakRefAttr>() || isWeakImported();
+ }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ValueDecl *D) { return true; }
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=145845&r1=145844&r2=145845&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Dec 5 14:16:26 2011
@@ -580,15 +580,9 @@
return Value.Base.dyn_cast<const Expr*>() && !Value.Frame;
}
-static bool IsWeakDecl(const ValueDecl *Decl) {
- return Decl->hasAttr<WeakAttr>() ||
- Decl->hasAttr<WeakRefAttr>() ||
- Decl->isWeakImported();
-}
-
static bool IsWeakLValue(const LValue &Value) {
const ValueDecl *Decl = GetLValueBaseDecl(Value);
- return Decl && IsWeakDecl(Decl);
+ return Decl && Decl->isWeak();
}
static bool EvalPointerValueAsBool(const CCValue &Value, bool &Result) {
@@ -607,7 +601,7 @@
// a weak declaration it can be null at runtime.
Result = true;
const ValueDecl *Decl = Value.getLValueBase().dyn_cast<const ValueDecl*>();
- return !Decl || !IsWeakDecl(Decl);
+ return !Decl || !Decl->isWeak();
}
static bool HandleConversionToBool(const CCValue &Val, bool &Result) {
@@ -866,7 +860,7 @@
// Never evaluate the initializer of a weak variable. We can't be sure that
// this is the definition which will be used.
- if (IsWeakDecl(VD))
+ if (VD->isWeak())
return false;
const Expr *Init = VD->getAnyInitializer();
More information about the cfe-commits
mailing list