diff options
author | Timm Baeder <tbaeder@redhat.com> | 2023-11-16 09:31:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 09:31:24 +0100 |
commit | aa4e34bd814a7d34551ab2e88cb2c45e78ada442 (patch) | |
tree | c6bb0742a6cb30c4b10369941f850ddea7d346af /clang | |
parent | af05f9ff06a20b9f58fdb4e9e6e1db5bee1abcf5 (diff) | |
download | llvm-aa4e34bd814a7d34551ab2e88cb2c45e78ada442.zip llvm-aa4e34bd814a7d34551ab2e88cb2c45e78ada442.tar.gz llvm-aa4e34bd814a7d34551ab2e88cb2c45e78ada442.tar.bz2 |
[clang][Interp] Implement bitwise operations for IntegralAP (#71807)
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/Interp/IntegralAP.h | 8 | ||||
-rw-r--r-- | clang/test/AST/Interp/intap.cpp | 12 |
2 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index b8e3787..d85904a 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -218,21 +218,19 @@ public: static bool bitAnd(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { - // FIXME: Implement. - assert(false); + *R = IntegralAP(A.V & B.V); return false; } static bool bitOr(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { - assert(false); + *R = IntegralAP(A.V | B.V); return false; } static bool bitXor(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { - // FIXME: Implement. - assert(false); + *R = IntegralAP(A.V ^ B.V); return false; } diff --git a/clang/test/AST/Interp/intap.cpp b/clang/test/AST/Interp/intap.cpp index c3cae9a..4a18f1f 100644 --- a/clang/test/AST/Interp/intap.cpp +++ b/clang/test/AST/Interp/intap.cpp @@ -172,4 +172,16 @@ namespace Bitfields { // expected-warning {{changes value from 100 to 0}} } +namespace BitOps { + constexpr unsigned __int128 UZero = 0; + constexpr unsigned __int128 Max = ~UZero; + static_assert(Max == ~0, ""); + static_assert((Max & 0) == 0, ""); + static_assert((UZero | 0) == 0, ""); + static_assert((Max ^ Max) == 0, ""); + static_assert((Max & 1) == 1, ""); + static_assert((UZero | 1) == 1, ""); + static_assert((Max ^ UZero) == Max, ""); +} + #endif |