Page MenuHomePhabricator

[Tooling] Add operator== to CompileCommand
ClosedPublic

Authored by simark on Jul 12 2018, 1:48 PM.

Details

Summary

It does the obvious thing of comparing all fields. This will be needed
for a clangd patch I have in the pipeline.

Diff Detail

Repository
rC Clang

Event Timeline

simark created this revision.Jul 12 2018, 1:48 PM

Any chance this can/should be unit tested? (also, in general (though might
not matter in this instance), symmetric operators like == should be
implemented as non-members (though they can still be friends and if they
are, can be defined inline in the class definition as a member could be),
so any implicit conversions apply equally to the LHS as the RHS of the
expression)

Any chance this can/should be unit tested? (also, in general (though might
not matter in this instance), symmetric operators like == should be
implemented as non-members (though they can still be friends and if they
are, can be defined inline in the class definition as a member could be),
so any implicit conversions apply equally to the LHS as the RHS of the
expression)

Of course, I'm on it.

simark updated this revision to Diff 155753.Jul 16 2018, 1:42 PM
  • Add test
  • Make operator== a function instead of method
  • Add operator!= (so I can use EXPECT_NE in the test, and because it may be useful in general)
dblaikie accepted this revision.Jul 16 2018, 2:10 PM

In theory you'd need separate tests for op== and op!= returning false (currently all the tests would pass if both implementations returned true in all cases), but not the biggest deal.

This revision is now accepted and ready to land.Jul 16 2018, 2:10 PM

In theory you'd need separate tests for op== and op!= returning false (currently all the tests would pass if both implementations returned true in all cases), but not the biggest deal.

Good point, I'll update it, it will take a second.

simark updated this revision to Diff 155773.Jul 16 2018, 3:38 PM

Add tests for both == and !=.

I need to rebuild ~800 files (because I pulled llvm/clang), so I did not
actually test it, but I'll do so before pushing tomorrow, of course.

dblaikie accepted this revision.Jul 16 2018, 5:35 PM

Looks good, Thanks!

Closed by commit rC337284: [Tooling] Add operator== to CompileCommand (authored by simark, committed by ). · Explain Why
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.