diff options
| author | Julie Hockett <juliehockett@google.com> | 2017-12-22 16:52:25 +0000 |
|---|---|---|
| committer | Julie Hockett <juliehockett@google.com> | 2017-12-22 16:52:25 +0000 |
| commit | fb4502db623884bf2ba2f354e25e6645b80a705b (patch) | |
| tree | 87ac3950dc1d1ac73196247d4f26055bed7bf32a /test | |
| parent | fd8788844c565fdc8d61bf7499dae656305d4b6e (diff) | |
[clang-tidy] Adding Fuchsia checker for overloaded operators
Adds a check to the Fuchsia module to warn if an operator is overloaded,
except move and copy operators.
See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for
reference.
Differential Revision: https://reviews.llvm.org/D41363
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@321363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
| -rw-r--r-- | test/clang-tidy/fuchsia-overloaded-operator.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/clang-tidy/fuchsia-overloaded-operator.cpp b/test/clang-tidy/fuchsia-overloaded-operator.cpp new file mode 100644 index 00000000..5c65c5bf --- /dev/null +++ b/test/clang-tidy/fuchsia-overloaded-operator.cpp @@ -0,0 +1,18 @@ +// RUN: %check_clang_tidy %s fuchsia-overloaded-operator %t + +class A { +public: + int operator+(int); + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: cannot overload 'operator+' [fuchsia-overloaded-operator] +}; + +class B { +public: + B &operator=(const B &Other); + // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' [fuchsia-overloaded-operator] + B &operator=(B &&Other); + // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' [fuchsia-overloaded-operator] +}; + +A operator-(const A& AA, const A& BB); +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' [fuchsia-overloaded-operator] |
