[llvm] r178147 - Cleanup the simplify_type implementation.

Eli Friedman eli.friedman at gmail.com
Tue Jul 16 16:14:53 PDT 2013


On Tue, Jul 16, 2013 at 5:12 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> In terms of testing it in the unittests, though, you shouldn't need
>> any fancy SFINAE; just do something like:
>>
>> using namespace llvm;
>> struct IllegalCast;
>> template<typename T> IllegalCast *cast(...) { return 0; }
>> IllegalCast *testIllegalCast() {
>>   return cast<SomeType>(SomeRValue);
>> }
>>
>> This will compile if and only if the cast isn't viable, because
>> overload resolution will always prefer a function with named
>> arguments.
>
> Good idea. I have added it to the patch.
>
>> In terms of the patch itself, if I recall correctly, the enable_ifs
>> you're removing are necessary to reject a T* where T is simplifiable.
>> I could be wrong, though.
>
> Sorry, can you give an example of what you want to reject?

Something like the following (there are probably better examples, but
I can't remember off the top of my head):

    llvm::Value *V;
    llvm::Use *U = &V->use_begin().getUse();
    llvm::Constant *XXX = cast<llvm::Constant>(U);

-Eli




More information about the llvm-commits mailing list