[cfe-commits] r53467 - in /cfe/trunk: include/clang/AST/APValue.h lib/AST/ExprConstant.cpp lib/Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Fri Jul 11 12:19:21 PDT 2008
Author: lattner
Date: Fri Jul 11 14:19:21 2008
New Revision: 53467
URL: http://llvm.org/viewvc/llvm-project?rev=53467&view=rev
Log:
rename "SInt" methods to "Int" in APValue.
Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/AST/APValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=53467&r1=53466&r2=53467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Fri Jul 11 14:19:21 2008
@@ -28,9 +28,9 @@
public:
enum ValueKind {
Uninitialized,
- SInt,
+ Int,
Float,
- ComplexSInt,
+ ComplexInt,
ComplexFloat,
LValue
};
@@ -63,13 +63,13 @@
public:
APValue() : Kind(Uninitialized) {}
explicit APValue(const APSInt &I) : Kind(Uninitialized) {
- MakeSInt(); setSInt(I);
+ MakeInt(); setInt(I);
}
explicit APValue(const APFloat &F) : Kind(Uninitialized) {
MakeFloat(); setFloat(F);
}
APValue(const APSInt &R, const APSInt &I) : Kind(Uninitialized) {
- MakeComplexSInt(); setComplexSInt(R, I);
+ MakeComplexInt(); setComplexInt(R, I);
}
APValue(const APFloat &R, const APFloat &I) : Kind(Uninitialized) {
MakeComplexFloat(); setComplexFloat(R, I);
@@ -86,18 +86,18 @@
ValueKind getKind() const { return Kind; }
bool isUninit() const { return Kind == Uninitialized; }
- bool isSInt() const { return Kind == SInt; }
+ bool isInt() const { return Kind == Int; }
bool isFloat() const { return Kind == Float; }
- bool isComplexSInt() const { return Kind == ComplexSInt; }
+ bool isComplexInt() const { return Kind == ComplexInt; }
bool isComplexFloat() const { return Kind == ComplexFloat; }
bool isLValue() const { return Kind == LValue; }
- APSInt &getSInt() {
- assert(isSInt() && "Invalid accessor");
+ APSInt &getInt() {
+ assert(isInt() && "Invalid accessor");
return *(APSInt*)(void*)Data;
}
- const APSInt &getSInt() const {
- return const_cast<APValue*>(this)->getSInt();
+ const APSInt &getInt() const {
+ return const_cast<APValue*>(this)->getInt();
}
APFloat &getFloat() {
@@ -108,20 +108,20 @@
return const_cast<APValue*>(this)->getFloat();
}
- APSInt &getComplexSIntReal() {
- assert(isComplexSInt() && "Invalid accessor");
+ APSInt &getComplexIntReal() {
+ assert(isComplexInt() && "Invalid accessor");
return ((ComplexAPSInt*)(void*)Data)->Real;
}
- const APSInt &getComplexSIntReal() const {
- return const_cast<APValue*>(this)->getComplexSIntReal();
+ const APSInt &getComplexIntReal() const {
+ return const_cast<APValue*>(this)->getComplexIntReal();
}
- APSInt &getComplexSIntImag() {
- assert(isComplexSInt() && "Invalid accessor");
+ APSInt &getComplexIntImag() {
+ assert(isComplexInt() && "Invalid accessor");
return ((ComplexAPSInt*)(void*)Data)->Imag;
}
- const APSInt &getComplexSIntImag() const {
- return const_cast<APValue*>(this)->getComplexSIntImag();
+ const APSInt &getComplexIntImag() const {
+ return const_cast<APValue*>(this)->getComplexIntImag();
}
APFloat &getComplexFloatReal() {
@@ -149,16 +149,16 @@
return ((const LV*)(const void*)Data)->Offset;
}
- void setSInt(const APSInt &I) {
- assert(isSInt() && "Invalid accessor");
+ void setInt(const APSInt &I) {
+ assert(isInt() && "Invalid accessor");
*(APSInt*)(void*)Data = I;
}
void setFloat(const APFloat &F) {
assert(isFloat() && "Invalid accessor");
*(APFloat*)(void*)Data = F;
}
- void setComplexSInt(const APSInt &R, const APSInt &I) {
- assert(isComplexSInt() && "Invalid accessor");
+ void setComplexInt(const APSInt &R, const APSInt &I) {
+ assert(isComplexInt() && "Invalid accessor");
((ComplexAPSInt*)(void*)Data)->Real = R;
((ComplexAPSInt*)(void*)Data)->Imag = I;
}
@@ -176,23 +176,23 @@
const APValue &operator=(const APValue &RHS) {
if (Kind != RHS.Kind) {
MakeUninit();
- if (RHS.isSInt())
- MakeSInt();
+ if (RHS.isInt())
+ MakeInt();
else if (RHS.isFloat())
MakeFloat();
- else if (RHS.isComplexSInt())
- MakeComplexSInt();
+ else if (RHS.isComplexInt())
+ MakeComplexInt();
else if (RHS.isComplexFloat())
MakeComplexFloat();
else if (RHS.isLValue())
MakeLValue();
}
- if (isSInt())
- setSInt(RHS.getSInt());
+ if (isInt())
+ setInt(RHS.getInt());
else if (isFloat())
setFloat(RHS.getFloat());
- else if (isComplexSInt())
- setComplexSInt(RHS.getComplexSIntReal(), RHS.getComplexSIntImag());
+ else if (isComplexInt())
+ setComplexInt(RHS.getComplexIntReal(), RHS.getComplexIntImag());
else if (isComplexFloat())
setComplexFloat(RHS.getComplexFloatReal(), RHS.getComplexFloatImag());
else if (isLValue())
@@ -202,11 +202,11 @@
private:
void MakeUninit() {
- if (Kind == SInt)
+ if (Kind == Int)
((APSInt*)(void*)Data)->~APSInt();
else if (Kind == Float)
((APFloat*)(void*)Data)->~APFloat();
- else if (Kind == ComplexSInt)
+ else if (Kind == ComplexInt)
((ComplexAPSInt*)(void*)Data)->~ComplexAPSInt();
else if (Kind == ComplexFloat)
((ComplexAPFloat*)(void*)Data)->~ComplexAPFloat();
@@ -214,20 +214,20 @@
((LV*)(void*)Data)->~LV();
}
}
- void MakeSInt() {
+ void MakeInt() {
assert(isUninit() && "Bad state change");
new ((void*)Data) APSInt(1);
- Kind = SInt;
+ Kind = Int;
}
void MakeFloat() {
assert(isUninit() && "Bad state change");
new ((APFloat*)(void*)Data) APFloat(0.0);
Kind = Float;
}
- void MakeComplexSInt() {
+ void MakeComplexInt() {
assert(isUninit() && "Bad state change");
new ((ComplexAPSInt*)(void*)Data) ComplexAPSInt();
- Kind = ComplexSInt;
+ Kind = ComplexInt;
}
void MakeComplexFloat() {
assert(isUninit() && "Bad state change");
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=53467&r1=53466&r2=53467&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jul 11 14:19:21 2008
@@ -386,9 +386,9 @@
//===----------------------------------------------------------------------===//
bool Expr::tryEvaluate(APValue &Result, ASTContext &Ctx) const {
+ llvm::APSInt sInt(32);
#if USE_NEW_EVALUATOR
if (getType()->isIntegerType()) {
- llvm::APSInt sInt(32);
if (EvaluateInteger(this, sInt, Ctx)) {
Result = APValue(sInt);
return true;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=53467&r1=53466&r2=53467&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jul 11 14:19:21 2008
@@ -1814,12 +1814,11 @@
if (const VariableArrayType* VLATy = dyn_cast<VariableArrayType>(T)) {
APValue Result;
if (VLATy->getSizeExpr() &&
- VLATy->getSizeExpr()->tryEvaluate(Result, Context) && Result.isSInt() &&
- Result.getSInt() > llvm::APSInt(Result.getSInt().getBitWidth(),
- Result.getSInt().isUnsigned())) {
- return Context.getConstantArrayType(VLATy->getElementType(),
- Result.getSInt(),
- ArrayType::Normal, 0);
+ VLATy->getSizeExpr()->tryEvaluate(Result, Context) && Result.isInt()) {
+ llvm::APSInt &Res = Result.getInt();
+ if (Res > llvm::APSInt(Res.getBitWidth(), Res.isUnsigned()))
+ return Context.getConstantArrayType(VLATy->getElementType(),
+ Res, ArrayType::Normal, 0);
}
}
return QualType();
More information about the cfe-commits
mailing list