This is a fix for #53963.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/
D122544
namespace {
AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
- return Node.getValue().getZExtValue() > N;
+ return Node.getValue().ugt(N);
}
AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,
- Fixed a false positive in :doc:`misc-redundant-expression <clang-tidy/checks/misc-redundant-expression>`
involving overloaded comparison operators.
+- Fixed a crash in :doc:`bugprone-sizeof-expression <clang-tidy/checks/bugprone-sizeof-expression>` when
+ `sizeof(...)` is compared agains a `__int128_t`.
+
Removed checks
^^^^^^^^^^^^^^
template <typename T>
int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar<char>(); }
+template <__int128_t N>
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar<char>() + Baz<-1>(); }
static const char* kABC = "abc";
static const wchar_t* kDEF = L"def";