summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYan Wang <yawanng@google.com>2017-06-07 22:39:20 +0000
committerYan Wang <yawanng@google.com>2017-06-07 22:39:20 +0000
commit98b74fc7d695b29a26ce3c15816002513dffd395 (patch)
treea9e95cc74e07e0ee824f04d0d7354a73e43463eb
parentfa6fcff2e3cd9017ae79fcf2128505d104227cc1 (diff)
downloadbcm5719-llvm-98b74fc7d695b29a26ce3c15816002513dffd395.tar.gz
bcm5719-llvm-98b74fc7d695b29a26ce3c15816002513dffd395.zip
[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 llvm-svn: 304949
-rw-r--r--clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp2
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp17
2 files changed, 14 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp b/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
index 12a360f4ba7..2fdcf75083f 100644
--- a/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
@@ -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(
diff --git a/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
index b8154ec3af1..4072e3f933b 100644
--- a/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp
@@ -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 {};
OpenPOWER on IntegriCloud