diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-12 22:28:03 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-12 22:28:03 +0000 |
commit | 1bf9a9e6a5bdc0de7939908855dcddf46b661800 (patch) | |
tree | 81774dcc4e8eec6cbd2a95cf48e9236a1771bd30 /include/clang/AST/APValue.h | |
parent | 8213ecaa7ce2048f1e10b02f730aefb7fdda57fe (diff) | |
download | clang-1bf9a9e6a5bdc0de7939908855dcddf46b661800.tar.gz clang-1bf9a9e6a5bdc0de7939908855dcddf46b661800.tar.bz2 clang-1bf9a9e6a5bdc0de7939908855dcddf46b661800.tar.xz |
Represent an APValue based on a Decl as that Decl, rather than a DeclRefExpr
or MemberExpr which refers to it. As a side-effect, MemberExprs which refer to
static member functions and static data members are now emitted as constant
expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144468 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/APValue.h')
-rw-r--r-- | include/clang/AST/APValue.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h index 0d6af425e9..69b1d1b80d 100644 --- a/include/clang/AST/APValue.h +++ b/include/clang/AST/APValue.h @@ -18,6 +18,7 @@ #include "llvm/ADT/APSInt.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/PointerUnion.h" namespace clang { class CharUnits; @@ -25,6 +26,7 @@ namespace clang { class Expr; class FieldDecl; class Decl; + class ValueDecl; /// APValue - This class implements a discriminated union of [uninitialized] /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset], @@ -45,6 +47,7 @@ public: Struct, Union }; + typedef llvm::PointerUnion<const ValueDecl *, const Expr *> LValueBase; typedef llvm::PointerIntPair<const Decl *, 1, bool> BaseOrMemberType; union LValuePathEntry { /// BaseOrMember - The FieldDecl or CXXRecordDecl indicating the next item @@ -124,15 +127,14 @@ public: APValue(const APValue &RHS) : Kind(Uninitialized) { *this = RHS; } - APValue(const Expr *B, const CharUnits &O, NoLValuePath N) + APValue(LValueBase B, const CharUnits &O, NoLValuePath N) : Kind(Uninitialized) { MakeLValue(); setLValue(B, O, N); } - APValue(const Expr *B, const CharUnits &O, ArrayRef<LValuePathEntry> Path) + APValue(LValueBase B, const CharUnits &O, ArrayRef<LValuePathEntry> Path) : Kind(Uninitialized) { MakeLValue(); setLValue(B, O, Path); } - APValue(const Expr *B); APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) { MakeArray(InitElts, Size); } @@ -211,7 +213,7 @@ public: return const_cast<APValue*>(this)->getComplexFloatImag(); } - const Expr* getLValueBase() const; + const LValueBase getLValueBase() const; CharUnits &getLValueOffset(); const CharUnits &getLValueOffset() const { return const_cast<APValue*>(this)->getLValueOffset(); @@ -324,8 +326,8 @@ public: ((ComplexAPFloat*)(char*)Data)->Real = R; ((ComplexAPFloat*)(char*)Data)->Imag = I; } - void setLValue(const Expr *B, const CharUnits &O, NoLValuePath); - void setLValue(const Expr *B, const CharUnits &O, + void setLValue(LValueBase B, const CharUnits &O, NoLValuePath); + void setLValue(LValueBase B, const CharUnits &O, ArrayRef<LValuePathEntry> Path); void setUnion(const FieldDecl *Field, const APValue &Value) { assert(isUnion() && "Invalid accessor"); |