mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Misc formatting
This commit is contained in:
parent
66771be32e
commit
ada13f2939
6
.clang_complete
Normal file
6
.clang_complete
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
-std=c++11
|
||||||
|
-Ithird_party/rapidjson/include
|
||||||
|
-IC:/Program Files/LLVM/include
|
||||||
|
-std=c++11
|
||||||
|
-fms-compatibility
|
||||||
|
-fdelayed-template-parsing
|
1129
command_line.cc
1129
command_line.cc
File diff suppressed because it is too large
Load Diff
@ -72,6 +72,7 @@ std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::str
|
|||||||
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, j)));
|
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, j)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result.push_back(entry);
|
result.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1223
indexer.cpp
1223
indexer.cpp
File diff suppressed because it is too large
Load Diff
239
indexer.h
239
indexer.h
@ -26,34 +26,26 @@ struct IndexedVarDef;
|
|||||||
|
|
||||||
using namespace std::experimental;
|
using namespace std::experimental;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
template<typename T>
|
|
||||||
struct Id {
|
struct Id {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
|
|
||||||
Id() : id(0) {} // Needed for containers. Do not use directly.
|
Id() : id(0) {} // Needed for containers. Do not use directly.
|
||||||
Id(uint64_t id) : id(id) {}
|
Id(uint64_t id) : id(id) {}
|
||||||
|
|
||||||
bool operator==(const Id<T>& other) const {
|
bool operator==(const Id<T>& other) const { return id == other.id; }
|
||||||
return id == other.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<(const Id<T>& other) const {
|
bool operator<(const Id<T>& other) const { return id < other.id; }
|
||||||
return id < other.id;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct hash<Id<T>> {
|
struct hash<Id<T>> {
|
||||||
size_t operator()(const Id<T>& k) const {
|
size_t operator()(const Id<T>& k) const { return hash<uint64_t>()(k.id); }
|
||||||
return hash<uint64_t>()(k.id);
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
template<typename T>
|
|
||||||
bool operator==(const Id<T>& a, const Id<T>& b) {
|
bool operator==(const Id<T>& a, const Id<T>& b) {
|
||||||
assert(a.group == b.group && "Cannot compare Ids from different groups");
|
assert(a.group == b.group && "Cannot compare Ids from different groups");
|
||||||
return a.id == b.id;
|
return a.id == b.id;
|
||||||
@ -87,9 +79,7 @@ struct Location {
|
|||||||
this->column = column;
|
this->column = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileId file_id() const {
|
FileId file_id() const { return FileId(raw_file_id); }
|
||||||
return FileId(raw_file_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit Location(const char* encoded) : Location() {
|
explicit Location(const char* encoded) : Location() {
|
||||||
int len = strlen(encoded);
|
int len = strlen(encoded);
|
||||||
@ -104,13 +94,15 @@ struct Location {
|
|||||||
raw_file_id = atoi(encoded);
|
raw_file_id = atoi(encoded);
|
||||||
while (*encoded && *encoded != ':')
|
while (*encoded && *encoded != ':')
|
||||||
++encoded;
|
++encoded;
|
||||||
if (*encoded == ':') ++encoded;
|
if (*encoded == ':')
|
||||||
|
++encoded;
|
||||||
|
|
||||||
assert(encoded);
|
assert(encoded);
|
||||||
line = atoi(encoded);
|
line = atoi(encoded);
|
||||||
while (*encoded && *encoded != ':')
|
while (*encoded && *encoded != ':')
|
||||||
++encoded;
|
++encoded;
|
||||||
if (*encoded == ':') ++encoded;
|
if (*encoded == ':')
|
||||||
|
++encoded;
|
||||||
|
|
||||||
assert(encoded);
|
assert(encoded);
|
||||||
column = atoi(encoded);
|
column = atoi(encoded);
|
||||||
@ -144,21 +136,13 @@ struct Location {
|
|||||||
// operator== doesn't seem to work properly...
|
// operator== doesn't seem to work properly...
|
||||||
bool IsEqualTo(const Location& o) const {
|
bool IsEqualTo(const Location& o) const {
|
||||||
// When comparing, ignore the value of |interesting|.
|
// When comparing, ignore the value of |interesting|.
|
||||||
return
|
return raw_file_id == o.raw_file_id && line == o.line && column == o.column;
|
||||||
raw_file_id == o.raw_file_id &&
|
|
||||||
line == o.line &&
|
|
||||||
column == o.column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Location& o) const {
|
bool operator==(const Location& o) const { return IsEqualTo(o); }
|
||||||
return IsEqualTo(o);
|
|
||||||
}
|
|
||||||
bool operator<(const Location& o) const {
|
bool operator<(const Location& o) const {
|
||||||
return
|
return interesting < o.interesting && raw_file_id < o.raw_file_id &&
|
||||||
interesting < o.interesting &&
|
line < o.line && column < o.column;
|
||||||
raw_file_id < o.raw_file_id &&
|
|
||||||
line < o.line &&
|
|
||||||
column < o.column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Location WithInteresting(bool interesting) {
|
Location WithInteresting(bool interesting) {
|
||||||
@ -229,31 +213,29 @@ Location WithInteresting(bool interesting) {
|
|||||||
END_BITFIELD_TYPE()
|
END_BITFIELD_TYPE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct Ref {
|
struct Ref {
|
||||||
Id<T> id;
|
Id<T> id;
|
||||||
Location loc;
|
Location loc;
|
||||||
|
|
||||||
Ref() {} // For serialization.
|
Ref() {} // For serialization.
|
||||||
|
|
||||||
Ref(Id<T> id, Location loc) : id(id), loc(loc) {}
|
Ref(Id<T> id, Location loc) : id(id), loc(loc) {}
|
||||||
|
|
||||||
bool operator==(const Ref<T>& other) {
|
bool operator==(const Ref<T>& other) {
|
||||||
return id == other.id && loc == other.loc;
|
return id == other.id && loc == other.loc;
|
||||||
}
|
}
|
||||||
bool operator!=(const Ref<T>& other) {
|
bool operator!=(const Ref<T>& other) { return !(*this == other); }
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
bool operator<(const Ref<T>& other) const {
|
bool operator<(const Ref<T>& other) const {
|
||||||
return id < other.id && loc < other.loc;
|
return id < other.id && loc < other.loc;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
bool operator==(const Ref<T>& a, const Ref<T>& b) {
|
bool operator==(const Ref<T>& a, const Ref<T>& b) {
|
||||||
return a.id == b.id && a.loc == b.loc;
|
return a.id == b.id && a.loc == b.loc;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template <typename T>
|
||||||
bool operator!=(const Ref<T>& a, const Ref<T>& b) {
|
bool operator!=(const Ref<T>& a, const Ref<T>& b) {
|
||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
@ -262,13 +244,15 @@ using TypeRef = Ref<IndexedTypeDef>;
|
|||||||
using FuncRef = Ref<IndexedFuncDef>;
|
using FuncRef = Ref<IndexedFuncDef>;
|
||||||
using VarRef = Ref<IndexedVarDef>;
|
using VarRef = Ref<IndexedVarDef>;
|
||||||
|
|
||||||
|
|
||||||
// TODO: skip as much forward-processing as possible when |is_system_def| is
|
// TODO: skip as much forward-processing as possible when |is_system_def| is
|
||||||
// set to false.
|
// set to false.
|
||||||
// TODO: Either eliminate the defs created as a by-product of cross-referencing,
|
// TODO: Either eliminate the defs created as a by-product of cross-referencing,
|
||||||
// or do not emit things we don't have definitions for.
|
// or do not emit things we don't have definitions for.
|
||||||
|
|
||||||
template<typename TypeId = TypeId, typename FuncId = FuncId, typename VarId = VarId, typename Location = Location>
|
template <typename TypeId = TypeId,
|
||||||
|
typename FuncId = FuncId,
|
||||||
|
typename VarId = VarId,
|
||||||
|
typename Location = Location>
|
||||||
struct TypeDefDefinitionData {
|
struct TypeDefDefinitionData {
|
||||||
// General metadata.
|
// General metadata.
|
||||||
std::string usr;
|
std::string usr;
|
||||||
@ -298,26 +282,30 @@ struct TypeDefDefinitionData {
|
|||||||
std::vector<FuncId> funcs;
|
std::vector<FuncId> funcs;
|
||||||
std::vector<VarId> vars;
|
std::vector<VarId> vars;
|
||||||
|
|
||||||
TypeDefDefinitionData() {} // For reflection.
|
TypeDefDefinitionData() {} // For reflection.
|
||||||
TypeDefDefinitionData(const std::string& usr) : usr(usr) {}
|
TypeDefDefinitionData(const std::string& usr) : usr(usr) {}
|
||||||
|
|
||||||
bool operator==(const TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& other) const {
|
bool operator==(const TypeDefDefinitionData<TypeId, FuncId, VarId, Location>&
|
||||||
return
|
other) const {
|
||||||
usr == other.usr &&
|
return usr == other.usr && short_name == other.short_name &&
|
||||||
short_name == other.short_name &&
|
qualified_name == other.qualified_name &&
|
||||||
qualified_name == other.qualified_name &&
|
definition == other.definition && alias_of == other.alias_of &&
|
||||||
definition == other.definition &&
|
parents == other.parents && types == other.types &&
|
||||||
alias_of == other.alias_of &&
|
funcs == other.funcs && vars == other.vars;
|
||||||
parents == other.parents &&
|
|
||||||
types == other.types &&
|
|
||||||
funcs == other.funcs &&
|
|
||||||
vars == other.vars;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& other) const { return !(*this == other); }
|
bool operator!=(const TypeDefDefinitionData<TypeId, FuncId, VarId, Location>&
|
||||||
|
other) const {
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
template<typename TVisitor, typename TypeId, typename FuncId, typename VarId, typename Location>
|
template <typename TVisitor,
|
||||||
void Reflect(TVisitor& visitor, TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
|
typename TypeId,
|
||||||
|
typename FuncId,
|
||||||
|
typename VarId,
|
||||||
|
typename Location>
|
||||||
|
void Reflect(TVisitor& visitor,
|
||||||
|
TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER(usr);
|
REFLECT_MEMBER(usr);
|
||||||
REFLECT_MEMBER(short_name);
|
REFLECT_MEMBER(short_name);
|
||||||
@ -331,7 +319,6 @@ void Reflect(TVisitor& visitor, TypeDefDefinitionData<TypeId, FuncId, VarId, Loc
|
|||||||
REFLECT_MEMBER_END();
|
REFLECT_MEMBER_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct IndexedTypeDef {
|
struct IndexedTypeDef {
|
||||||
TypeDefDefinitionData<> def;
|
TypeDefDefinitionData<> def;
|
||||||
|
|
||||||
@ -346,7 +333,7 @@ struct IndexedTypeDef {
|
|||||||
|
|
||||||
bool is_bad_def = true;
|
bool is_bad_def = true;
|
||||||
|
|
||||||
IndexedTypeDef() : def("") {} // For serialization
|
IndexedTypeDef() : def("") {} // For serialization
|
||||||
|
|
||||||
IndexedTypeDef(TypeId id, const std::string& usr);
|
IndexedTypeDef(TypeId id, const std::string& usr);
|
||||||
|
|
||||||
@ -356,15 +343,19 @@ struct IndexedTypeDef {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <>
|
||||||
struct hash<IndexedTypeDef> {
|
struct hash<IndexedTypeDef> {
|
||||||
size_t operator()(const IndexedTypeDef& k) const {
|
size_t operator()(const IndexedTypeDef& k) const {
|
||||||
return hash<string>()(k.def.usr);
|
return hash<string>()(k.def.usr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeId = TypeId, typename FuncId = FuncId, typename VarId = VarId, typename FuncRef = FuncRef, typename Location = Location>
|
template <typename TypeId = TypeId,
|
||||||
|
typename FuncId = FuncId,
|
||||||
|
typename VarId = VarId,
|
||||||
|
typename FuncRef = FuncRef,
|
||||||
|
typename Location = Location>
|
||||||
struct FuncDefDefinitionData {
|
struct FuncDefDefinitionData {
|
||||||
// General metadata.
|
// General metadata.
|
||||||
std::string usr;
|
std::string usr;
|
||||||
@ -384,27 +375,36 @@ struct FuncDefDefinitionData {
|
|||||||
// Functions that this function calls.
|
// Functions that this function calls.
|
||||||
std::vector<FuncRef> callees;
|
std::vector<FuncRef> callees;
|
||||||
|
|
||||||
FuncDefDefinitionData() {} // For reflection.
|
FuncDefDefinitionData() {} // For reflection.
|
||||||
FuncDefDefinitionData(const std::string& usr) : usr(usr) {
|
FuncDefDefinitionData(const std::string& usr) : usr(usr) {
|
||||||
//assert(usr.size() > 0);
|
// assert(usr.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>& other) const {
|
bool operator==(
|
||||||
return
|
const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>&
|
||||||
usr == other.usr &&
|
other) const {
|
||||||
short_name == other.short_name &&
|
return usr == other.usr && short_name == other.short_name &&
|
||||||
qualified_name == other.qualified_name &&
|
qualified_name == other.qualified_name &&
|
||||||
definition == other.definition &&
|
definition == other.definition &&
|
||||||
declaring_type == other.declaring_type &&
|
declaring_type == other.declaring_type && base == other.base &&
|
||||||
base == other.base &&
|
locals == other.locals && callees == other.callees;
|
||||||
locals == other.locals &&
|
}
|
||||||
callees == other.callees;
|
bool operator!=(
|
||||||
|
const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>&
|
||||||
|
other) const {
|
||||||
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
bool operator!=(const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>& other) const { return !(*this == other); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename TVisitor, typename TypeId, typename FuncId, typename VarId, typename FuncRef, typename Location>
|
template <typename TVisitor,
|
||||||
void Reflect(TVisitor& visitor, FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>& value) {
|
typename TypeId,
|
||||||
|
typename FuncId,
|
||||||
|
typename VarId,
|
||||||
|
typename FuncRef,
|
||||||
|
typename Location>
|
||||||
|
void Reflect(
|
||||||
|
TVisitor& visitor,
|
||||||
|
FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER(usr);
|
REFLECT_MEMBER(usr);
|
||||||
REFLECT_MEMBER(short_name);
|
REFLECT_MEMBER(short_name);
|
||||||
@ -441,9 +441,9 @@ struct IndexedFuncDef {
|
|||||||
|
|
||||||
bool is_bad_def = true;
|
bool is_bad_def = true;
|
||||||
|
|
||||||
IndexedFuncDef() {} // For reflection.
|
IndexedFuncDef() {} // For reflection.
|
||||||
IndexedFuncDef(FuncId id, const std::string& usr) : id(id), def(usr) {
|
IndexedFuncDef(FuncId id, const std::string& usr) : id(id), def(usr) {
|
||||||
//assert(usr.size() > 0);
|
// assert(usr.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const IndexedFuncDef& other) const {
|
bool operator<(const IndexedFuncDef& other) const {
|
||||||
@ -452,15 +452,18 @@ struct IndexedFuncDef {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <>
|
||||||
struct hash<IndexedFuncDef> {
|
struct hash<IndexedFuncDef> {
|
||||||
size_t operator()(const IndexedFuncDef& k) const {
|
size_t operator()(const IndexedFuncDef& k) const {
|
||||||
return hash<string>()(k.def.usr);
|
return hash<string>()(k.def.usr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeId = TypeId, typename FuncId = FuncId, typename VarId = VarId, typename Location = Location>
|
template <typename TypeId = TypeId,
|
||||||
|
typename FuncId = FuncId,
|
||||||
|
typename VarId = VarId,
|
||||||
|
typename Location = Location>
|
||||||
struct VarDefDefinitionData {
|
struct VarDefDefinitionData {
|
||||||
// General metadata.
|
// General metadata.
|
||||||
std::string usr;
|
std::string usr;
|
||||||
@ -477,24 +480,30 @@ struct VarDefDefinitionData {
|
|||||||
// Type which declares this one (ie, it is a method)
|
// Type which declares this one (ie, it is a method)
|
||||||
optional<TypeId> declaring_type;
|
optional<TypeId> declaring_type;
|
||||||
|
|
||||||
VarDefDefinitionData() {} // For reflection.
|
VarDefDefinitionData() {} // For reflection.
|
||||||
VarDefDefinitionData(const std::string& usr) : usr(usr) {}
|
VarDefDefinitionData(const std::string& usr) : usr(usr) {}
|
||||||
|
|
||||||
bool operator==(const VarDefDefinitionData<TypeId, FuncId, VarId, Location>& other) const {
|
bool operator==(const VarDefDefinitionData<TypeId, FuncId, VarId, Location>&
|
||||||
return
|
other) const {
|
||||||
usr == other.usr &&
|
return usr == other.usr && short_name == other.short_name &&
|
||||||
short_name == other.short_name &&
|
qualified_name == other.qualified_name &&
|
||||||
qualified_name == other.qualified_name &&
|
declaration == other.declaration && definition == other.definition &&
|
||||||
declaration == other.declaration &&
|
variable_type == other.variable_type &&
|
||||||
definition == other.definition &&
|
declaring_type == other.declaring_type;
|
||||||
variable_type == other.variable_type &&
|
}
|
||||||
declaring_type == other.declaring_type;
|
bool operator!=(const VarDefDefinitionData<TypeId, FuncId, VarId, Location>&
|
||||||
|
other) const {
|
||||||
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
bool operator!=(const VarDefDefinitionData<TypeId, FuncId, VarId, Location>& other) const { return !(*this == other); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename TVisitor, typename TypeId, typename FuncId, typename VarId, typename Location>
|
template <typename TVisitor,
|
||||||
void Reflect(TVisitor& visitor, VarDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
|
typename TypeId,
|
||||||
|
typename FuncId,
|
||||||
|
typename VarId,
|
||||||
|
typename Location>
|
||||||
|
void Reflect(TVisitor& visitor,
|
||||||
|
VarDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER(usr);
|
REFLECT_MEMBER(usr);
|
||||||
REFLECT_MEMBER(short_name);
|
REFLECT_MEMBER(short_name);
|
||||||
@ -515,10 +524,10 @@ struct IndexedVarDef {
|
|||||||
|
|
||||||
bool is_bad_def = true;
|
bool is_bad_def = true;
|
||||||
|
|
||||||
IndexedVarDef() : def("") {} // For serialization
|
IndexedVarDef() : def("") {} // For serialization
|
||||||
|
|
||||||
IndexedVarDef(VarId id, const std::string& usr) : id(id), def(usr) {
|
IndexedVarDef(VarId id, const std::string& usr) : id(id), def(usr) {
|
||||||
//assert(usr.size() > 0);
|
// assert(usr.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const IndexedVarDef& other) const {
|
bool operator<(const IndexedVarDef& other) const {
|
||||||
@ -527,12 +536,12 @@ struct IndexedVarDef {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <>
|
||||||
struct hash<IndexedVarDef> {
|
struct hash<IndexedVarDef> {
|
||||||
size_t operator()(const IndexedVarDef& k) const {
|
size_t operator()(const IndexedVarDef& k) const {
|
||||||
return hash<string>()(k.def.usr);
|
return hash<string>()(k.def.usr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IdCache {
|
struct IdCache {
|
||||||
@ -576,6 +585,6 @@ struct IndexedFile {
|
|||||||
std::string ToString();
|
std::string ToString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IndexedFile Parse(std::string filename,
|
||||||
|
std::vector<std::string> args,
|
||||||
IndexedFile Parse(std::string filename, std::vector<std::string> args, bool dump_ast = false);
|
bool dump_ast = false);
|
Loading…
Reference in New Issue
Block a user