[PATCH] D39360: [C++11] Don't put empty quotes in static_assert diagnostic.

Nicolas Lesser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 22:34:37 PDT 2017


Rakete1111 created this revision.
Rakete1111 added a project: clang.

This patch removes the empty `""` when using `static_assert(1 + 1 == 3, "");` in the diagnostic:

  main.cpp:1:1: error: static_assert failed
  static_assert(1 + 1 == 3, "");
  ^             ~~~~~~~~~~


https://reviews.llvm.org/D39360

Files:
  lib/Sema/SemaDeclCXX.cpp


Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13319,8 +13319,9 @@
                                          Expr *AssertExpr,
                                          Expr *AssertMessageExpr,
                                          SourceLocation RParenLoc) {
-  StringLiteral *AssertMessage =
-      AssertMessageExpr ? cast<StringLiteral>(AssertMessageExpr) : nullptr;
+  auto *AssertMessage = cast_or_null<StringLiteral>(AssertMessageExpr);
+  if (AssertMessage && !AssertMessage->getLength())
+    AssertMessage = nullptr;
 
   if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
     return nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39360.120539.patch
Type: text/x-patch
Size: 750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171027/60e96f87/attachment.bin>


More information about the cfe-commits mailing list