[PATCH] D95515: [clang-tidy] bugprone-assert-side-effect: Improve warning message.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 28 22:32:05 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGec8128983180: [clang-tidy] bugprone-assert-side-effect: Improve warning message. (authored by dergachev.a).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95515/new/

https://reviews.llvm.org/D95515

Files:
  clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-assert-side-effect.cpp
@@ -68,47 +68,47 @@
   assert(X == 1);
 
   assert(X = 1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect [bugprone-assert-side-effect]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds [bugprone-assert-side-effect]
   my_assert(X = 1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found my_assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in my_assert() condition discarded in release builds
   convoluted_assert(X = 1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found convoluted_assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in convoluted_assert() condition discarded in release builds
   not_my_assert(X = 1);
 
   assert(++X);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
   assert(!B);
 
   assert(B || true);
 
   assert(freeFunction());
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
 
   MyClass mc;
   assert(mc.badFunc(0, 1));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
   assert(mc.goodFunc(0, 1));
 
   MyClass mc2;
   assert(mc2 = mc);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
 
   assert(-mc > 0);
 
   MyClass *mcp;
   assert(mcp = new MyClass);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
 
   assert((delete mcp, false));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
 
   assert((throw 1, false));
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in assert() condition discarded in release builds
 
   assert2(1 == 2 - 1);
 
   msvc_assert(mc2 = mc);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found msvc_assert() with side effect
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in msvc_assert() condition discarded in release builds
 
   return 0;
 }
Index: clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
@@ -117,7 +117,8 @@
   if (AssertMacroName.empty())
     return;
 
-  diag(Loc, "found %0() with side effect") << AssertMacroName;
+  diag(Loc, "side effect in %0() condition discarded in release builds")
+      << AssertMacroName;
 }
 
 } // namespace bugprone


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95515.320050.patch
Type: text/x-patch
Size: 3554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210129/50b40f55/attachment-0001.bin>


More information about the cfe-commits mailing list