[clang-tools-extra] r304949 - [clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

Yan Wang via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 7 15:39:20 PDT 2017


Author: yawanng
Date: Wed Jun  7 17:39:20 2017
New Revision: 304949

URL: http://llvm.org/viewvc/llvm-project?rev=304949&view=rev
Log:
[clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed.

Summary:  "misc-noexcept-move-constructor" is better not to be issued when "-fno-exceptions" is set.

Reviewers: chh, alexfh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, cfe-commits, xazax.hun

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D34002

Modified:
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp?rev=304949&r1=304948&r2=304949&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp Wed Jun  7 17:39:20 2017
@@ -20,7 +20,7 @@ namespace misc {
 void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus11)
+  if (!getLangOpts().CPlusPlus11 || !getLangOpts().CXXExceptions)
     return;
 
   Finder->addMatcher(

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp?rev=304949&r1=304948&r2=304949&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp Wed Jun  7 17:39:20 2017
@@ -1,16 +1,25 @@
-// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- -std=c++11 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-EXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+// RUN: clang-tidy %s -checks="-*,misc-noexcept-move-constructor" -- -fno-exceptions -std=c++11 \
+// RUN:   | FileCheck %s -allow-empty -check-prefix=CHECK-NONEXCEPTIONS \
+// RUN:   -implicit-check-not="{{warning|error}}:"
+
 
 class A {
   A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-NONEXCEPTIONS-NOT: warning:
   A &operator=(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:6: warning: move assignment operators should
+  // CHECK-NONEXCEPTIONS-NOT: warning:
 };
 
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-EXCEPTIONS: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-NONEXCEPTIONS-NOT: warning:
 };
 
 class OK {};




More information about the cfe-commits mailing list