forked from OSchip/llvm-project
parent
27b10bc781
commit
82f87e63e8
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in New Issue