[llvm-commits] [dragonegg] r150486 - /dragonegg/trunk/src/Constants.cpp
Duncan Sands
baldrick at free.fr
Tue Feb 14 07:52:20 PST 2012
Author: baldrick
Date: Tue Feb 14 09:52:20 2012
New Revision: 150486
URL: http://llvm.org/viewvc/llvm-project?rev=150486&view=rev
Log:
Make some more safe implicit type conversions explicit.
Modified:
dragonegg/trunk/src/Constants.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=150486&r1=150485&r2=150486&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Tue Feb 14 09:52:20 2012
@@ -128,7 +128,7 @@
/// getBitWidth - Return the number of bits in the range.
unsigned getBitWidth() const {
- return R.getWidth();
+ return (unsigned)R.getWidth();
}
/// getRange - Return the range of bits in this slice.
@@ -165,15 +165,15 @@
if (R == r)
return *this;
assert(!r.empty() && "Empty ranges did not evaluate as equal?");
- Type *ExtTy = IntegerType::get(Context, r.getWidth());
+ Type *ExtTy = IntegerType::get(Context, (unsigned)r.getWidth());
// If the slice contains no bits then every bit of the extension is zero.
if (empty())
return BitSlice(r, Constant::getNullValue(ExtTy));
// Extend the contents to the new type.
Constant *C = Folder.CreateZExtOrBitCast(Contents, ExtTy);
// Position the old contents correctly inside the new contents.
- unsigned deltaFirst = R.getFirst() - r.getFirst();
- unsigned deltaLast = r.getLast() - R.getLast();
+ unsigned deltaFirst = (unsigned)(R.getFirst() - r.getFirst());
+ unsigned deltaLast = (unsigned)(r.getLast() - R.getLast());
if (BYTES_BIG_ENDIAN && deltaLast) {
(void)deltaFirst; // Avoid unused variable warning.
Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaLast);
@@ -198,7 +198,7 @@
// Quick exit if the desired range matches that of the slice.
if (R == r)
return Contents;
- Type *RetTy = IntegerType::get(Context, r.getWidth());
+ Type *RetTy = IntegerType::get(Context, (unsigned)r.getWidth());
// If the slice contains no bits then every returned bit is undefined.
if (empty())
return UndefValue::get(RetTy);
@@ -247,8 +247,8 @@
assert(!R.empty() && "Empty ranges did not evaluate as equal?");
// Move the least-significant bit to the correct position.
Constant *C = Contents;
- unsigned deltaFirst = r.getFirst() - R.getFirst();
- unsigned deltaLast = R.getLast() - r.getLast();
+ unsigned deltaFirst = (unsigned)(r.getFirst() - R.getFirst());
+ unsigned deltaLast = (unsigned)(R.getLast() - r.getLast());
if (BYTES_BIG_ENDIAN && deltaLast) {
(void)deltaFirst; // Avoid unused variable warning.
Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaLast);
@@ -259,7 +259,7 @@
C = Folder.CreateLShr(C, ShiftAmt);
}
// Truncate to the new type.
- Type *RedTy = IntegerType::get(Context, r.getWidth());
+ Type *RedTy = IntegerType::get(Context, (unsigned)r.getWidth());
C = Folder.CreateTruncOrBitCast(C, RedTy);
return BitSlice(r, C);
}
More information about the llvm-commits
mailing list