Skip to content

Commit 6b03a89

Browse files
committed
use std::optional to enforce ReadTimer
1 parent b45ce00 commit 6b03a89

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/include/clang/Serialization/ASTReader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ class ASTReader
526526
/// A timer used to track the time spent deserializing.
527527
std::unique_ptr<llvm::Timer> ReadTimer;
528528

529+
// A TimeRegion used to start and stop ReadTimer via RAII.
530+
std::optional<llvm::TimeRegion> ReadTimeRegion;
531+
529532
/// The location where the module file will be considered as
530533
/// imported from. For non-module AST types it should be invalid.
531534
SourceLocation CurrentImportLoc;

clang/lib/Serialization/ASTReader.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11004,8 +11004,8 @@ void ASTReader::diagnoseOdrViolations() {
1100411004

1100511005
void ASTReader::StartedDeserializing() {
1100611006
if (llvm::Timer *T = ReadTimer.get();
11007-
++NumCurrentElementsDeserializing == 1 && T && !T->isRunning())
11008-
T->startTimer();
11007+
++NumCurrentElementsDeserializing == 1 && T)
11008+
ReadTimeRegion.emplace(T);
1100911009
}
1101011010

1101111011
void ASTReader::FinishedDeserializing() {
@@ -11063,8 +11063,7 @@ void ASTReader::FinishedDeserializing() {
1106311063
(void)UndeducedFD->getMostRecentDecl();
1106411064
}
1106511065

11066-
if (ReadTimer)
11067-
ReadTimer->stopTimer();
11066+
ReadTimeRegion.reset();
1106811067

1106911068
diagnoseOdrViolations();
1107011069
}

0 commit comments

Comments
 (0)