This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Extend operator overloading for ' - ' and ' + ' operators on llvm::TimeRecord
Needs ReviewPublic

Authored by RithikSharma on Jul 13 2021, 12:11 PM.

Details

Summary

This patch is an attempt to extend the operator overloading for ' - ' and ' + ' operators.

While implementing #D105565 (Print time taken to analyze each function), we realized that the ' - ' operator isn't overloaded on llvm::TimeRecord.

Previously:

CheckerEndTime -= CheckerStartTime;
DisplayTime(CheckerEndTime);

Now:

DisplayTime(CheckerEndTime - CheckerStartTime);

Diff Detail

Event Timeline

RithikSharma created this revision.Jul 13 2021, 12:11 PM
RithikSharma requested review of this revision.Jul 13 2021, 12:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2021, 12:11 PM
NoQ added a comment.Jul 13 2021, 12:37 PM

Nice! Please add some reviewers based on git blame for Timer.h.

llvm/include/llvm/Support/Timer.h
69

Did you try the suggested canonical form from https://en.cppreference.com/w/cpp/language/operators? It's a bit shorter and they say it's more optimizer-friendly.