diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-01-04 14:24:01 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-01-04 14:24:01 +0000 |
commit | aab77cdb6b6975c6569749bb367e88af41ecb3f0 (patch) | |
tree | 2073a01647835edd25f9885ed61aaf05d1318618 | |
parent | 5bb6561568ee415b38ccaae468f97f0e60a85e13 (diff) |
Merging r321762:
------------------------------------------------------------------------
r321762 | juliehockett | 2018-01-03 14:10:11 -0800 (Wed, 03 Jan 2018) | 8 lines
[clang-tidy] Update fuchsia-overloaded-operator to check for valid loc
Updating fuchsia-overloaded-operator check to not issue warnings for
invalid locations.
Fixes PR35803.
Differential Revision: https://reviews.llvm.org/D41708
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_60@321800 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | clang-tidy/fuchsia/OverloadedOperatorCheck.cpp | 8 | ||||
-rw-r--r-- | test/clang-tidy/fuchsia-overloaded-operator.cpp | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp b/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp index 57b4628c..a2914827 100644 --- a/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp +++ b/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp @@ -30,8 +30,12 @@ void OverloadedOperatorCheck::registerMatchers(MatchFinder *Finder) { } void OverloadedOperatorCheck::check(const MatchFinder::MatchResult &Result) { - if (const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl")) - diag(D->getLocStart(), "cannot overload %0") << D; + const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl"); + assert(D && "No FunctionDecl captured!"); + + SourceLocation Loc = D->getLocStart(); + if (Loc.isValid()) + diag(Loc, "cannot overload %0") << D; } } // namespace fuchsia diff --git a/test/clang-tidy/fuchsia-overloaded-operator.cpp b/test/clang-tidy/fuchsia-overloaded-operator.cpp index c49084b4..df1b1060 100644 --- a/test/clang-tidy/fuchsia-overloaded-operator.cpp +++ b/test/clang-tidy/fuchsia-overloaded-operator.cpp @@ -16,3 +16,6 @@ public: A operator-(const A &A1, const A &A2); // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' [fuchsia-overloaded-operator] + +void operator delete(void*, void*) throw(); +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' [fuchsia-overloaded-operator] |