aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-04-26 19:19:15 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-04-26 19:19:15 +0000
commit9a901bb63990574ff0bcc12ff851d7a71cff8ddb (patch)
treea90ae2d57be74b5e2ce39197f486e31172c46f3f
parent9ec64d6e2fe575b297e1eaa5051efc2983373e25 (diff)
Remove getIntegerConstantExprValue in favor of using EvaluateAsInt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70145 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h16
-rw-r--r--lib/AST/ASTContext.cpp5
-rw-r--r--lib/AST/Expr.cpp2
-rw-r--r--lib/CodeGen/CGBuiltin.cpp3
-rw-r--r--lib/CodeGen/CGCall.cpp3
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp8
-rw-r--r--lib/CodeGen/CGObjCMac.cpp4
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp2
-rw-r--r--lib/Sema/SemaDeclObjC.cpp4
9 files changed, 14 insertions, 33 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 122d9b9433..1366450b52 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -177,17 +177,6 @@ public:
bool isBitField();
- /// getIntegerConstantExprValue() - Return the value of an integer
- /// constant expression. The expression must be a valid integer
- /// constant expression as determined by isIntegerConstantExpr.
- llvm::APSInt getIntegerConstantExprValue(ASTContext &Ctx) const {
- llvm::APSInt X;
- bool success = isIntegerConstantExpr(X, Ctx);
- success = success;
- assert(success && "Illegal argument to getIntegerConstantExpr");
- return X;
- }
-
/// isIntegerConstantExpr - Return true if this expression is a valid integer
/// constant expression, and, if so, return its value in Result. If not a
/// valid i-c-e, return false and fill in Loc (if specified) with the location
@@ -195,9 +184,6 @@ public:
bool isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
SourceLocation *Loc = 0,
bool isEvaluated = true) const;
- bool isIntegerConstantExprInternal(llvm::APSInt &Result, ASTContext &Ctx,
- SourceLocation *Loc = 0,
- bool isEvaluated = true) const;
bool isIntegerConstantExpr(ASTContext &Ctx, SourceLocation *Loc = 0) const {
llvm::APSInt X;
return isIntegerConstantExpr(X, Ctx, Loc);
@@ -1722,7 +1708,7 @@ public:
unsigned getShuffleMaskIdx(ASTContext &Ctx, unsigned N) {
assert((N < NumExprs - 2) && "Shuffle idx out of range!");
- return getExpr(N+2)->getIntegerConstantExprValue(Ctx).getZExtValue();
+ return getExpr(N+2)->EvaluateAsInt(Ctx).getZExtValue();
}
// Iterators
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 95bb1ba04b..58fc42b036 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -549,8 +549,7 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo,
if (const Expr *BitWidthExpr = FD->getBitWidth()) {
// TODO: Need to check this algorithm on other targets!
// (tested on Linux-X86)
- FieldSize =
- BitWidthExpr->getIntegerConstantExprValue(Context).getZExtValue();
+ FieldSize = BitWidthExpr->EvaluateAsInt(Context).getZExtValue();
std::pair<uint64_t, unsigned> FieldInfo =
Context.getTypeInfo(FD->getType());
@@ -2263,7 +2262,7 @@ static void EncodeBitField(const ASTContext *Context, std::string& S,
const Expr *E = FD->getBitWidth();
assert(E && "bitfield width not there - getObjCEncodingForTypeImpl");
ASTContext *Ctx = const_cast<ASTContext*>(Context);
- unsigned N = E->getIntegerConstantExprValue(*Ctx).getZExtValue();
+ unsigned N = E->EvaluateAsInt(*Ctx).getZExtValue();
S += 'b';
S += llvm::utostr(N);
}
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 053117d35b..acf119ab79 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1536,7 +1536,7 @@ void ObjCMessageExpr::setClassInfo(const ObjCMessageExpr::ClassInfo &CI) {
bool ChooseExpr::isConditionTrue(ASTContext &C) const {
- return getCond()->getIntegerConstantExprValue(C) != 0;
+ return getCond()->EvaluateAsInt(C) != 0;
}
void ShuffleVectorExpr::setExprs(Expr ** Exprs, unsigned NumExprs) {
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index e7adf72190..2b9a17845d 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -196,8 +196,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_object_size: {
// FIXME: Implement. For now we just always fail and pretend we
// don't know the object size.
- llvm::APSInt TypeArg =
- E->getArg(1)->getIntegerConstantExprValue(CGM.getContext());
+ llvm::APSInt TypeArg = E->getArg(1)->EvaluateAsInt(CGM.getContext());
const llvm::Type *ResType = ConvertType(E->getType());
// bool UseSubObject = TypeArg.getZExtValue() & 1;
bool UseMinimum = TypeArg.getZExtValue() & 2;
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 5427466cdf..41d4d7c90b 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -785,8 +785,7 @@ void X86_64ABIInfo::classify(QualType Ty,
// therefore they can straddle an eightbyte.
if (BitField) {
uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);
- uint64_t Size =
- i->getBitWidth()->getIntegerConstantExprValue(Context).getZExtValue();
+ uint64_t Size = i->getBitWidth()->EvaluateAsInt(Context).getZExtValue();
uint64_t EB_Lo = Offset / 64;
uint64_t EB_Hi = (Offset + Size - 1) / 64;
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index a652ede1c1..eeaa197cf3 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -320,8 +320,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
FieldSize = M->getContext().getTypeSize(FType);
Expr *BitWidth = Field->getBitWidth();
if (BitWidth)
- FieldSize =
- BitWidth->getIntegerConstantExprValue(M->getContext()).getZExtValue();
+ FieldSize = BitWidth->EvaluateAsInt(M->getContext()).getZExtValue();
FieldAlign = M->getContext().getTypeAlign(FType);
}
@@ -432,9 +431,8 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
FieldSize = M->getContext().getTypeSize(FType);
Expr *BitWidth = Field->getBitWidth();
if (BitWidth)
- FieldSize =
- BitWidth->getIntegerConstantExprValue(M->getContext()).getZExtValue();
-
+ FieldSize = BitWidth->EvaluateAsInt(M->getContext()).getZExtValue();
+
FieldAlign = M->getContext().getTypeAlign(FType);
}
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index faab3cfe10..ae3c267190 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -3085,7 +3085,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
LastFieldBitfield);
Expr *BitWidth = LastFieldBitfield->getBitWidth();
uint64_t BitFieldSize =
- BitWidth->getIntegerConstantExprValue(CGM.getContext()).getZExtValue();
+ BitWidth->EvaluateAsInt(CGM.getContext()).getZExtValue();
skivar.ivar_size = (BitFieldSize / ByteSizeInBits)
+ ((BitFieldSize % ByteSizeInBits) != 0);
SkipIvars.push_back(skivar);
@@ -4293,7 +4293,7 @@ void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCInterfaceDecl *OID,
if (Last->isBitField()) {
Expr *BitWidth = Last->getBitWidth();
uint64_t BitFieldSize =
- BitWidth->getIntegerConstantExprValue(CGM.getContext()).getZExtValue();
+ BitWidth->EvaluateAsInt(CGM.getContext()).getZExtValue();
Size = (BitFieldSize / 8) + ((BitFieldSize % 8) != 0);
}
#endif
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 79aa705971..f0bc6f6961 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -577,7 +577,7 @@ void RecordOrganizer::layoutUnionFields(const ASTRecordLayout &RL) {
if (Field->isBitField()) {
Expr *BitWidth = Field->getBitWidth();
uint64_t BitFieldSize =
- BitWidth->getIntegerConstantExprValue(CGT.getContext()).getZExtValue();
+ BitWidth->EvaluateAsInt(CGT.getContext()).getZExtValue();
CGT.addFieldInfo(*Field, 0);
CGT.addBitFieldInfo(*Field, offset, BitFieldSize);
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 968fddd1af..da50573f23 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -722,8 +722,8 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
} else if (ImplIvar->isBitField() && ClsIvar->isBitField()) {
Expr *ImplBitWidth = ImplIvar->getBitWidth();
Expr *ClsBitWidth = ClsIvar->getBitWidth();
- if (ImplBitWidth->getIntegerConstantExprValue(Context).getZExtValue() !=
- ClsBitWidth->getIntegerConstantExprValue(Context).getZExtValue()) {
+ if (ImplBitWidth->EvaluateAsInt(Context).getZExtValue() !=
+ ClsBitWidth->EvaluateAsInt(Context).getZExtValue()) {
Diag(ImplBitWidth->getLocStart(), diag::err_conflicting_ivar_bitwidth)
<< ImplIvar->getIdentifier();
Diag(ClsBitWidth->getLocStart(), diag::note_previous_definition);