As requested here:https://bugs.llvm.org/show_bug.cgi?id=37633
permit the __builtin_*_overflow builtins in constexpr functions.
Differential D48040
Implement constexpr __builtin_*_overflow erichkeane on Jun 11 2018, 11:23 AM. Authored by
Details As requested here:https://bugs.llvm.org/show_bug.cgi?id=37633 permit the __builtin_*_overflow builtins in constexpr functions.
Diff Detail Event Timeline
Comment Actions Alright, done here: https://reviews.llvm.org/D48053 This one'll require some rebasing on that change, but I'm not sure how to do it in SVN. Therefore, I'll just rebase this one when it comes to commit it. -Erich Comment Actions Separated out the other patch as Eli suggested (which has now been committed), and rebased this patch on top of it. Comment Actions I'd like to see a couple of testcases ensuring the return value is correct on overflow (we had a problem with that for __builtin_mul_overflow in the past). Otherwise LGTM. Comment Actions I believe my tests DO validate the return value correctly, don't they? It uses a sentinel, but the ternary should check that return value, right? Or is there an obvious thing I'm missing? Comment Actions Oh, sorry, I mixed up the two values. I meant that you should add a couple testcases to ensure the stored value is correct on overflow. |
The comment should explain *why* growth isn't possible (it's because we extended to the max-width type earlier).
I don't think a casual reader is going to understand what you're saying about TruncOrSelf (that APSInt doesn't have such an operation, but that we can safely simulate it with extOrTrunc because we'll never do an extension).