Skip to content

Commit 08f0389

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 08f0389

17 files changed

+84
-83
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
using namespace IndexStoreDB;
3333
using namespace IndexStoreDB::db;
3434

35-
const unsigned Database::DATABASE_FORMAT_VERSION = 11;
35+
const unsigned Database::DATABASE_FORMAT_VERSION = 12;
3636

3737
static const char *DeadProcessDBSuffix = "-dead";
3838

@@ -237,7 +237,7 @@ 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::TimePoint<>(std::chrono::nanoseconds(infoData.NanoTime));
241241
return UnitInfo{ unitName, unitCode, modTime,
242242
infoData.OutFileCode, infoData.MainFileCode, infoData.SysrootCode, infoData.TargetCode,
243243
infoData.HasMainFile, infoData.HasSysroot, infoData.IsSystem,

lib/Database/DatabaseImpl.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ struct TimestampedFileForProviderData {
111111
IDCode FileCode;
112112
IDCode UnitCode;
113113
IDCode ModuleNameCode;
114-
int64_t Seconds;
115-
int32_t Nanoseconds;
114+
uint64_t NanoTime;
116115
bool IsSystem;
117116
};
118117

@@ -132,8 +131,7 @@ struct UnitInfoData {
132131
IDCode OutFileCode;
133132
IDCode SysrootCode;
134133
IDCode TargetCode;
135-
int64_t Seconds;
136-
int32_t Nanoseconds;
134+
int64_t NanoTime;
137135
uint16_t NameLength;
138136
uint8_t SymProviderKind;
139137
bool HasMainFile : 1;

lib/Database/ImportTransaction.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,14 @@ 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+
uint64_t nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(modTime.time_since_epoch()).count();
168+
TimestampedFileForProviderData entry{file, unit, module, nanos, isSystem};
168169
lmdb::val key{&provider, sizeof(provider)};
169170
lmdb::val value{&entry, sizeof(entry)};
170171
bool added = cursor.put(key, value, MDB_NODUPDATA);
@@ -174,7 +175,7 @@ void ImportTransaction::Implementation::addFileAssociationForProvider(IDCode pro
174175
lmdb::val existingValue;
175176
cursor.get(existingKey, existingValue, MDB_GET_CURRENT);
176177
const auto &existingData = *(TimestampedFileForProviderData*)existingValue.data();
177-
llvm::sys::TimeValue existingModTime(existingData.Seconds, existingData.Nanoseconds);
178+
llvm::sys::TimePoint<> existingModTime = llvm::sys::TimePoint<>(std::chrono::nanoseconds(existingData.NanoTime));
178179
if (modTime > existingModTime)
179180
cursor.put(key, value, MDB_CURRENT);
180181
}
@@ -185,7 +186,7 @@ bool ImportTransaction::Implementation::removeFileAssociationFromProvider(IDCode
185186
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
186187
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
187188

188-
TimestampedFileForProviderData entry{file, unit, IDCode(), 0, 0, false};
189+
TimestampedFileForProviderData entry{file, unit, IDCode(), 0, false};
189190
lmdb::val key{&provider, sizeof(provider)};
190191
lmdb::val value{&entry, sizeof(entry)};
191192
bool found = cursor.get(key, value, MDB_GET_BOTH_RANGE);
@@ -218,9 +219,10 @@ void ImportTransaction::Implementation::addUnitInfo(const UnitInfo &info) {
218219
assert(static_cast<uint32_t>(info.FileDepends.size()) == info.FileDepends.size());
219220
assert(static_cast<uint32_t>(info.UnitDepends.size()) == info.UnitDepends.size());
220221
assert(static_cast<uint32_t>(info.ProviderDepends.size()) == info.ProviderDepends.size());
222+
auto nanoTime = std::chrono::duration_cast<std::chrono::nanoseconds>(info.ModTime.time_since_epoch()).count();
221223
UnitInfoData infoData{ info.MainFileCode, info.OutFileCode, info.SysrootCode,
222224
info.TargetCode,
223-
info.ModTime.seconds(), info.ModTime.nanoseconds(),
225+
nanoTime,
224226
static_cast<uint16_t>(info.UnitName.size()),
225227
uint8_t(info.SymProviderKind),
226228
info.HasMainFile, info.HasSysroot, info.IsSystem,
@@ -370,7 +372,7 @@ void ImportTransaction::commit() {
370372
return Impl->commit();
371373
}
372374

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

376378
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: 9 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,7 @@ 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 = llvm::sys::TimePoint<>(std::chrono::nanoseconds(entry.NanoTime));
161161
if (!currFileCode) {
162162
currFileCode = entry.FileCode;
163163
currUnitCode = entry.UnitCode;
@@ -184,7 +184,7 @@ static bool passFileReferencesForProviderCursor(lmdb::val &key,
184184
}
185185

186186
bool ReadTransaction::Implementation::getProviderFileCodeReferences(IDCode provider,
187-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
187+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
188188
auto &db = DBase->impl();
189189
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
190190
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
@@ -198,7 +198,7 @@ bool ReadTransaction::Implementation::getProviderFileCodeReferences(IDCode provi
198198
return passFileReferencesForProviderCursor(key, value, cursor, std::move(receiver));
199199
}
200200

201-
bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
201+
bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
202202
auto &db = DBase->impl();
203203
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
204204
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
@@ -207,7 +207,7 @@ bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::
207207
lmdb::val value{};
208208
while (cursor.get(key, value, MDB_NEXT_NODUP)) {
209209
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 {
210+
bool cont = passFileReferencesForProviderCursor(key, value, cursor, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem) -> bool {
211211
return receiver(providerCode, pathCode, unitCode, modTime, moduleNameCode, isSystem);
212212
});
213213
if (!cont)
@@ -627,11 +627,11 @@ bool ReadTransaction::getProviderFileReferences(IDCode provider,
627627
}
628628

629629
bool ReadTransaction::getProviderFileCodeReferences(IDCode provider,
630-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
630+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
631631
return Impl->getProviderFileCodeReferences(provider, std::move(receiver));
632632
}
633633

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

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)