Add a new emitPrimCast helper function and use that when evaluating floating compound operators.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/AST/Interp/ByteCodeExprGen.cpp | ||
---|---|---|
2405 | Might as well leave a comment here too, for symmetry |
clang/lib/AST/Interp/ByteCodeExprGen.cpp | ||
---|---|---|
2383 | ||
2388–2393 | Should we be early returning if we're casting from float->float like we do for int->int? | |
2396 | It weirds me out that isIntegralType() returns false for a boolean type; that is an integral type as well: http://eel.is/c++draft/basic.types#basic.fundamental-11 | |
clang/test/AST/Interp/floats.cpp | ||
106 | Is it intentional that this is returning a float but then comparing below as an integer? |
clang/lib/AST/Interp/ByteCodeExprGen.cpp | ||
---|---|---|
2388–2393 | Heh, I was thinking the exact same thing when writing this, but a) That means we also have to pass a QualTyp FromQT | |
2396 | I don't think there's a good reason for it to return false for bools; before this patch, the function is only used for an assertion in Neg(). | |
clang/test/AST/Interp/floats.cpp | ||
106 | Kinda? What we compare against doesn't really matter for the compound assignment in the function, does it? |
LGTM with a testing nit.
clang/lib/AST/Interp/ByteCodeExprGen.cpp | ||
---|---|---|
2388–2393 | Okay, that seems reasonable to me. We can always revisit later if we find it on a hot path for some reason. | |
2396 | Sounds like a good NFC change to make as a follow-up. | |
clang/test/AST/Interp/floats.cpp | ||
106 | Heh, that's why I was surprised -- it seems like odd type mismatches that are unrelated to the patch. If that's not what's being tested, might as well match the types up better so the test coverage is more clear. |