Serialized indexes are now versioned. Old versions are not imported.

This commit is contained in:
Jacob Dufault 2017-04-19 23:02:24 -07:00
parent 9338bcfd0e
commit d83b1591a4
113 changed files with 21 additions and 130 deletions

View File

@ -26,7 +26,7 @@ std::unique_ptr<IndexedFile> LoadCachedFile(IndexerConfig* config, const std::st
return nullptr;
optional<IndexedFile> indexed = Deserialize(filename, *file_content);
if (indexed)
if (indexed && indexed->version == IndexedFile::kCurrentVersion)
return MakeUnique<IndexedFile>(indexed.value());
return nullptr;

View File

@ -8,6 +8,7 @@
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/doctest
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/rapidjson/include
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/sparsehash/src
-IC:/Users/jacob/Desktop/superindex/indexer/third_party/sparsepp
-IC:/Program Files/LLVM/include
# OSX
#-I/Users/jdufault/Personal/super-clang-index/third_party

View File

@ -465,6 +465,9 @@ struct IdCache {
struct IndexedFile {
IdCache id_cache;
static constexpr int kCurrentVersion = 1;
int version = 0;
std::string path;
int64_t last_modification_time = 0;

View File

@ -11,8 +11,6 @@
namespace {
bool gModificationTimeDisabled = false;
// See http://stackoverflow.com/a/236803
template<typename Out>
void Split(const std::string &s, char delim, Out result) {
@ -85,15 +83,6 @@ void MakeDirectoryRecursive(std::string path) {
}
}
void DisableModificationTimeForTest() {
gModificationTimeDisabled = true;
}
bool IsModificationTimeDisabledForTests() {
return gModificationTimeDisabled;
}
TEST_SUITE("Platform");
TEST_CASE("Split strings") {

View File

@ -37,9 +37,6 @@ bool TryMakeDirectory(const std::string& absolute_path);
void SetCurrentThreadName(const std::string& thread_name);
void DisableModificationTimeForTest();
bool IsModificationTimeDisabledForTests();
int64_t GetLastModificationTime(const std::string& absolute_path);
// Returns any clang arguments that are specific to the current platform.

View File

@ -183,9 +183,6 @@ void SetCurrentThreadName(const std::string& thread_name) {
}
int64_t GetLastModificationTime(const std::string& absolute_path) {
if (IsModificationTimeDisabledForTests())
return 1;
struct _stat buf;
if (_stat(absolute_path.c_str(), &buf) != 0) {
switch (errno) {

View File

@ -2,6 +2,9 @@
#include "indexer.h"
namespace {
bool gTestOutputMode = false;
} // namespace
// int
void Reflect(Reader& visitor, int& value) {
@ -216,13 +219,17 @@ bool ReflectMemberStart(Writer& visitor, IndexedFile& value) {
assert(value.Resolve(it->second)->uses.size() == 0);
}
value.version = IndexedFile::kCurrentVersion;
DefaultReflectMemberStart(visitor);
return true;
}
template<typename TVisitor>
void Reflect(TVisitor& visitor, IndexedFile& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(last_modification_time);
if (!gTestOutputMode) {
REFLECT_MEMBER(version);
REFLECT_MEMBER(last_modification_time);
}
REFLECT_MEMBER(dependencies);
REFLECT_MEMBER(types);
REFLECT_MEMBER(funcs);
@ -276,3 +283,7 @@ optional<IndexedFile> Deserialize(std::string path, std::string serialized) {
return file;
}
void SetTestOutputMode() {
gTestOutputMode = true;
}

View File

@ -208,3 +208,5 @@ void ReflectMember(Reader& visitor, const char* name, T& value) {
std::string Serialize(IndexedFile& file);
optional<IndexedFile> Deserialize(std::string path, std::string serialized);
void SetTestOutputMode();

View File

@ -112,7 +112,7 @@ IndexedFile* FindDbForPathEnding(const std::string& path, const std::vector<std:
}
void RunTests() {
DisableModificationTimeForTest();
SetTestOutputMode();
// TODO: Assert that we need to be on clang >= 3.9.1
bool update_all = false;

View File

@ -1,6 +1,4 @@
/*
OUTPUT:
{
"last_modification_time": 1
}
{}
*/

View File

@ -6,7 +6,6 @@ class Foo;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -11,7 +11,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -16,7 +16,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -6,7 +6,6 @@ Foo::Foo() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -8,7 +8,6 @@ class Foo;
// for comments.
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -5,7 +5,6 @@ class Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -7,7 +7,6 @@ int Foo::foo;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -7,7 +7,6 @@ void foo();
// Note: we always use the latest seen ("most local") definition/declaration.
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#",

View File

@ -9,7 +9,6 @@ void Foo::def() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -6,7 +6,6 @@ enum class Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@Foo",

View File

@ -6,7 +6,6 @@ enum Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@Foo",

View File

@ -6,7 +6,6 @@ enum Foo : int {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@Foo",

View File

@ -8,7 +8,6 @@ Foo x = Foo::A;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@Foo",

View File

@ -11,7 +11,6 @@ Foo<B> b;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@A",

View File

@ -3,7 +3,6 @@ void foo(int a, int b);
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#I#I#",

View File

@ -5,7 +5,6 @@ void foo() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#",

View File

@ -3,7 +3,6 @@ void foo() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#",

View File

@ -4,7 +4,6 @@ class Derived : public Parent {};
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Parent",

View File

@ -15,7 +15,6 @@ class Derived : Base1<3>, Base2<Derived>, Derived1<4>, Derived2<Derived> {};
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#Ni@Base1",

View File

@ -6,7 +6,6 @@ class Derived : public MiddleA, public MiddleB {};
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Root",

View File

@ -8,7 +8,6 @@ class Derived : public Root {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Root",

View File

@ -5,7 +5,6 @@ class IFoo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@IFoo",

View File

@ -9,7 +9,6 @@ class Foo {
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -7,7 +7,6 @@ void Foo::foo() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -5,7 +5,6 @@ class Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -8,7 +8,6 @@ enum Foo {
OUTPUT: funky_enum.h
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@Foo",
@ -48,7 +47,6 @@ OUTPUT: funky_enum.h
}
OUTPUT: funky_enum.cc
{
"last_modification_time": 1,
"dependencies": ["C:/Users/jacob/Desktop/superindex/indexer/tests/multi_file/funky_enum.h"],
"types": [{
"id": 0,

View File

@ -7,7 +7,6 @@ void Impl() {
/*
OUTPUT: header.h
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Base",
@ -111,7 +110,6 @@ OUTPUT: header.h
}
OUTPUT: impl.cc
{
"last_modification_time": 1,
"dependencies": ["C:/Users/jacob/Desktop/superindex/indexer/tests/multi_file/header.h"],
"funcs": [{
"id": 0,

View File

@ -7,7 +7,6 @@ void impl() {
/*
OUTPUT: simple_header.h
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@header#",
@ -18,7 +17,6 @@ OUTPUT: simple_header.h
}
OUTPUT: simple_impl.cc
{
"last_modification_time": 1,
"dependencies": ["C:/Users/jacob/Desktop/superindex/indexer/tests/multi_file/simple_header.h"],
"funcs": [{
"id": 0,

View File

@ -5,7 +5,6 @@ void Buffer::CreateSharedBuffer() {}
/*
OUTPUT: static.h
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Buffer",
@ -27,7 +26,6 @@ OUTPUT: static.h
}
OUTPUT: static.cc
{
"last_modification_time": 1,
"dependencies": ["C:/Users/jacob/Desktop/superindex/indexer/tests/multi_file/static.h"],
"types": [{
"id": 0,

View File

@ -5,7 +5,6 @@ void foo();
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:anonymous_function.cc@aN@F@foo#",

View File

@ -5,7 +5,6 @@ void foo(int a, int b);
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@N@hello@F@foo#I#I#",

View File

@ -5,7 +5,6 @@ void foo() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@N@hello@F@foo#",

View File

@ -7,7 +7,6 @@ class Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@N@hello@S@Foo",

View File

@ -9,7 +9,6 @@ void Foo::foo() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@N@hello@S@Foo",

View File

@ -7,7 +7,6 @@ class Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@N@hello@S@Foo",

View File

@ -12,7 +12,6 @@ void Runner() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@N@ns@F@Accept#I#",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,6 @@ void Foo::Bar(Template<double>&) {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Template",

View File

@ -17,7 +17,6 @@ namespace ns {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@N@ns@E@VarType",

View File

@ -14,7 +14,6 @@ namespace ns {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@N@ns@ST>1#T@Foo",

View File

@ -9,7 +9,6 @@ namespace ns {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@N@ns@ST>1#T@Foo",

View File

@ -15,7 +15,6 @@ void Template<void>::Foo() {}
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Template",

View File

@ -11,7 +11,6 @@ int b = Foo<bool>::foo();
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Foo",

View File

@ -12,7 +12,6 @@ int b = Foo<bool>::foo<double>();
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Foo",

View File

@ -30,7 +30,6 @@ VarDecl b
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@A",

View File

@ -9,7 +9,6 @@ int b = Foo<bool>::var;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Foo",

View File

@ -12,7 +12,6 @@ int b = foo<bool>();
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:template_func_usage_folded_into_one.cc@FT@>1#Tfoo#I#",

View File

@ -7,7 +7,6 @@ Foo<bool> b;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Foo",

View File

@ -30,7 +30,6 @@ UnexposedDecl var
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@A",

View File

@ -6,7 +6,6 @@ union vector3 {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@U@vector3",

View File

@ -6,7 +6,6 @@ union Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@U@Foo",

View File

@ -14,7 +14,6 @@ void act(Foo*) {
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@U@Foo",

View File

@ -11,7 +11,6 @@ Foo::Foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -9,7 +9,6 @@ void caller() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@called#b#b#",

View File

@ -14,7 +14,6 @@ void foo() {
// called() is never referenced.
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@called#",

View File

@ -11,7 +11,6 @@ Wrapper caller() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Wrapper",

View File

@ -10,7 +10,6 @@ void user() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@consume#*v#",

View File

@ -10,7 +10,6 @@ void user() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -6,7 +6,6 @@ void caller() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@called#",

View File

@ -10,7 +10,6 @@ void user() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -9,7 +9,6 @@ class Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -6,7 +6,6 @@ void usage() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#",

View File

@ -9,7 +9,6 @@ void usage() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -9,7 +9,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@FT@>1#Taccept#t0.0#v#",

View File

@ -13,7 +13,6 @@ unique_ptr<S>* return_type() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@unique_ptr",

View File

@ -81,7 +81,6 @@ unique_ptr<S1, S2>* Foo::foo() { return nullptr; }
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>2#T#T@unique_ptr",

View File

@ -8,7 +8,6 @@ static unique_ptr<S> foo;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@unique_ptr",

View File

@ -4,7 +4,6 @@ extern T t;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@T",

View File

@ -9,7 +9,6 @@ struct Foo {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@ForwardType",

View File

@ -9,7 +9,6 @@ void Foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@ForwardType",

View File

@ -6,7 +6,6 @@ void foo(ForwardType* f, ImplementedType a) {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@ForwardType",

View File

@ -11,7 +11,6 @@ void foo(Foo* f, Foo*) {}
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -3,7 +3,6 @@ void foo(ForwardType*) {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@ForwardType",

View File

@ -9,7 +9,6 @@ void foo(Type& a0, const Type& a1) {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Type",

View File

@ -3,7 +3,6 @@ static Type t;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Type",

View File

@ -20,7 +20,6 @@ static Type* bar() {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Type",

View File

@ -12,7 +12,6 @@ void accept3(Foo3*) {}
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -7,7 +7,6 @@ typedef Foo<Foo1> Foo2;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@ST>1#T@Foo",

View File

@ -12,7 +12,6 @@ extern Foo foo;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -17,7 +17,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -9,7 +9,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@called#I#",

View File

@ -10,7 +10,6 @@ void caller() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@called#",

View File

@ -20,7 +20,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -11,7 +11,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@S@Foo",

View File

@ -10,7 +10,6 @@ const VarType Holder::static_var;
/*
OUTPUT:
{
"last_modification_time": 1,
"types": [{
"id": 0,
"usr": "c:@E@VarType",

View File

@ -6,7 +6,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#",

View File

@ -4,7 +4,6 @@ void foo(int a) {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#I#",

View File

@ -5,7 +5,6 @@ void foo() {
/*
OUTPUT:
{
"last_modification_time": 1,
"funcs": [{
"id": 0,
"usr": "c:@F@foo#",

Some files were not shown because too many files have changed in this diff Show More