llvm.org GIT mirror llvm / 276222a
Change casts from old style to new style. This helps document the details better, gives the compiler a chance to validate the cast and reduces warnings if the user turns on -Wold-style-cast option. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41033 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 12 years ago
11 changed file(s) with 36 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
3131 // Provide DenseMapKeyInfo for all pointers.
3232 template
3333 struct DenseMapKeyInfo {
34 static inline T* getEmptyKey() { return (T*)-1; }
35 static inline T* getTombstoneKey() { return (T*)-2; }
34 static inline T* getEmptyKey() { return reinterpret_cast(-1); }
35 static inline T* getTombstoneKey() { return reinterpret_cast(-2); }
3636 static unsigned getHashValue(const T *PtrVal) {
37 return (unsigned)((uintptr_t)PtrVal >> 4) ^
38 (unsigned)((uintptr_t)PtrVal >> 9);
37 return (unsigned(uintptr_t(PtrVal)) >> 4) ^
38 (unsigned(uintptr_t(PtrVal)) >> 9);
3939 }
4040 static bool isPod() { return true; }
4141 };
6868 P->second.~ValueT();
6969 P->first.~KeyT();
7070 }
71 delete[] (char*)Buckets;
71 delete[] reinterpret_cast(Buckets);
7272 }
7373
7474 typedef DenseMapIterator iterator;
257257 NumBuckets = InitBuckets;
258258 assert(InitBuckets && (InitBuckets & InitBuckets-1) == 0 &&
259259 "# initial buckets must be a power of two!");
260 Buckets = (BucketT*)new char[sizeof(BucketT)*InitBuckets];
260 Buckets = reinterpret_cast(new char[sizeof(BucketT)*InitBuckets]);
261261 // Initialize all the keys to EmptyKey.
262262 const KeyT EmptyKey = getEmptyKey();
263263 for (unsigned i = 0; i != InitBuckets; ++i)
271271 // Double the number of buckets.
272272 NumBuckets <<= 1;
273273 NumTombstones = 0;
274 Buckets = (BucketT*)new char[sizeof(BucketT)*NumBuckets];
274 Buckets = reinterpret_cast(new char[sizeof(BucketT)*NumBuckets]);
275275
276276 // Initialize all the keys to EmptyKey.
277277 const KeyT EmptyKey = getEmptyKey();
297297 }
298298
299299 // Free the old table.
300 delete[] (char*)OldBuckets;
300 delete[] reinterpret_cast(OldBuckets);
301301 }
302302
303303 void shrink_and_clear() {
308308 NumBuckets = NumEntries > 32 ? 1 << (Log2_32_Ceil(NumEntries) + 1)
309309 : 64;
310310 NumTombstones = 0;
311 Buckets = (BucketT*)new char[sizeof(BucketT)*NumBuckets];
311 Buckets = reinterpret_cast(new char[sizeof(BucketT)*NumBuckets]);
312312
313313 // Initialize all the keys to EmptyKey.
314314 const KeyT EmptyKey = getEmptyKey();
326326 }
327327
328328 // Free the old table.
329 delete[] (char*)OldBuckets;
329 delete[] reinterpret_cast(OldBuckets);
330330
331331 NumEntries = 0;
332332 }
7272 public:
7373 // Default ctor - Initialize to empty.
7474 SmallVectorImpl(unsigned N)
75 : Begin((T*)&FirstEl), End((T*)&FirstEl), Capacity((T*)&FirstEl+N) {
75 : Begin(reinterpret_cast(&FirstEl)),
76 End(reinterpret_cast(&FirstEl)),
77 Capacity(reinterpret_cast(&FirstEl)+N) {
7678 }
7779
7880 ~SmallVectorImpl() {
8183
8284 // If this wasn't grown from the inline copy, deallocate the old space.
8385 if (!isSmall())
84 delete[] (char*)Begin;
86 delete[] reinterpret_cast(Begin);
8587 }
8688
8789 typedef size_t size_type;
284286 /// isSmall - Return true if this is a smallvector which has not had dynamic
285287 /// memory allocated for it.
286288 bool isSmall() const {
287 return (void*)Begin == (void*)&FirstEl;
289 return reinterpret_cast(Begin) ==
290 reinterpret_cast(&FirstEl);
288291 }
289292
290293 /// grow - double the size of the allocated memory, guaranteeing space for at
322325
323326 // If this wasn't grown from the inline copy, deallocate the old space.
324327 if (!isSmall())
325 delete[] (char*)Begin;
328 delete[] reinterpret_cast(Begin);
326329
327330 Begin = NewElts;
328331 End = NewElts+CurSize;
281281 class DominatorTree : public DominatorTreeBase {
282282 public:
283283 static char ID; // Pass ID, replacement for typeid
284 DominatorTree() : DominatorTreeBase((intptr_t)&ID, false) {}
284 DominatorTree() : DominatorTreeBase(intptr_t(&ID), false) {}
285285
286286 BasicBlock *getRoot() const {
287287 assert(Roots.size() == 1 && "Should always have entry node!");
398398 public:
399399 static char ID; // Pass ID, replacement for typeid
400400 DominanceFrontier() :
401 DominanceFrontierBase((intptr_t)& ID, false) {}
401 DominanceFrontierBase(intptr_t(&ID), false) {}
402402
403403 BasicBlock *getRoot() const {
404404 assert(Roots.size() == 1 && "Should always have entry node!");
245245 public:
246246 static char ID; // Pass identification, replacement for typeid
247247
248 LoopInfo() : FunctionPass((intptr_t)&ID) {}
248 LoopInfo() : FunctionPass(intptr_t(&ID)) {}
249249 ~LoopInfo() { releaseMemory(); }
250250
251251 /// iterator/begin/end - The interface to the top-level loops in the current
2828 bool DeleteStream; // Delete the ostream in our dtor?
2929 public:
3030 static char ID;
31 PrintModulePass() : ModulePass((intptr_t)&ID), Out(&cerr), DeleteStream(false) {}
31 PrintModulePass() : ModulePass(intptr_t(&ID)), Out(&cerr),
32 DeleteStream(false) {}
3233 PrintModulePass(OStream *o, bool DS = false)
33 : ModulePass((intptr_t)&ID), Out(o), DeleteStream(DS) {}
34 : ModulePass(intptr_t(&ID)), Out(o), DeleteStream(DS) {}
3435
3536 ~PrintModulePass() {
3637 if (DeleteStream) delete Out;
5253 bool DeleteStream; // Delete the ostream in our dtor?
5354 public:
5455 static char ID;
55 PrintFunctionPass() : FunctionPass((intptr_t)&ID), Banner(""), Out(&cerr),
56 PrintFunctionPass() : FunctionPass(intptr_t(&ID)), Banner(""), Out(&cerr),
5657 DeleteStream(false) {}
5758 PrintFunctionPass(const std::string &B, OStream *o = &cout,
5859 bool DS = false)
59 : FunctionPass((intptr_t)&ID), Banner(B), Out(o), DeleteStream(DS) {}
60 : FunctionPass(intptr_t(&ID)), Banner(B), Out(o), DeleteStream(DS) {}
6061
6162 inline ~PrintFunctionPass() {
6263 if (DeleteStream) delete Out;
7373 Alignment = Align;
7474 }
7575
76 VisibilityTypes getVisibility() const { return (VisibilityTypes)Visibility; }
76 VisibilityTypes getVisibility() const { return VisibilityTypes(Visibility); }
7777 bool hasHiddenVisibility() const { return Visibility == HiddenVisibility; }
7878 bool hasProtectedVisibility() const {
7979 return Visibility == ProtectedVisibility;
169169
170170 template
171171 static const PassInfo *getClassPassInfo() {
172 return lookupPassInfo((intptr_t)&AnalysisClass::ID);
172 return lookupPassInfo(intptr_t(&AnalysisClass::ID));
173173 }
174174
175175 // lookupPassInfo - Return the pass info object for the specified pass class,
340340 public:
341341 static char ID;
342342 explicit FPPassManager(int Depth)
343 : ModulePass((intptr_t)&ID), PMDataManager(Depth) { }
343 : ModulePass(intptr_t(&ID)), PMDataManager(Depth) { }
344344
345345 /// run - Execute all of the passes scheduled for execution. Keep track of
346346 /// whether any of the passes modifies the module, and if so, return true.
164164
165165 // Register Pass using default constructor...
166166 RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false)
167 : RegisterPassBase(Name, PassArg, (intptr_t)&PassName::ID,
168 (RegisterPassBase::NormalCtor_t)callDefaultCtor, CFGOnly) {
167 : RegisterPassBase(Name, PassArg, intptr_t(&PassName::ID),
168 RegisterPassBase::NormalCtor_t(callDefaultCtor), CFGOnly) {
169169 }
170170 };
171171
203203 template
204204 struct RegisterAnalysisGroup : public RegisterAGBase {
205205 explicit RegisterAnalysisGroup(RegisterPassBase &RPB)
206 : RegisterAGBase((intptr_t) &Interface::ID, RPB.getPassInfo()->getTypeInfo(),
206 : RegisterAGBase(intptr_t(&Interface::ID), RPB.getPassInfo()->getTypeInfo(),
207207 Default) {
208208 }
209209
210210 explicit RegisterAnalysisGroup(const char *Name)
211 : RegisterAGBase((intptr_t) &Interface::ID) {
211 : RegisterAGBase(intptr_t(&Interface::ID)) {
212212 setGroupName(Name);
213213 }
214214 };
4444 /// getListOwner - Return the object that owns this list. If this is a list
4545 /// of instructions, it returns the BasicBlock that owns them.
4646 ItemParentClass *getListOwner() {
47 return reinterpret_cast((char*)this-
47 return reinterpret_cast(reinterpret_cast(this)-
4848 TraitsClass::getListOffset());
4949 }
5050 static ValueSubClass *getPrev(ValueSubClass *V) { return V->getPrev(); }
107107 ///
108108 /// @note This has to exist, because this is a pass, but it should never be
109109 /// used.
110 TargetData() : ImmutablePass((intptr_t)&ID) {
110 TargetData() : ImmutablePass(intptr_t(&ID)) {
111111 assert(0 && "ERROR: Bad TargetData ctor used. "
112112 "Tool did not specify a TargetData to use?");
113113 abort();
115115
116116 /// Constructs a TargetData from a specification string. See init().
117117 explicit TargetData(const std::string &TargetDescription)
118 : ImmutablePass((intptr_t)&ID) {
118 : ImmutablePass(intptr_t(&ID)) {
119119 init(TargetDescription);
120120 }
121121
123123 explicit TargetData(const Module *M);
124124
125125 TargetData(const TargetData &TD) :
126 ImmutablePass((intptr_t)&ID),
126 ImmutablePass(intptr_t(&ID)),
127127 LittleEndian(TD.isLittleEndian()),
128128 PointerMemSize(TD.PointerMemSize),
129129 PointerABIAlign(TD.PointerABIAlign),