[llvm-commits] PR10663: remove DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS
Gabor Greif
ggreif at gmail.com
Fri Aug 19 11:36:22 PDT 2011
Hi Jay,
as I commented in the PR, I prefer not to remove DTCOA, because before
they were introduced ConstantArray::getOperand() also returned
Constant*, not Value*.
So in certain situations you could introduce pessimizations to LLVM
and even get compile errors in out-of-tree code, which reiles on a
subclass pointer being returned.
OTOH, changing DTOA to use cast_or_null just as DTCOA seems like a
consistent idea.
Just my 2 cents :-)
Gabor
On 8/19/11, Jay Foad <jay.foad at gmail.com> wrote:
> http://llvm.org/bugs/show_bug.cgi?id=10663
>
> The only difference between DEFINE_TRANSPARENT_OPERAND_ACCESSORS and
> DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS seems to be in the way
> they cast the value returned from getOperand():
>
> - DTOA uses static_cast<>, which tolerates NULL operands
> - DTCOA uses cast<>, which asserts that the cast is safe, but doesn't
> tolerate NULL operands (hence the bug report)
>
> The attached patch simplifies this by removing DTCOA and changing DTOA
> to use cast_or_null<>, which gives the best of both worlds: it checks
> that the cast is safe, and allows NULL operands.
>
> Tested with "make all check-all", LLVM + Clang, and by manually
> running the test case from the PR. (I have no idea how to add this
> test case to the automatic test suite -- perhaps you could take care
> of that, Duncan?)
>
> OK to commit?
>
> Thanks,
> Jay.
>
More information about the llvm-commits
mailing list