summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Support/Casting.h5
-rw-r--r--include/Support/CommandLine.h17
-rw-r--r--include/Support/GraphWriter.h9
-rw-r--r--include/Support/HashExtras.h4
-rw-r--r--include/Support/MallocAllocator.h6
-rw-r--r--include/Support/MathExtras.h2
-rw-r--r--include/Support/StringExtras.h10
-rw-r--r--include/llvm/ADT/HashExtras.h4
-rw-r--r--include/llvm/ADT/StringExtras.h10
-rw-r--r--include/llvm/ConstantHandling.h5
-rw-r--r--include/llvm/Constants.h9
-rw-r--r--include/llvm/GlobalValue.h2
-rw-r--r--include/llvm/GlobalVariable.h6
-rw-r--r--include/llvm/InstrTypes.h5
-rw-r--r--include/llvm/PassSupport.h5
-rw-r--r--include/llvm/Support/Casting.h5
-rw-r--r--include/llvm/Support/CommandLine.h17
-rw-r--r--include/llvm/Support/GraphWriter.h9
-rw-r--r--include/llvm/Support/MallocAllocator.h6
-rw-r--r--include/llvm/Support/MathExtras.h2
-rw-r--r--include/llvm/Use.h4
-rw-r--r--include/llvm/User.h4
-rw-r--r--include/llvm/iMemory.h6
-rw-r--r--include/llvm/iOther.h4
-rw-r--r--include/llvm/iPHINode.h6
-rw-r--r--include/llvm/iTerminators.h17
-rw-r--r--lib/VMCore/ConstantFold.h5
-rw-r--r--lib/VMCore/ConstantFolding.h5
28 files changed, 108 insertions, 81 deletions
diff --git a/include/Support/Casting.h b/include/Support/Casting.h
index 4b070c18d8..abc80aac7a 100644
--- a/include/Support/Casting.h
+++ b/include/Support/Casting.h
@@ -37,7 +37,7 @@ template<typename From> struct simplify_type {
template<typename From> struct simplify_type<const From> {
typedef const From SimpleType;
static SimpleType &getSimplifiedValue(const From &Val) {
- return simplify_type<From>::getSimplifiedValue((From&)Val);
+ return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
}
};
@@ -178,7 +178,8 @@ template<class To, class From, class SimpleFrom> struct cast_convert_val {
template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
// This _is_ a simple type, just cast it.
static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) {
- return (typename cast_retty<To, FromTy>::ret_type)Val;
+ return reinterpret_cast<typename cast_retty<To, FromTy>::ret_type>(
+ const_cast<FromTy&>(Val));
}
};
diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h
index df40d80070..0a3cb6f320 100644
--- a/include/Support/CommandLine.h
+++ b/include/Support/CommandLine.h
@@ -148,19 +148,23 @@ public:
inline enum NumOccurrences getNumOccurrencesFlag() const {
int NO = Flags & OccurrencesMask;
- return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault();
+ return NO ? static_cast<enum NumOccurrences>(NO)
+ : getNumOccurrencesFlagDefault();
}
inline enum ValueExpected getValueExpectedFlag() const {
int VE = Flags & ValueMask;
- return VE ? (enum ValueExpected)VE : getValueExpectedFlagDefault();
+ return VE ? static_cast<enum ValueExpected>(VE)
+ : getValueExpectedFlagDefault();
}
inline enum OptionHidden getOptionHiddenFlag() const {
int OH = Flags & HiddenMask;
- return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault();
+ return OH ? static_cast<enum OptionHidden>(OH)
+ : getOptionHiddenFlagDefault();
}
inline enum FormattingFlags getFormattingFlag() const {
int OH = Flags & FormattingMask;
- return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault();
+ return OH ? static_cast<enum FormattingFlags>(OH)
+ : getFormattingFlagDefault();
}
inline unsigned getMiscFlags() const {
return Flags & MiscMask;
@@ -307,7 +311,7 @@ public:
// Process the varargs portion of the values...
while (const char *EnumName = va_arg(ValueArgs, const char *)) {
- DataType EnumVal = (DataType)va_arg(ValueArgs, int);
+ DataType EnumVal = static_cast<DataType>(va_arg(ValueArgs, int));
const char *EnumDesc = va_arg(ValueArgs, const char *);
Values.push_back(std::make_pair(EnumName, // Add value to value map
std::make_pair(EnumVal, EnumDesc)));
@@ -452,7 +456,8 @@ public:
template <class DT>
void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) {
assert(findOption(Name) == Values.size() && "Option already exists!");
- Values.push_back(std::make_pair(Name, std::make_pair((DataType)V,HelpStr)));
+ Values.push_back(std::make_pair(Name,
+ std::make_pair(static_cast<DataType>(V),HelpStr)));
}
// removeLiteralOption - Remove the specified option.
diff --git a/include/Support/GraphWriter.h b/include/Support/GraphWriter.h
index 7e5aa80645..0eace78d73 100644
--- a/include/Support/GraphWriter.h
+++ b/include/Support/GraphWriter.h
@@ -100,7 +100,7 @@ public:
void writeNode(NodeType *Node) {
std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
- O << "\tNode" << (void*)Node << " [shape=record,";
+ O << "\tNode" << reinterpret_cast<const void*>(Node) << " [shape=record,";
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
O << "label=\"{"
<< DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
@@ -137,10 +137,11 @@ public:
// Figure out which edge this targets...
unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
TargetIt);
- DestPort = (int)Offset;
+ DestPort = static_cast<int>(Offset);
}
- emitEdge((void *)Node, edgeidx, (void*)TargetNode, DestPort,
+ emitEdge(reinterpret_cast<const void*>(Node), edgeidx,
+ reinterpret_cast<const void*>(TargetNode), DestPort,
DOTTraits::getEdgeAttributes(Node, EI));
}
}
@@ -178,7 +179,7 @@ public:
O << "\tNode" << SrcNodeID;
if (SrcNodePort >= 0)
O << ":g" << SrcNodePort;
- O << " -> Node" << (void*)DestNodeID;
+ O << " -> Node" << reinterpret_cast<const void*>(DestNodeID);
if (DestNodePort >= 0)
O << ":g" << DestNodePort;
diff --git a/include/Support/HashExtras.h b/include/Support/HashExtras.h
index 871080c467..67f65b5f3a 100644
--- a/include/Support/HashExtras.h
+++ b/include/Support/HashExtras.h
@@ -31,7 +31,9 @@ template <> struct hash<std::string> {
// Provide a hash function for arbitrary pointers...
template <class T> struct hash<T *> {
- inline size_t operator()(const T *Val) const { return (size_t)Val; }
+ inline size_t operator()(const T *Val) const {
+ return reinterpret_cast<size_t>(Val);
+ }
};
} // End namespace std
diff --git a/include/Support/MallocAllocator.h b/include/Support/MallocAllocator.h
index 022953df93..3e3da4139c 100644
--- a/include/Support/MallocAllocator.h
+++ b/include/Support/MallocAllocator.h
@@ -47,15 +47,15 @@ struct MallocAllocator {
size_type max_size() const { return ~0 / sizeof(T); }
static pointer allocate(size_t n, void* hint = 0) {
- return (pointer)malloc(n*sizeof(T));
+ return static_cast<pointer>(malloc(n*sizeof(T)));
}
static void deallocate(pointer p, size_t n) {
- free((void*)p);
+ free(static_cast<void*>(p));
}
void construct(pointer p, const T &val) {
- new((void*)p) T(val);
+ new(static_cast<void*>(p)) T(val);
}
void destroy(pointer p) {
p->~T();
diff --git a/include/Support/MathExtras.h b/include/Support/MathExtras.h
index 74958fbc35..125aff3b9f 100644
--- a/include/Support/MathExtras.h
+++ b/include/Support/MathExtras.h
@@ -28,7 +28,7 @@ inline unsigned log2(uint64_t C) {
inline bool isPowerOf2(int64_t C, unsigned &getPow) {
if (C < 0) C = -C;
if (C > 0 && C == (C & ~(C - 1))) {
- getPow = log2((uint64_t)C);
+ getPow = log2(static_cast<uint64_t>(C));
return true;
}
diff --git a/include/Support/StringExtras.h b/include/Support/StringExtras.h
index 2ebac81935..08e5eb7e04 100644
--- a/include/Support/StringExtras.h
+++ b/include/Support/StringExtras.h
@@ -57,14 +57,14 @@ static inline std::string utostr(unsigned long long X, bool isNeg = false) {
static inline std::string itostr(int64_t X) {
if (X < 0)
- return utostr((uint64_t)-X, true);
+ return utostr(static_cast<uint64_t>(-X), true);
else
- return utostr((uint64_t)X);
+ return utostr(static_cast<uint64_t>(X));
}
static inline std::string utostr(unsigned long X, bool isNeg = false) {
- return utostr((unsigned long long)X, isNeg);
+ return utostr(static_cast<unsigned long long>(X), isNeg);
}
static inline std::string utostr(unsigned X, bool isNeg = false) {
@@ -86,9 +86,9 @@ static inline std::string utostr(unsigned X, bool isNeg = false) {
static inline std::string itostr(int X) {
if (X < 0)
- return utostr((unsigned)-X, true);
+ return utostr(static_cast<unsigned>(-X), true);
else
- return utostr((unsigned)X);
+ return utostr(static_cast<unsigned>(X));
}
static inline std::string ftostr(double V) {
diff --git a/include/llvm/ADT/HashExtras.h b/include/llvm/ADT/HashExtras.h
index 871080c467..67f65b5f3a 100644
--- a/include/llvm/ADT/HashExtras.h
+++ b/include/llvm/ADT/HashExtras.h
@@ -31,7 +31,9 @@ template <> struct hash<std::string> {
// Provide a hash function for arbitrary pointers...
template <class T> struct hash<T *> {
- inline size_t operator()(const T *Val) const { return (size_t)Val; }
+ inline size_t operator()(const T *Val) const {
+ return reinterpret_cast<size_t>(Val);
+ }
};
} // End namespace std
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h
index 2ebac81935..08e5eb7e04 100644
--- a/include/llvm/ADT/StringExtras.h
+++ b/include/llvm/ADT/StringExtras.h
@@ -57,14 +57,14 @@ static inline std::string utostr(unsigned long long X, bool isNeg = false) {
static inline std::string itostr(int64_t X) {
if (X < 0)
- return utostr((uint64_t)-X, true);
+ return utostr(static_cast<uint64_t>(-X), true);
else
- return utostr((uint64_t)X);
+ return utostr(static_cast<uint64_t>(X));
}
static inline std::string utostr(unsigned long X, bool isNeg = false) {
- return utostr((unsigned long long)X, isNeg);
+ return utostr(static_cast<unsigned long long>(X), isNeg);
}
static inline std::string utostr(unsigned X, bool isNeg = false) {
@@ -86,9 +86,9 @@ static inline std::string utostr(unsigned X, bool isNeg = false) {
static inline std::string itostr(int X) {
if (X < 0)
- return utostr((unsigned)-X, true);
+ return utostr(static_cast<unsigned>(-X), true);
else
- return utostr((unsigned)X);
+ return utostr(static_cast<unsigned>(X));
}
static inline std::string ftostr(double V) {
diff --git a/include/llvm/ConstantHandling.h b/include/llvm/ConstantHandling.h
index a0a01e5306..b392ad1173 100644
--- a/include/llvm/ConstantHandling.h
+++ b/include/llvm/ConstantHandling.h
@@ -113,7 +113,8 @@ public:
case Type::LongTyID: return castToLong(V);
case Type::FloatTyID: return castToFloat(V);
case Type::DoubleTyID: return castToDouble(V);
- case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+ case Type::PointerTyID:
+ return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
default: return 0;
}
}
@@ -125,7 +126,7 @@ public:
static inline ConstRules *get(const Constant &V1, const Constant &V2) {
if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
return getConstantExprRules();
- return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+ return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
}
private:
static ConstRules *getConstantExprRules();
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 5d65b2f0c7..06f1308fdf 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -301,7 +301,7 @@ public:
/// which reduces the amount of casting needed in parts of the compiler.
///
inline const ArrayType *getType() const {
- return (ArrayType*)Value::getType();
+ return reinterpret_cast<const ArrayType*>(Value::getType());
}
/// getAsString - If the sub-element type of this array is either sbyte or
@@ -354,7 +354,7 @@ public:
/// getType() specialization - Reduce amount of casting...
inline const StructType *getType() const {
- return (StructType*)Value::getType();
+ return reinterpret_cast<const StructType*>(Value::getType());
}
/// getValues - Return a vector of the component constants that make up this
@@ -394,10 +394,11 @@ public:
class ConstantPointer : public Constant {
ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT
protected:
- inline ConstantPointer(const PointerType *T) : Constant((const Type*)T) {}
+ inline ConstantPointer(const PointerType *T)
+ : Constant(reinterpret_cast<const Type*>(T)) { }
public:
inline const PointerType *getType() const {
- return (PointerType*)Value::getType();
+ return reinterpret_cast<const PointerType*>(Value::getType());
}
/// isNullValue - Return true if this is the value that would be returned by
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index 47a2189fa4..942d9b9a40 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -46,7 +46,7 @@ public:
/// getType - Global values are always pointers.
inline const PointerType *getType() const {
- return (const PointerType*)User::getType();
+ return reinterpret_cast<const PointerType*>(User::getType());
}
bool hasExternalLinkage() const { return Linkage == ExternalLinkage; }
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index 03c4f39120..b09bf40f05 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -70,18 +70,18 @@ public:
///
inline Constant *getInitializer() const {
assert(hasInitializer() && "GV doesn't have initializer!");
- return (Constant*)Operands[0].get();
+ return reinterpret_cast<Constant*>(Operands[0].get());
}
inline Constant *getInitializer() {
assert(hasInitializer() && "GV doesn't have initializer!");
- return (Constant*)Operands[0].get();
+ return reinterpret_cast<Constant*>(Operands[0].get());
}
inline void setInitializer(Constant *CPV) {
if (CPV == 0) {
if (hasInitializer()) Operands.pop_back();
} else {
if (!hasInitializer()) Operands.push_back(Use(0, this));
- Operands[0] = (Value*)CPV;
+ Operands[0] = reinterpret_cast<Value*>(CPV);
}
}
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 7938b483c7..70cb742d96 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -50,7 +50,8 @@ public:
virtual void setSuccessor(unsigned idx, BasicBlock *B) = 0;
inline BasicBlock *getSuccessor(unsigned idx) {
- return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx);
+ const TerminatorInst *TI = this;
+ return const_cast<BasicBlock*>(TI->getSuccessor(idx));
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -110,7 +111,7 @@ public:
static Value* getNotArgument( BinaryOperator* Bop);
BinaryOps getOpcode() const {
- return (BinaryOps)Instruction::getOpcode();
+ return static_cast<BinaryOps>(Instruction::getOpcode());
}
virtual Instruction *clone() const {
diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h
index d985bf121d..bc2b7da8a2 100644
--- a/include/llvm/PassSupport.h
+++ b/include/llvm/PassSupport.h
@@ -226,7 +226,8 @@ struct RegisterOpt : public RegisterPassBase {
RegisterOpt(const char *PassArg, const char *Name, FunctionPass *(*ctor)(),
bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
- PassInfo::Optimization, (Pass*(*)())ctor));
+ PassInfo::Optimization,
+ static_cast<Pass*(*)()>(ctor)));
if (CFGOnly) setOnlyUsesCFG();
}
@@ -246,7 +247,7 @@ struct RegisterOpt : public RegisterPassBase {
bool CFGOnly = false) {
registerPass(new PassInfo(Name, PassArg, typeid(PassName),
PassInfo::Optimization, 0,
- (Pass*(*)(TargetMachine&))targetctor));
+ static_cast<Pass*(*)(TargetMachine&)>(targetctor)));
if (CFGOnly) setOnlyUsesCFG();
}
};
diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h
index 4b070c18d8..abc80aac7a 100644
--- a/include/llvm/Support/Casting.h
+++ b/include/llvm/Support/Casting.h
@@ -37,7 +37,7 @@ template<typename From> struct simplify_type {
template<typename From> struct simplify_type<const From> {
typedef const From SimpleType;
static SimpleType &getSimplifiedValue(const From &Val) {
- return simplify_type<From>::getSimplifiedValue((From&)Val);
+ return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
}
};
@@ -178,7 +178,8 @@ template<class To, class From, class SimpleFrom> struct cast_convert_val {
template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
// This _is_ a simple type, just cast it.
static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) {
- return (typename cast_retty<To, FromTy>::ret_type)Val;
+ return reinterpret_cast<typename cast_retty<To, FromTy>::ret_type>(
+ const_cast<FromTy&>(Val));
}
};
diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h
index df40d80070..0a3cb6f320 100644
--- a/include/llvm/Support/CommandLine.h
+++ b/include/llvm/Support/CommandLine.h
@@ -148,19 +148,23 @@ public:
inline enum NumOccurrences getNumOccurrencesFlag() const {
int NO = Flags & OccurrencesMask;
- return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault();
+ return NO ? static_cast<enum NumOccurrences>(NO)
+ : getNumOccurrencesFlagDefault();
}
inline enum ValueExpected getValueExpectedFlag() const {
int VE = Flags & ValueMask;
- return VE ? (enum ValueExpected)VE : getValueExpectedFlagDefault();
+ return VE ? static_cast<enum ValueExpected>(VE)
+ : getValueExpectedFlagDefault();
}
inline enum OptionHidden getOptionHiddenFlag() const {
int OH = Flags & HiddenMask;
- return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault();
+ return OH ? static_cast<enum OptionHidden>(OH)
+ : getOptionHiddenFlagDefault();
}
inline enum FormattingFlags getFormattingFlag() const {
int OH = Flags & FormattingMask;
- return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault();
+ return OH ? static_cast<enum FormattingFlags>(OH)
+ : getFormattingFlagDefault();
}
inline unsigned getMiscFlags() const {
return Flags & MiscMask;
@@ -307,7 +311,7 @@ public:
// Process the varargs portion of the values...
while (const char *EnumName = va_arg(ValueArgs, const char *)) {
- DataType EnumVal = (DataType)va_arg(ValueArgs, int);
+ DataType EnumVal = static_cast<DataType>(va_arg(ValueArgs, int));
const char *EnumDesc = va_arg(ValueArgs, const char *);
Values.push_back(std::make_pair(EnumName, // Add value to value map
std::make_pair(EnumVal, EnumDesc)));
@@ -452,7 +456,8 @@ public:
template <class DT>
void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) {
assert(findOption(Name) == Values.size() && "Option already exists!");
- Values.push_back(std::make_pair(Name, std::make_pair((DataType)V,HelpStr)));
+ Values.push_back(std::make_pair(Name,
+ std::make_pair(static_cast<DataType>(V),HelpStr)));
}
// removeLiteralOption - Remove the specified option.
diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h
index 7e5aa80645..0eace78d73 100644
--- a/include/llvm/Support/GraphWriter.h
+++ b/include/llvm/Support/GraphWriter.h
@@ -100,7 +100,7 @@ public:
void writeNode(NodeType *Node) {
std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
- O << "\tNode" << (void*)Node << " [shape=record,";
+ O << "\tNode" << reinterpret_cast<const void*>(Node) << " [shape=record,";
if (!NodeAttributes.empty()) O << NodeAttributes << ",";
O << "label=\"{"
<< DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
@@ -137,10 +137,11 @@ public:
// Figure out which edge this targets...
unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
TargetIt);
- DestPort = (int)Offset;
+ DestPort = static_cast<int>(Offset);
}
- emitEdge((void *)Node, edgeidx, (void*)TargetNode, DestPort,
+ emitEdge(reinterpret_cast<const void*>(Node), edgeidx,
+ reinterpret_cast<const void*>(TargetNode), DestPort,
DOTTraits::getEdgeAttributes(Node, EI));
}
}
@@ -178,7 +179,7 @@ public:
O << "\tNode" << SrcNodeID;
if (SrcNodePort >= 0)
O << ":g" << SrcNodePort;
- O << " -> Node" << (void*)DestNodeID;
+ O << " -> Node" << reinterpret_cast<const void*>(DestNodeID);
if (DestNodePort >= 0)
O << ":g" << DestNodePort;
diff --git a/include/llvm/Support/MallocAllocator.h b/include/llvm/Support/MallocAllocator.h
index 022953df93..3e3da4139c 100644
--- a/include/llvm/Support/MallocAllocator.h
+++ b/include/llvm/Support/MallocAllocator.h
@@ -47,15 +47,15 @@ struct MallocAllocator {
size_type max_size() const { return ~0 / sizeof(T); }
static pointer allocate(size_t n, void* hint = 0) {
- return (pointer)malloc(n*sizeof(T));
+ return static_cast<pointer>(malloc(n*sizeof(T)));
}
static void deallocate(pointer p, size_t n) {
- free((void*)p);
+ free(static_cast<void*>(p));
}
void construct(pointer p, const T &val) {
- new((void*)p) T(val);
+ new(static_cast<void*>(p)) T(val);
}
void destroy(pointer p) {
p->~T();
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 74958fbc35..125aff3b9f 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -28,7 +28,7 @@ inline unsigned log2(uint64_t C) {
inline bool isPowerOf2(int64_t C, unsigned &getPow) {
if (C < 0) C = -C;
if (C > 0 && C == (C & ~(C - 1))) {
- getPow = log2((uint64_t)C);
+ getPow = log2(static_cast<uint64_t>(C));
return true;
}
diff --git a/include/llvm/Use.h b/include/llvm/Use.h
index d7c1010fc8..fb5eafb712 100644
--- a/include/llvm/Use.h
+++ b/include/llvm/Use.h
@@ -83,13 +83,13 @@ struct ilist_traits<Use> {
template<> struct simplify_type<Use> {
typedef Value* SimpleType;
static SimpleType getSimplifiedValue(const Use &Val) {
- return (SimpleType)Val.get();
+ return static_cast<SimpleType>(Val.get());
}
};
template<> struct simplify_type<const Use> {
typedef Value* SimpleType;
static SimpleType getSimplifiedValue(const Use &Val) {
- return (SimpleType)Val.get();
+ return static_cast<SimpleType>(Val.get());
}
};
diff --git a/include/llvm/User.h b/include/llvm/User.h
index cdd9b539ca..0482189b6d 100644
--- a/include/llvm/User.h
+++ b/include/llvm/User.h
@@ -96,7 +96,7 @@ template<> struct simplify_type<User::op_iterator> {
typedef Value* SimpleType;
static SimpleType getSimplifiedValue(const User::op_iterator &Val) {
- return (SimpleType)Val->get();
+ return static_cast<SimpleType>(Val->get());
}
};
template<> struct simplify_type<const User::op_iterator>
@@ -106,7 +106,7 @@ template<> struct simplify_type<User::const_op_iterator> {
typedef Value* SimpleType;
static SimpleType getSimplifiedValue(const User::const_op_iterator &Val) {
- return (SimpleType)Val->get();
+ return static_cast<SimpleType>(Val->get());
}
};
template<> struct simplify_type<const User::const_op_iterator>
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h
index e0a551a0f7..bec4502e40 100644
--- a/include/llvm/iMemory.h
+++ b/include/llvm/iMemory.h
@@ -47,7 +47,7 @@ public:
// getType - Overload to return most specific pointer type...
inline const PointerType *getType() const {
- return (const PointerType*)Instruction::getType();
+ return reinterpret_cast<const PointerType*>(Instruction::getType());
}
// getAllocatedType - Return the type that is being allocated by the
@@ -237,7 +237,7 @@ public:
class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &EPI)
- : Instruction((Type*)EPI.getType(), GetElementPtr) {
+ : Instruction(reinterpret_cast<const Type*>(EPI.getType()), GetElementPtr) {
Operands.reserve(EPI.Operands.size());
for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
Operands.push_back(Use(EPI.Operands[i], this));
@@ -249,7 +249,7 @@ public:
// getType - Overload to return most specific pointer type...
inline const PointerType *getType() const {
- return (PointerType*)Instruction::getType();
+ return reinterpret_cast<const PointerType*>(Instruction::getType());
}
/// getIndexedType - Returns the type of the element that would be loaded with
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index c611e06612..8ecf6b0269 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -113,7 +113,9 @@ public:
Operands.push_back(Use(SA, this));
}
- OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
+ OtherOps getOpcode() const {
+ return static_cast<OtherOps>(Instruction::getOpcode());
+ }
virtual Instruction *clone() const { return new ShiftInst(*this); }
diff --git a/include/llvm/iPHINode.h b/include/llvm/iPHINode.h
index 191de040e7..399c761670 100644
--- a/include/llvm/iPHINode.h
+++ b/include/llvm/iPHINode.h
@@ -58,11 +58,11 @@ public:
/// getIncomingBlock - Return incoming basic block #x
BasicBlock *getIncomingBlock(unsigned i) const {
assert(i*2+1 < Operands.size() && "Invalid value number!");
- return (BasicBlock*)Operands[i*2+1].get();
+ return reinterpret_cast<BasicBlock*>(Operands[i*2+1].get());
}
void setIncomingBlock(unsigned i, BasicBlock *BB) {
assert(i*2+1 < Operands.size() && "Invalid value number!");
- Operands[i*2+1] = (Value*)BB;
+ Operands[i*2+1] = reinterpret_cast<Value*>(BB);
}
unsigned getOperandNumForIncomingBlock(unsigned i) {
return i*2+1;
@@ -73,7 +73,7 @@ public:
assert(getType() == D->getType() &&
"All operands to PHI node must be the same type as the PHI node!");
Operands.push_back(Use(D, this));
- Operands.push_back(Use((Value*)BB, this));
+ Operands.push_back(Use(reinterpret_cast<Value*>(BB), this));
}
/// removeIncomingValue - Remove an incoming value. This is useful if a
diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h
index 93e3adce76..a27ffdf81d 100644
--- a/include/llvm/iTerminators.h
+++ b/include/llvm/iTerminators.h
@@ -87,7 +87,7 @@ public:
inline bool isConditional() const { return Operands.size() == 3; }
inline Value *getCondition() const {
- return isUnconditional() ? 0 : (Value*)Operands[2].get();
+ return isUnconditional() ? 0 : reinterpret_cast<Value*>(Operands[2].get());
}
void setCondition(Value *V) {
@@ -100,7 +100,7 @@ public:
//
void setUnconditionalDest(BasicBlock *Dest) {
if (isConditional()) Operands.erase(Operands.begin()+1, Operands.end());
- Operands[0] = (Value*)Dest;
+ Operands[0] = reinterpret_cast<Value*>(Dest);
}
virtual const BasicBlock *getSuccessor(unsigned i) const {
@@ -109,12 +109,13 @@ public:
cast<BasicBlock>(Operands[1].get());
}
inline BasicBlock *getSuccessor(unsigned idx) {
- return (BasicBlock*)((const BranchInst *)this)->getSuccessor(idx);
+ const BranchInst *BI = this;
+ return const_cast<BasicBlock*>(BI->getSuccessor(idx));
}
virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");
- Operands[idx] = (Value*)NewSucc;
+ Operands[idx] = reinterpret_cast<Value*>(NewSucc);
}
virtual unsigned getNumSuccessors() const { return 1+isConditional(); }
@@ -176,7 +177,7 @@ public:
virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < getNumSuccessors() && "Successor # out of range for switch!");
- Operands[idx*2+1] = (Value*)NewSucc;
+ Operands[idx*2+1] = reinterpret_cast<Value*>(NewSucc);
}
// getSuccessorValue - Return the value associated with the specified
@@ -243,11 +244,11 @@ public:
}
inline void setNormalDest(BasicBlock *B){
- Operands[1] = (Value*)B;
+ Operands[1] = reinterpret_cast<Value*>(B);
}
inline void setExceptionalDest(BasicBlock *B){
- Operands[2] = (Value*)B;
+ Operands[2] = reinterpret_cast<Value*>(B);
}
virtual const BasicBlock *getSuccessor(unsigned i) const {
@@ -261,7 +262,7 @@ public:
virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < 2 && "Successor # out of range for invoke!");
- Operands[idx+1] = (Value*)NewSucc;
+ Operands[idx+1] = reinterpret_cast<Value*>(NewSucc);
}
virtual unsigned getNumSuccessors() const { return 2; }
diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h
index a0a01e5306..b392ad1173 100644
--- a/lib/VMCore/ConstantFold.h
+++ b/lib/VMCore/ConstantFold.h
@@ -113,7 +113,8 @@ public:
case Type::LongTyID: return castToLong(V);
case Type::FloatTyID: return castToFloat(V);
case Type::DoubleTyID: return castToDouble(V);
- case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+ case Type::PointerTyID:
+ return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
default: return 0;
}
}
@@ -125,7 +126,7 @@ public:
static inline ConstRules *get(const Constant &V1, const Constant &V2) {
if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
return getConstantExprRules();
- return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+ return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
}
private:
static ConstRules *getConstantExprRules();
diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h
index a0a01e5306..b392ad1173 100644
--- a/lib/VMCore/ConstantFolding.h
+++ b/lib/VMCore/ConstantFolding.h
@@ -113,7 +113,8 @@ public:
case Type::LongTyID: return castToLong(V);
case Type::FloatTyID: return castToFloat(V);
case Type::DoubleTyID: return castToDouble(V);
- case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+ case Type::PointerTyID:
+ return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
default: return 0;
}
}
@@ -125,7 +126,7 @@ public:
static inline ConstRules *get(const Constant &V1, const Constant &V2) {
if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
return getConstantExprRules();
- return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+ return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
}
private:
static ConstRules *getConstantExprRules();