[PATCH] D149000: Update with warning message for comparison to NULL pointer

Krishna Narayanan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 22 10:48:29 PDT 2023


Krishna-13-cyber created this revision.
Krishna-13-cyber added reviewers: aaron.ballman, tbaeder, Quuxplusone.
Herald added a project: All.
Krishna-13-cyber requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch solves the issue pointed out in https://github.com/llvm/llvm-project/issues/42992.
While checking the testcases it fails in one of the cases, I am unsure of the fix of that while rest all seems fine.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149000

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16715,7 +16715,7 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast<BinaryOperator>(E)) {
+  if (const auto *Op = dyn_cast<BinaryOperator>(E);Op && Op->getOpcode() != BO_LOr) {
     const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
     const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149000.516083.patch
Type: text/x-patch
Size: 616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230422/f98a2141/attachment.bin>


More information about the cfe-commits mailing list