[cfe-commits] r53216 - /cfe/trunk/include/clang/AST/APValue.h
Anders Carlsson
andersca at mac.com
Mon Jul 7 21:35:29 PDT 2008
Author: andersca
Date: Mon Jul 7 23:35:19 2008
New Revision: 53216
URL: http://llvm.org/viewvc/llvm-project?rev=53216&view=rev
Log:
Add LValue setters for APValue
Modified:
cfe/trunk/include/clang/AST/APValue.h
Modified: cfe/trunk/include/clang/AST/APValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=53216&r1=53215&r2=53216&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Mon Jul 7 23:35:19 2008
@@ -46,7 +46,7 @@
ComplexAPFloat() : Real(0.0), Imag(0.0) {}
};
- struct LValue {
+ struct LV {
Expr* Base;
uint64_t Offset;
};
@@ -77,6 +77,9 @@
APValue(const APValue &RHS) : Kind(Uninitialized) {
*this = RHS;
}
+ APValue(Expr* B, uint64_t O) : Kind(Uninitialized) {
+ MakeLValue(); setLValue(B, O);
+ }
~APValue() {
MakeUninit();
}
@@ -87,6 +90,7 @@
bool isFloat() const { return Kind == Float; }
bool isComplexSInt() const { return Kind == ComplexSInt; }
bool isComplexFloat() const { return Kind == ComplexFloat; }
+ bool isLValue() const { return Kind == LValue; }
const APSInt &getSInt() const {
assert(isSInt() && "Invalid accessor");
@@ -112,6 +116,14 @@
assert(isComplexFloat() && "Invalid accessor");
return ((const ComplexAPFloat*)(const void*)Data)->Imag;
}
+ Expr* getLValueBase() const {
+ assert(isLValue() && "Invalid accessor");
+ return ((const LV*)(const void*)Data)->Base;
+ }
+ uint64_t getLValueOffset() const {
+ assert(isLValue() && "Invalid accessor");
+ return ((const LV*)(const void*)Data)->Offset;
+ }
void setSInt(const APSInt &I) {
assert(isSInt() && "Invalid accessor");
@@ -131,6 +143,11 @@
((ComplexAPFloat*)(void*)Data)->Real = R;
((ComplexAPFloat*)(void*)Data)->Imag = I;
}
+ void setLValue(Expr *B, uint64_t O) {
+ assert(isLValue() && "Invalid accessor");
+ ((LV*)(void*)Data)->Base = B;
+ ((LV*)(void*)Data)->Offset = O;
+ }
const APValue &operator=(const APValue &RHS) {
if (Kind != RHS.Kind) {
@@ -143,6 +160,8 @@
MakeComplexSInt();
else if (RHS.isComplexFloat())
MakeComplexFloat();
+ else if (RHS.isLValue())
+ MakeLValue();
}
if (isSInt())
setSInt(RHS.getSInt());
@@ -152,6 +171,8 @@
setComplexSInt(RHS.getComplexSIntReal(), RHS.getComplexSIntImag());
else if (isComplexFloat())
setComplexFloat(RHS.getComplexFloatReal(), RHS.getComplexFloatImag());
+ else if (isLValue())
+ setLValue(RHS.getLValueBase(), RHS.getLValueOffset());
return *this;
}
@@ -165,6 +186,9 @@
((ComplexAPSInt*)(void*)Data)->~ComplexAPSInt();
else if (Kind == ComplexFloat)
((ComplexAPFloat*)(void*)Data)->~ComplexAPFloat();
+ else if (Kind == LValue) {
+ ((LV*)(void*)Data)->~LV();
+ }
}
void MakeSInt() {
assert(isUninit() && "Bad state change");
@@ -186,6 +210,11 @@
new ((ComplexAPFloat*)(void*)Data) ComplexAPFloat();
Kind = ComplexFloat;
}
+ void MakeLValue() {
+ assert(isUninit() && "Bad state change");
+ new ((LV*)(void*)Data) LV();
+ Kind = LValue;
+ }
};
}
More information about the cfe-commits
mailing list