This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Update fuchsia-overloaded-operator to check for valid loc
ClosedPublic

Authored by juliehockett on Jan 3 2018, 12:18 PM.

Diff Detail

Event Timeline

juliehockett created this revision.Jan 3 2018, 12:18 PM
aaron.ballman accepted this revision.Jan 3 2018, 12:25 PM
aaron.ballman added subscribers: hans, aaron.ballman.

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.

clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
33–39

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, ...);
test/clang-tidy/fuchsia-overloaded-operator.cpp
20

Formatting is off -- this should be operator delete(... (no space after "delete").

This revision is now accepted and ready to land.Jan 3 2018, 12:25 PM
This revision was automatically updated to reflect the committed changes.
alexfh added inline comments.Jan 3 2018, 3:14 PM
clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
38

This is not related to the fix, but the warning message is unclear, incorrect and confusing: one most certainly _can_ overload these functions, but shouldn't do this in fuchsia code due to certain reasons. Ideally, warning messages should make it clear to the reader what's wrong with the code, why, and how to fix it.

hans added a comment.Jan 16 2018, 6:46 AM

Alex, do you think the fix is still OK for the 6.0 branch? Let me know, and I'll merge it.

The update to the message is also up for review here: D42120

In D41708#977000, @hans wrote:

Alex, do you think the fix is still OK for the 6.0 branch? Let me know, and I'll merge it.

Yes, please. Thank you!

hans added a comment.Jan 17 2018, 6:09 AM
In D41708#977000, @hans wrote:

Alex, do you think the fix is still OK for the 6.0 branch? Let me know, and I'll merge it.

Yes, please. Thank you!

Oh, it was already merged in r321800. Sorry for the noise.