[PATCH] D146376: Update static_assert message for redundant cases

Krishna Narayanan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 18 23:53:43 PDT 2023


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

There are some simple messages where an expansion isn't particularly helpful or needed. We aim to eliminate expansions that don't add much value for user (this will give us slightly more room or prioritise to have longer diagnostics elsewhere).

The test case for which it has been tested:

  constexpr auto is_gitlab = false;
  constexpr auto is_weekend = false;
  static_assert(is_gitlab or is_weekend);

**Previous warning/error message**:

  <source>:4:1: error: static assertion failed due to requirement 'is_gitlab || is_weekend'
  static_assert(is_gitlab or is_weekend);
  ^             ~~~~~~~~~~~~~~~~~~~~~~~
  <source>:4:25: note: expression evaluates to 'false || false'
  static_assert(is_gitlab or is_weekend);
                ~~~~~~~~~~^~~~~~~~~~~~~

**Currrent warning/error message**:

  <source>:4:1: error: static assertion failed due to requirement 'is_gitlab'
  static_assert(is_gitlab and is_weekend);
  ^             ~~~~~~~~~


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146376

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16744,9 +16744,7 @@
           DiagSide[I].Result.Val, Side->getType(), DiagSide[I].ValueString);
     }
     if (DiagSide[0].Print && DiagSide[1].Print) {
-      Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
-          << DiagSide[0].ValueString << Op->getOpcodeStr()
-          << DiagSide[1].ValueString << Op->getSourceRange();
+      return;
     }
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146376.506352.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230319/4fed737c/attachment.bin>


More information about the cfe-commits mailing list