aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/fuchsia
diff options
context:
space:
mode:
authorJulie Hockett <juliehockett@google.com>2018-01-03 22:10:11 +0000
committerJulie Hockett <juliehockett@google.com>2018-01-03 22:10:11 +0000
commit3005fd7f8efd38e51a35f4a539deb499995b66f3 (patch)
tree9e0898e2210fa17d7137c037631c4a20cb6f90f9 /clang-tidy/fuchsia
parent5f459b0495192dd75a76cbd058b49b6369058c1d (diff)
[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/trunk@321762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/fuchsia')
-rw-r--r--clang-tidy/fuchsia/OverloadedOperatorCheck.cpp8
1 files changed, 6 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