[llvm-commits] PR10663: remove DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS

Jay Foad jay.foad at gmail.com
Fri Aug 19 03:47:44 PDT 2011


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtcoa.diff
Type: text/x-patch
Size: 4796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110819/a90244ab/attachment.bin>


More information about the llvm-commits mailing list