[clang] aa4e34b - [clang][Interp] Implement bitwise operations for IntegralAP (#71807)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 16 00:31:29 PST 2023
Author: Timm Baeder
Date: 2023-11-16T09:31:24+01:00
New Revision: aa4e34bd814a7d34551ab2e88cb2c45e78ada442
URL: https://github.com/llvm/llvm-project/commit/aa4e34bd814a7d34551ab2e88cb2c45e78ada442
DIFF: https://github.com/llvm/llvm-project/commit/aa4e34bd814a7d34551ab2e88cb2c45e78ada442.diff
LOG: [clang][Interp] Implement bitwise operations for IntegralAP (#71807)
Added:
Modified:
clang/lib/AST/Interp/IntegralAP.h
clang/test/AST/Interp/intap.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h
index b8e37878ce2f848..d85904a8f9572eb 100644
--- a/clang/lib/AST/Interp/IntegralAP.h
+++ b/clang/lib/AST/Interp/IntegralAP.h
@@ -218,21 +218,19 @@ template <bool Signed> 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 c3cae9a64780d5c..4a18f1f9459e301 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
More information about the cfe-commits
mailing list