[llvm-commits] [patch] universally transition to non-const llvm::Type

Chris Lattner clattner at apple.com
Sat Jul 16 23:02:41 PDT 2011


On Jul 16, 2011, at 6:57 PM, David Blaikie wrote:

> If I've understood recent conversations on llvm-dev/commits, there is a desire to transition all const llvm::Type references to non-const llvm::Type references - I'm assuming this is because llvm::Type is now immutable anyway it's just simpler to refer by non-const. 
> 
> To that end I've attached a patch to do this universally (for verficiation I did this with the following sed:
>  sed -ie 's/const \(llvm::\)\?\(Integer\|Function\|Composite\|Sequential\|Struct\|Array\|Pointer\|Vector\|\)\?Type\(\W\|$\)/\1\2Type\3/g'
> Except in clang I only used the fully qualified name (removing the optionality of the llvm:: group in the above regex) since there's a clang::Type too) & made manual changes to Types.h, DerivedTypes.h, and Types.cpp. Some functions that could be const are not - but would require const overloads of other functions. Any functions returning Type* had to be non-const so that users would get the non-const Type* they require.
> 
> Everything seems to build (debug+asserts, x86-32) and check-lit passes.
> 
> If I've misunderstood the goal here, or there's some other way this should be approached, that's ok - I just thought I'd put this out there in case it'd be useful.

Hi David,

This *is* highly desirable.  Unfortunately, this breaks all the clients, like clang and dragonegg etc.  Can you tweak this so that the main APIs *take* a "const Type" but *return* a "Type"?

-Chris



More information about the llvm-commits mailing list