[PATCH] D105927: [analyzer] Extend operator overloading for ' - ' and ' + ' operators on llvm::TimeRecord
rithik sharma via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 13 12:11:36 PDT 2021
RithikSharma created this revision.
RithikSharma added reviewers: NoQ, xazax.hun, teemperor, vsavchenko.
Herald added subscribers: manas, dexonsmith, steakhal, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
RithikSharma requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch is an attempt to extend the operator overloading for ' - ' and ' + ' operators.
While implementing #D105565 <https://reviews.llvm.org/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);
https://reviews.llvm.org/D105927
Files:
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
llvm/include/llvm/Support/Timer.h
Index: llvm/include/llvm/Support/Timer.h
===================================================================
--- llvm/include/llvm/Support/Timer.h
+++ llvm/include/llvm/Support/Timer.h
@@ -66,6 +66,16 @@
MemUsed -= RHS.MemUsed;
InstructionsExecuted -= RHS.InstructionsExecuted;
}
+ TimeRecord operator-(const TimeRecord &RHS) {
+ TimeRecord TR(*this);
+ TR -= RHS;
+ return TR;
+ }
+ TimeRecord operator+(const TimeRecord &RHS) {
+ TimeRecord TR(*this);
+ TR += RHS;
+ return TR;
+ }
/// Print the current time record to \p OS, with a breakdown showing
/// contributions to the \p Total time record.
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -187,7 +187,7 @@
}
}
- void DisplayTime(llvm::TimeRecord &Time) {
+ void DisplayTime(llvm::TimeRecord Time) {
if (!Opts->AnalyzerDisplayProgress) {
return;
}
@@ -637,8 +637,7 @@
if (SyntaxCheckTimer) {
SyntaxCheckTimer->stopTimer();
llvm::TimeRecord CheckerEndTime = SyntaxCheckTimer->getTotalTime();
- CheckerEndTime -= CheckerStartTime;
- DisplayTime(CheckerEndTime);
+ DisplayTime(CheckerEndTime - CheckerStartTime);
}
}
@@ -680,8 +679,7 @@
if (ExprEngineTimer) {
ExprEngineTimer->stopTimer();
llvm::TimeRecord ExprEngineEndTime = ExprEngineTimer->getTotalTime();
- ExprEngineEndTime -= ExprEngineStartTime;
- DisplayTime(ExprEngineEndTime);
+ DisplayTime(ExprEngineEndTime - ExprEngineStartTime);
}
if (!Mgr->options.DumpExplodedGraphTo.empty())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105927.358383.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210713/32da1d25/attachment.bin>
More information about the llvm-commits
mailing list