summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/fuchsia-overloaded-operator.cpp
diff options
context:
space:
mode:
authorJulie Hockett <juliehockett@google.com>2017-12-22 16:52:25 +0000
committerJulie Hockett <juliehockett@google.com>2017-12-22 16:52:25 +0000
commita966f45b7ee6a9c77a7040b51a18c01caac90918 (patch)
tree280861773da8ff8eea0be9932721fa8a663a0a8f /clang-tools-extra/test/clang-tidy/fuchsia-overloaded-operator.cpp
parent9c9b61df7e37bc1832b225c0c26123031727c8ef (diff)
downloadbcm5719-llvm-a966f45b7ee6a9c77a7040b51a18c01caac90918.tar.gz
bcm5719-llvm-a966f45b7ee6a9c77a7040b51a18c01caac90918.zip
[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 llvm-svn: 321363
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/fuchsia-overloaded-operator.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/fuchsia-overloaded-operator.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/fuchsia-overloaded-operator.cpp b/clang-tools-extra/test/clang-tidy/fuchsia-overloaded-operator.cpp
new file mode 100644
index 00000000000..5c65c5bfa11
--- /dev/null
+++ b/clang-tools-extra/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]
OpenPOWER on IntegriCloud