Skip to content

Remove all Uses of TimeValue #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/IndexStoreDB/Core/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/TimeValue.h"
#include "llvm/Support/Chrono.h"
#include <memory>
#include <string>

Expand Down Expand Up @@ -224,20 +224,20 @@ class SymbolRelation {
class TimestampedPath {
std::string Path;
std::string ModuleName;
llvm::sys::TimeValue ModificationTime;
llvm::sys::TimePoint<> ModificationTime;
unsigned sysrootPrefixLength = 0;
bool IsSystem;

public:
TimestampedPath(StringRef Path, llvm::sys::TimeValue ModificationTime, StringRef moduleName, bool isSystem, CanonicalFilePathRef sysroot = {})
TimestampedPath(StringRef Path, llvm::sys::TimePoint<> ModificationTime, StringRef moduleName, bool isSystem, CanonicalFilePathRef sysroot = {})
: Path(Path), ModuleName(moduleName), ModificationTime(ModificationTime), IsSystem(isSystem) {
if (sysroot.contains(CanonicalFilePathRef::getAsCanonicalPath(Path))) {
sysrootPrefixLength = sysroot.getPath().size();
}
}

const std::string &getPathString() const { return Path; }
llvm::sys::TimeValue getModificationTime() const { return ModificationTime; }
llvm::sys::TimePoint<> getModificationTime() const { return ModificationTime; }
const std::string &getModuleName() const { return ModuleName; }
unsigned isSystem() const { return IsSystem; }
StringRef getPathWithoutSysroot() const {
Expand Down
4 changes: 2 additions & 2 deletions include/IndexStoreDB/Database/ImportTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LLVM_EXPORT UnitDataImport {
CanonicalFilePath MainFile;
CanonicalFilePath OutFile;
CanonicalFilePath Sysroot;
llvm::sys::TimeValue ModTime;
llvm::sys::TimePoint<> ModTime;
Optional<bool> IsSystem;
Optional<SymbolProviderKind> SymProviderKind;
std::string Target;
Expand All @@ -75,7 +75,7 @@ class LLVM_EXPORT UnitDataImport {
std::vector<UnitInfo::Provider> ProviderDepends;

public:
UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimeValue modTime);
UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimePoint<> modTime);
~UnitDataImport();

IDCode getUnitCode() const { return UnitCode; }
Expand Down
4 changes: 2 additions & 2 deletions include/IndexStoreDB/Database/ReadTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class LLVM_EXPORT ReadTransaction {
bool getProviderFileReferences(IDCode provider,
llvm::function_ref<bool(TimestampedPath path)> receiver);
bool getProviderFileCodeReferences(IDCode provider,
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
/// Returns all provider-file associations. Intended for debugging purposes.
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);

/// Returns USR codes in batches.
bool foreachUSROfGlobalSymbolKind(SymbolKind symKind, llvm::function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);
Expand Down
4 changes: 2 additions & 2 deletions include/IndexStoreDB/Database/UnitInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/TimeValue.h"
#include "llvm/Support/Chrono.h"

namespace IndexStoreDB {
namespace db {
Expand All @@ -38,7 +38,7 @@ struct UnitInfo {

StringRef UnitName;
IDCode UnitCode;
llvm::sys::TimeValue ModTime;
llvm::sys::TimePoint<> ModTime;
IDCode OutFileCode;
IDCode MainFileCode;
IDCode SysrootCode;
Expand Down
4 changes: 2 additions & 2 deletions include/IndexStoreDB/Index/IndexSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "IndexStoreDB/Support/LLVM.h"
#include "llvm/ADT/OptionSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/TimeValue.h"
#include "llvm/Support/Chrono.h"
#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -51,7 +51,7 @@ class LLVM_EXPORT IndexSystem {
void waitUntilDoneInitializing();

bool isUnitOutOfDate(StringRef unitOutputPath, ArrayRef<StringRef> dirtyFiles);
bool isUnitOutOfDate(StringRef unitOutputPath, llvm::sys::TimeValue outOfDateModTime);
bool isUnitOutOfDate(StringRef unitOutputPath, llvm::sys::TimePoint<> outOfDateModTime);

/// Check whether any unit(s) containing \p file are out of date and if so,
/// *synchronously* notify the delegate.
Expand Down
4 changes: 2 additions & 2 deletions include/IndexStoreDB/Index/IndexSystemDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define INDEXSTOREDB_INDEX_INDEXSYSTEMDELEGATE_H

#include "IndexStoreDB/Index/StoreUnitInfo.h"
#include "llvm/Support/TimeValue.h"
#include "llvm/Support/Chrono.h"
#include <memory>
#include <string>

Expand Down Expand Up @@ -75,7 +75,7 @@ class LLVM_EXPORT IndexSystemDelegate {
virtual void processedStoreUnit(StoreUnitInfo unitInfo) {}

virtual void unitIsOutOfDate(StoreUnitInfo unitInfo,
llvm::sys::TimeValue outOfDateModTime,
llvm::sys::TimePoint<> outOfDateModTime,
OutOfDateTriggerHintRef hint,
bool synchronous = false) {}

Expand Down
4 changes: 2 additions & 2 deletions include/IndexStoreDB/Index/StoreUnitInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define INDEXSTOREDB_INDEX_STOREUNITINFO_H

#include "IndexStoreDB/Support/Path.h"
#include "llvm/Support/TimeValue.h"
#include "llvm/Support/Chrono.h"
#include <string>

namespace IndexStoreDB {
Expand All @@ -24,7 +24,7 @@ struct StoreUnitInfo {
std::string UnitName;
CanonicalFilePath MainFilePath;
CanonicalFilePath OutFilePath;
llvm::sys::TimeValue ModTime;
llvm::sys::TimePoint<> ModTime;
};

} // namespace index
Expand Down
4 changes: 2 additions & 2 deletions lib/Database/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
using namespace IndexStoreDB;
using namespace IndexStoreDB::db;

const unsigned Database::DATABASE_FORMAT_VERSION = 11;
const unsigned Database::DATABASE_FORMAT_VERSION = 12;

static const char *DeadProcessDBSuffix = "-dead";

Expand Down Expand Up @@ -237,7 +237,7 @@ UnitInfo Database::Implementation::getUnitInfo(IDCode unitCode, lmdb::txn &Txn)
ptr += sizeof(UnitInfo::Provider)*providerDepends.size();
unitName = StringRef(ptr, infoData.NameLength);

llvm::sys::TimeValue modTime(infoData.Seconds, infoData.Nanoseconds);
llvm::sys::TimePoint<> modTime = llvm::sys::TimePoint<>(std::chrono::nanoseconds(infoData.NanoTime));
return UnitInfo{ unitName, unitCode, modTime,
infoData.OutFileCode, infoData.MainFileCode, infoData.SysrootCode, infoData.TargetCode,
infoData.HasMainFile, infoData.HasSysroot, infoData.IsSystem,
Expand Down
6 changes: 2 additions & 4 deletions lib/Database/DatabaseImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ struct TimestampedFileForProviderData {
IDCode FileCode;
IDCode UnitCode;
IDCode ModuleNameCode;
int64_t Seconds;
int32_t Nanoseconds;
uint64_t NanoTime;
bool IsSystem;
};

Expand All @@ -132,8 +131,7 @@ struct UnitInfoData {
IDCode OutFileCode;
IDCode SysrootCode;
IDCode TargetCode;
int64_t Seconds;
int32_t Nanoseconds;
int64_t NanoTime;
uint16_t NameLength;
uint8_t SymProviderKind;
bool HasMainFile : 1;
Expand Down
14 changes: 8 additions & 6 deletions lib/Database/ImportTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ IDCode ImportTransaction::Implementation::addModuleName(StringRef moduleName) {
}

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

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

TimestampedFileForProviderData entry{file, unit, module, modTime.seconds(), modTime.nanoseconds(), isSystem};
uint64_t nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(modTime.time_since_epoch()).count();
TimestampedFileForProviderData entry{file, unit, module, nanos, isSystem};
lmdb::val key{&provider, sizeof(provider)};
lmdb::val value{&entry, sizeof(entry)};
bool added = cursor.put(key, value, MDB_NODUPDATA);
Expand All @@ -174,7 +175,7 @@ void ImportTransaction::Implementation::addFileAssociationForProvider(IDCode pro
lmdb::val existingValue;
cursor.get(existingKey, existingValue, MDB_GET_CURRENT);
const auto &existingData = *(TimestampedFileForProviderData*)existingValue.data();
llvm::sys::TimeValue existingModTime(existingData.Seconds, existingData.Nanoseconds);
llvm::sys::TimePoint<> existingModTime = llvm::sys::TimePoint<>(std::chrono::nanoseconds(existingData.NanoTime));
if (modTime > existingModTime)
cursor.put(key, value, MDB_CURRENT);
}
Expand All @@ -185,7 +186,7 @@ bool ImportTransaction::Implementation::removeFileAssociationFromProvider(IDCode
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);

TimestampedFileForProviderData entry{file, unit, IDCode(), 0, 0, false};
TimestampedFileForProviderData entry{file, unit, IDCode(), 0, false};
lmdb::val key{&provider, sizeof(provider)};
lmdb::val value{&entry, sizeof(entry)};
bool found = cursor.get(key, value, MDB_GET_BOTH_RANGE);
Expand Down Expand Up @@ -218,9 +219,10 @@ void ImportTransaction::Implementation::addUnitInfo(const UnitInfo &info) {
assert(static_cast<uint32_t>(info.FileDepends.size()) == info.FileDepends.size());
assert(static_cast<uint32_t>(info.UnitDepends.size()) == info.UnitDepends.size());
assert(static_cast<uint32_t>(info.ProviderDepends.size()) == info.ProviderDepends.size());
auto nanoTime = std::chrono::duration_cast<std::chrono::nanoseconds>(info.ModTime.time_since_epoch()).count();
UnitInfoData infoData{ info.MainFileCode, info.OutFileCode, info.SysrootCode,
info.TargetCode,
info.ModTime.seconds(), info.ModTime.nanoseconds(),
nanoTime,
static_cast<uint16_t>(info.UnitName.size()),
uint8_t(info.SymProviderKind),
info.HasMainFile, info.HasSysroot, info.IsSystem,
Expand Down Expand Up @@ -370,7 +372,7 @@ void ImportTransaction::commit() {
return Impl->commit();
}

UnitDataImport::UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimeValue modTime)
UnitDataImport::UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimePoint<> modTime)
: Import(import), UnitName(unitName), ModTime(modTime), IsSystem(false) {

auto dbUnit = import._impl()->getUnitInfo(makeIDCodeFromString(unitName));
Expand Down
2 changes: 1 addition & 1 deletion lib/Database/ImportTransactionImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ImportTransaction::Implementation {
IDCode addTargetName(StringRef target);
IDCode addModuleName(StringRef moduleName);
/// If file is already associated, its timestamp is updated if \c modTime is more recent.
void addFileAssociationForProvider(IDCode provider, IDCode file, IDCode unit, llvm::sys::TimeValue modTime, IDCode module, bool isSystem);
void addFileAssociationForProvider(IDCode provider, IDCode file, IDCode unit, llvm::sys::TimePoint<> modTime, IDCode module, bool isSystem);
/// \returns true if there is no remaining file reference, false otherwise.
bool removeFileAssociationFromProvider(IDCode provider, IDCode file, IDCode unit);

Expand Down
18 changes: 9 additions & 9 deletions lib/Database/ReadTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ StringRef ReadTransaction::Implementation::getModuleName(IDCode moduleNameCode)

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

do {
const auto &entry = *(TimestampedFileForProviderData*)value.data();
llvm::sys::TimeValue modTime{entry.Seconds, entry.Nanoseconds};
llvm::sys::TimePoint<> modTime = llvm::sys::TimePoint<>(std::chrono::nanoseconds(entry.NanoTime));
if (!currFileCode) {
currFileCode = entry.FileCode;
currUnitCode = entry.UnitCode;
Expand All @@ -184,7 +184,7 @@ static bool passFileReferencesForProviderCursor(lmdb::val &key,
}

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

bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver) {
auto &db = DBase->impl();
auto &dbiFilesByProvider = db.getDBITimestampedFilesByProvider();
auto cursor = lmdb::cursor::open(Txn, dbiFilesByProvider);
Expand All @@ -207,7 +207,7 @@ bool ReadTransaction::Implementation::foreachProviderAndFileCodeReference(llvm::
lmdb::val value{};
while (cursor.get(key, value, MDB_NEXT_NODUP)) {
IDCode providerCode = *(IDCode*)key.data();
bool cont = passFileReferencesForProviderCursor(key, value, cursor, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem) -> bool {
bool cont = passFileReferencesForProviderCursor(key, value, cursor, [&](IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem) -> bool {
return receiver(providerCode, pathCode, unitCode, modTime, moduleNameCode, isSystem);
});
if (!cont)
Expand Down Expand Up @@ -627,11 +627,11 @@ bool ReadTransaction::getProviderFileReferences(IDCode provider,
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions lib/Database/ReadTransactionImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class ReadTransaction::Implementation {
bool getProviderFileReferences(IDCode provider,
llvm::function_ref<bool(TimestampedPath path)> receiver);
bool getProviderFileCodeReferences(IDCode provider,
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);

bool foreachUSROfGlobalSymbolKind(SymbolKind symKind, llvm::function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);
bool foreachUSROfGlobalSymbolKind(GlobalSymbolKind globalSymKind, function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);
Expand Down
Loading