Skip to content

Commit be8f03b

Browse files
committed
Remove all Uses of TimeValue
The lastest version of llvm no longer has TimeValue.h, so this replaces uses with TimePoint and std::chrono.
1 parent e510daa commit be8f03b

16 files changed

+87
-77
lines changed

include/IndexStoreDB/Core/Symbol.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "llvm/ADT/StringRef.h"
2424
#include "llvm/ADT/SmallVector.h"
2525
#include "llvm/Support/DataTypes.h"
26-
#include "llvm/Support/TimeValue.h"
26+
#include "llvm/Support/Chrono.h"
2727
#include <memory>
2828
#include <string>
2929

@@ -224,20 +224,20 @@ class SymbolRelation {
224224
class TimestampedPath {
225225
std::string Path;
226226
std::string ModuleName;
227-
llvm::sys::TimeValue ModificationTime;
227+
llvm::sys::TimePoint<> ModificationTime;
228228
unsigned sysrootPrefixLength = 0;
229229
bool IsSystem;
230230

231231
public:
232-
TimestampedPath(StringRef Path, llvm::sys::TimeValue ModificationTime, StringRef moduleName, bool isSystem, CanonicalFilePathRef sysroot = {})
232+
TimestampedPath(StringRef Path, llvm::sys::TimePoint<> ModificationTime, StringRef moduleName, bool isSystem, CanonicalFilePathRef sysroot = {})
233233
: Path(Path), ModuleName(moduleName), ModificationTime(ModificationTime), IsSystem(isSystem) {
234234
if (sysroot.contains(CanonicalFilePathRef::getAsCanonicalPath(Path))) {
235235
sysrootPrefixLength = sysroot.getPath().size();
236236
}
237237
}
238238

239239
const std::string &getPathString() const { return Path; }
240-
llvm::sys::TimeValue getModificationTime() const { return ModificationTime; }
240+
llvm::sys::TimePoint<> getModificationTime() const { return ModificationTime; }
241241
const std::string &getModuleName() const { return ModuleName; }
242242
unsigned isSystem() const { return IsSystem; }
243243
StringRef getPathWithoutSysroot() const {

include/IndexStoreDB/Database/ImportTransaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LLVM_EXPORT UnitDataImport {
5454
CanonicalFilePath MainFile;
5555
CanonicalFilePath OutFile;
5656
CanonicalFilePath Sysroot;
57-
llvm::sys::TimeValue ModTime;
57+
llvm::sys::TimePoint<> ModTime;
5858
Optional<bool> IsSystem;
5959
Optional<SymbolProviderKind> SymProviderKind;
6060
std::string Target;
@@ -75,7 +75,7 @@ class LLVM_EXPORT UnitDataImport {
7575
std::vector<UnitInfo::Provider> ProviderDepends;
7676

7777
public:
78-
UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimeValue modTime);
78+
UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimePoint<> modTime);
7979
~UnitDataImport();
8080

8181
IDCode getUnitCode() const { return UnitCode; }

include/IndexStoreDB/Database/ReadTransaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class LLVM_EXPORT ReadTransaction {
4545
bool getProviderFileReferences(IDCode provider,
4646
llvm::function_ref<bool(TimestampedPath path)> receiver);
4747
bool getProviderFileCodeReferences(IDCode provider,
48-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
48+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
4949
/// Returns all provider-file associations. Intended for debugging purposes.
50-
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
50+
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
5151

5252
/// Returns USR codes in batches.
5353
bool foreachUSROfGlobalSymbolKind(SymbolKind symKind, llvm::function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);

include/IndexStoreDB/Database/UnitInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "llvm/ADT/ArrayRef.h"
1919
#include "llvm/ADT/Hashing.h"
2020
#include "llvm/ADT/StringRef.h"
21-
#include "llvm/Support/TimeValue.h"
21+
#include "llvm/Support/Chrono.h"
2222

2323
namespace IndexStoreDB {
2424
namespace db {
@@ -38,7 +38,7 @@ struct UnitInfo {
3838

3939
StringRef UnitName;
4040
IDCode UnitCode;
41-
llvm::sys::TimeValue ModTime;
41+
llvm::sys::TimePoint<> ModTime;
4242
IDCode OutFileCode;
4343
IDCode MainFileCode;
4444
IDCode SysrootCode;

include/IndexStoreDB/Index/IndexSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "IndexStoreDB/Support/LLVM.h"
1717
#include "llvm/ADT/OptionSet.h"
1818
#include "llvm/ADT/StringRef.h"
19-
#include "llvm/Support/TimeValue.h"
19+
#include "llvm/Support/Chrono.h"
2020
#include <memory>
2121
#include <string>
2222
#include <vector>
@@ -51,7 +51,7 @@ class LLVM_EXPORT IndexSystem {
5151
void waitUntilDoneInitializing();
5252

5353
bool isUnitOutOfDate(StringRef unitOutputPath, ArrayRef<StringRef> dirtyFiles);
54-
bool isUnitOutOfDate(StringRef unitOutputPath, llvm::sys::TimeValue outOfDateModTime);
54+
bool isUnitOutOfDate(StringRef unitOutputPath, llvm::sys::TimePoint<> outOfDateModTime);
5555

5656
/// Check whether any unit(s) containing \p file are out of date and if so,
5757
/// *synchronously* notify the delegate.

include/IndexStoreDB/Index/IndexSystemDelegate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define INDEXSTOREDB_INDEX_INDEXSYSTEMDELEGATE_H
1515

1616
#include "IndexStoreDB/Index/StoreUnitInfo.h"
17-
#include "llvm/Support/TimeValue.h"
17+
#include "llvm/Support/Chrono.h"
1818
#include <memory>
1919
#include <string>
2020

@@ -75,7 +75,7 @@ class LLVM_EXPORT IndexSystemDelegate {
7575
virtual void processedStoreUnit(StoreUnitInfo unitInfo) {}
7676

7777
virtual void unitIsOutOfDate(StoreUnitInfo unitInfo,
78-
llvm::sys::TimeValue outOfDateModTime,
78+
llvm::sys::TimePoint<> outOfDateModTime,
7979
OutOfDateTriggerHintRef hint,
8080
bool synchronous = false) {}
8181

include/IndexStoreDB/Index/StoreUnitInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define INDEXSTOREDB_INDEX_STOREUNITINFO_H
1515

1616
#include "IndexStoreDB/Support/Path.h"
17-
#include "llvm/Support/TimeValue.h"
17+
#include "llvm/Support/Chrono.h"
1818
#include <string>
1919

2020
namespace IndexStoreDB {
@@ -24,7 +24,7 @@ struct StoreUnitInfo {
2424
std::string UnitName;
2525
CanonicalFilePath MainFilePath;
2626
CanonicalFilePath OutFilePath;
27-
llvm::sys::TimeValue ModTime;
27+
llvm::sys::TimePoint<> ModTime;
2828
};
2929

3030
} // namespace index

lib/Database/Database.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ UnitInfo Database::Implementation::getUnitInfo(IDCode unitCode, lmdb::txn &Txn)
237237
ptr += sizeof(UnitInfo::Provider)*providerDepends.size();
238238
unitName = StringRef(ptr, infoData.NameLength);
239239

240-
llvm::sys::TimeValue modTime(infoData.Seconds, infoData.Nanoseconds);
240+
llvm::sys::TimePoint<> modTime = llvm::sys::toTimePoint(infoData.Seconds);
241+
modTime += std::chrono::nanoseconds(infoData.Nanoseconds);
241242
return UnitInfo{ unitName, unitCode, modTime,
242243
infoData.OutFileCode, infoData.MainFileCode, infoData.SysrootCode, infoData.TargetCode,
243244
infoData.HasMainFile, infoData.HasSysroot, infoData.IsSystem,

lib/Database/ImportTransaction.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,16 @@ IDCode ImportTransaction::Implementation::addModuleName(StringRef moduleName) {
158158
}
159159

160160
void ImportTransaction::Implementation::addFileAssociationForProvider(IDCode provider, IDCode file, IDCode unit,
161-
llvm::sys::TimeValue modTime, IDCode module, bool isSystem) {
161+
llvm::sys::TimePoint<> modTime, IDCode module, bool isSystem) {
162162
auto &db = DBase->impl();
163163
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
164164

165165
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
166166

167-
TimestampedFileForProviderData entry{file, unit, module, modTime.seconds(), modTime.nanoseconds(), isSystem};
167+
auto nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(modTime.time_since_epoch()).count();
168+
auto secComponent = nanos / 1000000000;
169+
int32_t nanoComponent = nanos % 1000000000;
170+
TimestampedFileForProviderData entry{file, unit, module, secComponent, nanoComponent, isSystem};
168171
lmdb::val key{&provider, sizeof(provider)};
169172
lmdb::val value{&entry, sizeof(entry)};
170173
bool added = cursor.put(key, value, MDB_NODUPDATA);
@@ -174,7 +177,8 @@ void ImportTransaction::Implementation::addFileAssociationForProvider(IDCode pro
174177
lmdb::val existingValue;
175178
cursor.get(existingKey, existingValue, MDB_GET_CURRENT);
176179
const auto &existingData = *(TimestampedFileForProviderData*)existingValue.data();
177-
llvm::sys::TimeValue existingModTime(existingData.Seconds, existingData.Nanoseconds);
180+
llvm::sys::TimePoint<> existingModTime = std::chrono::time_point_cast<std::chrono::nanoseconds>(llvm::sys::toTimePoint(existingData.Seconds));
181+
existingModTime += std::chrono::nanoseconds(existingData.Nanoseconds);
178182
if (modTime > existingModTime)
179183
cursor.put(key, value, MDB_CURRENT);
180184
}
@@ -218,9 +222,12 @@ void ImportTransaction::Implementation::addUnitInfo(const UnitInfo &info) {
218222
assert(static_cast<uint32_t>(info.FileDepends.size()) == info.FileDepends.size());
219223
assert(static_cast<uint32_t>(info.UnitDepends.size()) == info.UnitDepends.size());
220224
assert(static_cast<uint32_t>(info.ProviderDepends.size()) == info.ProviderDepends.size());
225+
auto nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(info.ModTime.time_since_epoch()).count();
226+
auto secComponent = nanos / 1000000000;
227+
int32_t nanoComponent = nanos % 1000000000;
221228
UnitInfoData infoData{ info.MainFileCode, info.OutFileCode, info.SysrootCode,
222229
info.TargetCode,
223-
info.ModTime.seconds(), info.ModTime.nanoseconds(),
230+
secComponent, nanoComponent,
224231
static_cast<uint16_t>(info.UnitName.size()),
225232
uint8_t(info.SymProviderKind),
226233
info.HasMainFile, info.HasSysroot, info.IsSystem,
@@ -370,7 +377,7 @@ void ImportTransaction::commit() {
370377
return Impl->commit();
371378
}
372379

373-
UnitDataImport::UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimeValue modTime)
380+
UnitDataImport::UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimePoint<> modTime)
374381
: Import(import), UnitName(unitName), ModTime(modTime), IsSystem(false) {
375382

376383
auto dbUnit = import._impl()->getUnitInfo(makeIDCodeFromString(unitName));

lib/Database/ImportTransactionImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ImportTransaction::Implementation {
3737
IDCode addTargetName(StringRef target);
3838
IDCode addModuleName(StringRef moduleName);
3939
/// If file is already associated, its timestamp is updated if \c modTime is more recent.
40-
void addFileAssociationForProvider(IDCode provider, IDCode file, IDCode unit, llvm::sys::TimeValue modTime, IDCode module, bool isSystem);
40+
void addFileAssociationForProvider(IDCode provider, IDCode file, IDCode unit, llvm::sys::TimePoint<> modTime, IDCode module, bool isSystem);
4141
/// \returns true if there is no remaining file reference, false otherwise.
4242
bool removeFileAssociationFromProvider(IDCode provider, IDCode file, IDCode unit);
4343

lib/Database/ReadTransaction.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ StringRef ReadTransaction::Implementation::getModuleName(IDCode moduleNameCode)
121121

122122
bool ReadTransaction::Implementation::getProviderFileReferences(IDCode provider,
123123
llvm::function_ref<bool(TimestampedPath path)> receiver) {
124-
return getProviderFileCodeReferences(provider, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem) -> bool {
124+
return getProviderFileCodeReferences(provider, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem) -> bool {
125125
std::string pathString;
126126
llvm::raw_string_ostream OS(pathString);
127127
if (!getFullFilePathFromCode(pathCode, OS)) {
@@ -141,14 +141,14 @@ bool ReadTransaction::Implementation::getProviderFileReferences(IDCode provider,
141141
static bool passFileReferencesForProviderCursor(lmdb::val &key,
142142
lmdb::val &value,
143143
lmdb::cursor &cursor,
144-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
144+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
145145
// Entries are sorted by file code and there can be multiple same file entries
146146
// from different units. We want to pass each file only once with its most recent
147147
// timestamp. Visit the entries and keep track of current file and recent timestamp;
148148
// when file changes pass it to the receiver.
149149
Optional<IDCode> currFileCode;
150150
Optional<IDCode> currUnitCode;
151-
llvm::sys::TimeValue currModTime;
151+
llvm::sys::TimePoint<> currModTime;
152152
IDCode currModuleNameCode;
153153
bool currIsSystem = false;
154154
auto passCurrFile = [&]() -> bool {
@@ -157,7 +157,8 @@ static bool passFileReferencesForProviderCursor(lmdb::val &key,
157157

158158
do {
159159
const auto &entry = *(TimestampedFileForProviderData*)value.data();
160-
llvm::sys::TimeValue modTime{entry.Seconds, entry.Nanoseconds};
160+
llvm::sys::TimePoint<> modTime = std::chrono::time_point_cast<std::chrono::nanoseconds>(llvm::sys::toTimePoint(entry.Seconds));
161+
modTime += std::chrono::nanoseconds(entry.Nanoseconds);
161162
if (!currFileCode) {
162163
currFileCode = entry.FileCode;
163164
currUnitCode = entry.UnitCode;
@@ -184,7 +185,7 @@ static bool passFileReferencesForProviderCursor(lmdb::val &key,
184185
}
185186

186187
bool ReadTransaction::Implementation::getProviderFileCodeReferences(IDCode provider,
187-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
188+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
188189
auto &db = DBase->impl();
189190
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
190191
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
@@ -198,7 +199,7 @@ bool ReadTransaction::Implementation::getProviderFileCodeReferences(IDCode provi
198199
return passFileReferencesForProviderCursor(key, value, cursor, std::move(receiver));
199200
}
200201

201-
bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
202+
bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
202203
auto &db = DBase->impl();
203204
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
204205
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
@@ -207,7 +208,7 @@ bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::
207208
lmdb::val value{};
208209
while (cursor.get(key, value, MDB_NEXT_NODUP)) {
209210
IDCode providerCode = *(IDCode*)key.data();
210-
bool cont = passFileReferencesForProviderCursor(key, value, cursor, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem) -> bool {
211+
bool cont = passFileReferencesForProviderCursor(key, value, cursor, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem) -> bool {
211212
return receiver(providerCode, pathCode, unitCode, modTime, moduleNameCode, isSystem);
212213
});
213214
if (!cont)
@@ -627,11 +628,11 @@ bool ReadTransaction::getProviderFileReferences(IDCode provider,
627628
}
628629

629630
bool ReadTransaction::getProviderFileCodeReferences(IDCode provider,
630-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
631+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
631632
return Impl->getProviderFileCodeReferences(provider, std::move(receiver));
632633
}
633634

634-
bool ReadTransaction::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
635+
bool ReadTransaction::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
635636
return Impl->foreachProviderAndFileCodeReference(std::move(receiver));
636637
}
637638

lib/Database/ReadTransactionImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class ReadTransaction::Implementation {
5050
bool getProviderFileReferences(IDCode provider,
5151
llvm::function_ref<bool(TimestampedPath path)> receiver);
5252
bool getProviderFileCodeReferences(IDCode provider,
53-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
54-
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
53+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
54+
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
5555

5656
bool foreachUSROfGlobalSymbolKind(SymbolKind symKind, llvm::function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);
5757
bool foreachUSROfGlobalSymbolKind(GlobalSymbolKind globalSymKind, function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);

0 commit comments

Comments
 (0)