[PATCH] D41708: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 3 12:25:57 PST 2018
aaron.ballman added subscribers: hans, aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM with a minor suggestion to not call `getLocStart()` twice and a formatting fix. I think you should also ping @hans to get this pulled into the 6.0 branch once it's been commit.
================
Comment at: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp:33-37
+ if (const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl")) {
+ if (D->getLocStart().isValid())
+ diag(D->getLocStart(), "cannot overload %0") << D;
+ }
}
----------------
I think this code can be simplified to:
```
const auto *D = Result.Nodes...
assert(D && "No FunctionDecl captured!");
SourceLocation Loc = D->getLocStart();
if (Loc.isValid())
diag(Loc, ...);
```
================
Comment at: test/clang-tidy/fuchsia-overloaded-operator.cpp:20
+
+void operator delete (void*, void*) throw();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' [fuchsia-overloaded-operator]
----------------
Formatting is off -- this should be `operator delete(`... (no space after "delete").
https://reviews.llvm.org/D41708
More information about the cfe-commits
mailing list