This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix modernize-use-override incorrect replacement
ClosedPublic

Authored by vgao on Jul 6 2017, 11:41 AM.

Details

Summary

For the following code: modernize-use-override generates a replacement with incorrect location.

struct IntPair
{
  int first, second;
};

struct A
{
  virtual void il(IntPair);
};

struct B : A
{
  void il(IntPair p = {1, (2 + 3)}) {};
  // Generated Fixit: void il(IntPair p = override {1, (2 + 3)}) {};
  // Should be: void il(IntPair p = {1, (2 + 3)}) override {};
};

This fixes that and adds a unit test.

Diff Detail

Repository
rL LLVM

Event Timeline

vgao created this revision.Jul 6 2017, 11:41 AM
Eugene.Zelenko added a project: Restricted Project.
alexfh accepted this revision.Jul 6 2017, 2:27 PM

Looks good with a nit.

Thank you for the fix!

clang-tidy/modernize/UseOverrideCheck.cpp
43 ↗(On Diff #105495)

s/!Parens/Parens == 0/

Maybe also change Parens to NestedParens or NestingLevel.

This revision is now accepted and ready to land.Jul 6 2017, 2:27 PM
vgao updated this revision to Diff 105554.Jul 6 2017, 3:39 PM

Change variable name Parens to NestedParens

vgao marked an inline comment as done.Jul 6 2017, 3:47 PM
vgao added a comment.Jul 6 2017, 4:11 PM

@alexfh Could you please land this for me? Thanks!

This revision was automatically updated to reflect the committed changes.