forked from OSchip/llvm-project
Fixed few warnings; trimmed empty lines.
llvm-svn: 160159
This commit is contained in:
parent
96816e4848
commit
fc25990582
|
@ -2213,27 +2213,33 @@ void ConstantDataSequential::destroyConstant() {
|
||||||
/// can return a ConstantAggregateZero object.
|
/// can return a ConstantAggregateZero object.
|
||||||
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint8_t> Elts) {
|
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint8_t> Elts) {
|
||||||
Type *Ty = ArrayType::get(Type::getInt8Ty(Context), Elts.size());
|
Type *Ty = ArrayType::get(Type::getInt8Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*1), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*1), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint16_t> Elts){
|
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint16_t> Elts){
|
||||||
Type *Ty = ArrayType::get(Type::getInt16Ty(Context), Elts.size());
|
Type *Ty = ArrayType::get(Type::getInt16Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*2), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*2), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint32_t> Elts){
|
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint32_t> Elts){
|
||||||
Type *Ty = ArrayType::get(Type::getInt32Ty(Context), Elts.size());
|
Type *Ty = ArrayType::get(Type::getInt32Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*4), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*4), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint64_t> Elts){
|
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<uint64_t> Elts){
|
||||||
Type *Ty = ArrayType::get(Type::getInt64Ty(Context), Elts.size());
|
Type *Ty = ArrayType::get(Type::getInt64Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*8), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*8), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<float> Elts) {
|
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<float> Elts) {
|
||||||
Type *Ty = ArrayType::get(Type::getFloatTy(Context), Elts.size());
|
Type *Ty = ArrayType::get(Type::getFloatTy(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*4), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*4), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<double> Elts) {
|
Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<double> Elts) {
|
||||||
Type *Ty = ArrayType::get(Type::getDoubleTy(Context), Elts.size());
|
Type *Ty = ArrayType::get(Type::getDoubleTy(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*8), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*8), Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getString - This method constructs a CDS and initializes it with a text
|
/// getString - This method constructs a CDS and initializes it with a text
|
||||||
|
@ -2243,8 +2249,11 @@ Constant *ConstantDataArray::get(LLVMContext &Context, ArrayRef<double> Elts) {
|
||||||
/// to disable this behavior.
|
/// to disable this behavior.
|
||||||
Constant *ConstantDataArray::getString(LLVMContext &Context,
|
Constant *ConstantDataArray::getString(LLVMContext &Context,
|
||||||
StringRef Str, bool AddNull) {
|
StringRef Str, bool AddNull) {
|
||||||
if (!AddNull)
|
if (!AddNull) {
|
||||||
return get(Context, ArrayRef<uint8_t>((uint8_t*)Str.data(), Str.size()));
|
const uint8_t *Data = reinterpret_cast<const uint8_t *>(Str.data());
|
||||||
|
return get(Context, ArrayRef<uint8_t>(const_cast<uint8_t *>(Data),
|
||||||
|
Str.size()));
|
||||||
|
}
|
||||||
|
|
||||||
SmallVector<uint8_t, 64> ElementVals;
|
SmallVector<uint8_t, 64> ElementVals;
|
||||||
ElementVals.append(Str.begin(), Str.end());
|
ElementVals.append(Str.begin(), Str.end());
|
||||||
|
@ -2257,27 +2266,33 @@ Constant *ConstantDataArray::getString(LLVMContext &Context,
|
||||||
/// can return a ConstantAggregateZero object.
|
/// can return a ConstantAggregateZero object.
|
||||||
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint8_t> Elts){
|
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint8_t> Elts){
|
||||||
Type *Ty = VectorType::get(Type::getInt8Ty(Context), Elts.size());
|
Type *Ty = VectorType::get(Type::getInt8Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*1), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*1), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint16_t> Elts){
|
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint16_t> Elts){
|
||||||
Type *Ty = VectorType::get(Type::getInt16Ty(Context), Elts.size());
|
Type *Ty = VectorType::get(Type::getInt16Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*2), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*2), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint32_t> Elts){
|
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint32_t> Elts){
|
||||||
Type *Ty = VectorType::get(Type::getInt32Ty(Context), Elts.size());
|
Type *Ty = VectorType::get(Type::getInt32Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*4), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*4), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint64_t> Elts){
|
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<uint64_t> Elts){
|
||||||
Type *Ty = VectorType::get(Type::getInt64Ty(Context), Elts.size());
|
Type *Ty = VectorType::get(Type::getInt64Ty(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*8), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*8), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<float> Elts) {
|
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<float> Elts) {
|
||||||
Type *Ty = VectorType::get(Type::getFloatTy(Context), Elts.size());
|
Type *Ty = VectorType::get(Type::getFloatTy(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*4), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*4), Ty);
|
||||||
}
|
}
|
||||||
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<double> Elts) {
|
Constant *ConstantDataVector::get(LLVMContext &Context, ArrayRef<double> Elts) {
|
||||||
Type *Ty = VectorType::get(Type::getDoubleTy(Context), Elts.size());
|
Type *Ty = VectorType::get(Type::getDoubleTy(Context), Elts.size());
|
||||||
return getImpl(StringRef((char*)Elts.data(), Elts.size()*8), Ty);
|
const char *Data = reinterpret_cast<const char *>(Elts.data());
|
||||||
|
return getImpl(StringRef(const_cast<char *>(Data), Elts.size()*8), Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *ConstantDataVector::getSplat(unsigned NumElts, Constant *V) {
|
Constant *ConstantDataVector::getSplat(unsigned NumElts, Constant *V) {
|
||||||
|
@ -2327,10 +2342,14 @@ uint64_t ConstantDataSequential::getElementAsInteger(unsigned Elt) const {
|
||||||
// type to load with the right endianness.
|
// type to load with the right endianness.
|
||||||
switch (getElementType()->getIntegerBitWidth()) {
|
switch (getElementType()->getIntegerBitWidth()) {
|
||||||
default: llvm_unreachable("Invalid bitwidth for CDS");
|
default: llvm_unreachable("Invalid bitwidth for CDS");
|
||||||
case 8: return *(uint8_t*)EltPtr;
|
case 8:
|
||||||
case 16: return *(uint16_t*)EltPtr;
|
return *const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(EltPtr));
|
||||||
case 32: return *(uint32_t*)EltPtr;
|
case 16:
|
||||||
case 64: return *(uint64_t*)EltPtr;
|
return *const_cast<uint16_t *>(reinterpret_cast<const uint16_t *>(EltPtr));
|
||||||
|
case 32:
|
||||||
|
return *const_cast<uint32_t *>(reinterpret_cast<const uint32_t *>(EltPtr));
|
||||||
|
case 64:
|
||||||
|
return *const_cast<uint64_t *>(reinterpret_cast<const uint64_t *>(EltPtr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2342,8 +2361,14 @@ APFloat ConstantDataSequential::getElementAsAPFloat(unsigned Elt) const {
|
||||||
switch (getElementType()->getTypeID()) {
|
switch (getElementType()->getTypeID()) {
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Accessor can only be used when element is float/double!");
|
llvm_unreachable("Accessor can only be used when element is float/double!");
|
||||||
case Type::FloatTyID: return APFloat(*(float*)EltPtr);
|
case Type::FloatTyID: {
|
||||||
case Type::DoubleTyID: return APFloat(*(double*)EltPtr);
|
const float *FloatPrt = reinterpret_cast<const float *>(EltPtr);
|
||||||
|
return APFloat(*const_cast<float *>(FloatPrt));
|
||||||
|
}
|
||||||
|
case Type::DoubleTyID: {
|
||||||
|
const double *DoublePtr = reinterpret_cast<const double *>(EltPtr);
|
||||||
|
return APFloat(*const_cast<double *>(DoublePtr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2352,7 +2377,8 @@ APFloat ConstantDataSequential::getElementAsAPFloat(unsigned Elt) const {
|
||||||
float ConstantDataSequential::getElementAsFloat(unsigned Elt) const {
|
float ConstantDataSequential::getElementAsFloat(unsigned Elt) const {
|
||||||
assert(getElementType()->isFloatTy() &&
|
assert(getElementType()->isFloatTy() &&
|
||||||
"Accessor can only be used when element is a 'float'");
|
"Accessor can only be used when element is a 'float'");
|
||||||
return *(float*)getElementPointer(Elt);
|
const float *EltPtr = reinterpret_cast<const float *>(getElementPointer(Elt));
|
||||||
|
return *const_cast<float *>(EltPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getElementAsDouble - If this is an sequential container of doubles, return
|
/// getElementAsDouble - If this is an sequential container of doubles, return
|
||||||
|
@ -2360,7 +2386,9 @@ float ConstantDataSequential::getElementAsFloat(unsigned Elt) const {
|
||||||
double ConstantDataSequential::getElementAsDouble(unsigned Elt) const {
|
double ConstantDataSequential::getElementAsDouble(unsigned Elt) const {
|
||||||
assert(getElementType()->isDoubleTy() &&
|
assert(getElementType()->isDoubleTy() &&
|
||||||
"Accessor can only be used when element is a 'float'");
|
"Accessor can only be used when element is a 'float'");
|
||||||
return *(double*)getElementPointer(Elt);
|
const double *EltPtr =
|
||||||
|
reinterpret_cast<const double *>(getElementPointer(Elt));
|
||||||
|
return *const_cast<double *>(EltPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getElementAsConstant - Return a Constant for a specified index's element.
|
/// getElementAsConstant - Return a Constant for a specified index's element.
|
||||||
|
|
Loading…
Reference in New Issue