diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index 88de1f1392e68..c8850a4bbb574 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -219,21 +219,19 @@ template class IntegralAP final { 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 34c8d05650829..729d144012713 100644 --- a/clang/test/AST/Interp/intap.cpp +++ b/clang/test/AST/Interp/intap.cpp @@ -157,4 +157,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