Misc formatting

This commit is contained in:
Jacob Dufault 2017-03-17 00:58:41 -07:00
parent 66771be32e
commit ada13f2939
5 changed files with 1291 additions and 1307 deletions

6
.clang_complete Normal file
View 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

File diff suppressed because it is too large Load Diff

View File

@ -72,6 +72,7 @@ std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::str
entry.args.push_back(clang::ToString(clang_CompileCommand_getArg(cx_command, j)));
}
result.push_back(entry);
}

File diff suppressed because it is too large Load Diff

153
indexer.h
View File

@ -26,7 +26,6 @@ struct IndexedVarDef;
using namespace std::experimental;
template <typename T>
struct Id {
uint64_t id;
@ -34,25 +33,18 @@ struct Id {
Id() : id(0) {} // Needed for containers. Do not use directly.
Id(uint64_t id) : id(id) {}
bool operator==(const Id<T>& other) const {
return id == other.id;
}
bool operator==(const Id<T>& other) const { return id == other.id; }
bool operator<(const Id<T>& other) const {
return id < other.id;
}
bool operator<(const Id<T>& other) const { return id < other.id; }
};
namespace std {
template <typename T>
struct hash<Id<T>> {
size_t operator()(const Id<T>& k) const {
return hash<uint64_t>()(k.id);
}
size_t operator()(const Id<T>& k) const { return hash<uint64_t>()(k.id); }
};
}
template <typename T>
bool operator==(const Id<T>& a, const Id<T>& b) {
assert(a.group == b.group && "Cannot compare Ids from different groups");
@ -87,9 +79,7 @@ struct Location {
this->column = column;
}
FileId file_id() const {
return FileId(raw_file_id);
}
FileId file_id() const { return FileId(raw_file_id); }
explicit Location(const char* encoded) : Location() {
int len = strlen(encoded);
@ -104,13 +94,15 @@ struct Location {
raw_file_id = atoi(encoded);
while (*encoded && *encoded != ':')
++encoded;
if (*encoded == ':') ++encoded;
if (*encoded == ':')
++encoded;
assert(encoded);
line = atoi(encoded);
while (*encoded && *encoded != ':')
++encoded;
if (*encoded == ':') ++encoded;
if (*encoded == ':')
++encoded;
assert(encoded);
column = atoi(encoded);
@ -144,21 +136,13 @@ struct Location {
// operator== doesn't seem to work properly...
bool IsEqualTo(const Location& o) const {
// When comparing, ignore the value of |interesting|.
return
raw_file_id == o.raw_file_id &&
line == o.line &&
column == o.column;
return raw_file_id == o.raw_file_id && line == o.line && column == o.column;
}
bool operator==(const Location& o) const {
return IsEqualTo(o);
}
bool operator==(const Location& o) const { return IsEqualTo(o); }
bool operator<(const Location& o) const {
return
interesting < o.interesting &&
raw_file_id < o.raw_file_id &&
line < o.line &&
column < o.column;
return interesting < o.interesting && raw_file_id < o.raw_file_id &&
line < o.line && column < o.column;
}
Location WithInteresting(bool interesting) {
@ -241,9 +225,7 @@ struct Ref {
bool operator==(const Ref<T>& other) {
return id == other.id && loc == other.loc;
}
bool operator!=(const Ref<T>& other) {
return !(*this == other);
}
bool operator!=(const Ref<T>& other) { return !(*this == other); }
bool operator<(const Ref<T>& other) const {
return id < other.id && loc < other.loc;
}
@ -262,13 +244,15 @@ using TypeRef = Ref<IndexedTypeDef>;
using FuncRef = Ref<IndexedFuncDef>;
using VarRef = Ref<IndexedVarDef>;
// TODO: skip as much forward-processing as possible when |is_system_def| is
// set to false.
// TODO: Either eliminate the defs created as a by-product of cross-referencing,
// 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 {
// General metadata.
std::string usr;
@ -301,23 +285,27 @@ struct TypeDefDefinitionData {
TypeDefDefinitionData() {} // For reflection.
TypeDefDefinitionData(const std::string& usr) : usr(usr) {}
bool operator==(const TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& other) const {
return
usr == other.usr &&
short_name == other.short_name &&
bool operator==(const TypeDefDefinitionData<TypeId, FuncId, VarId, Location>&
other) const {
return usr == other.usr && short_name == other.short_name &&
qualified_name == other.qualified_name &&
definition == other.definition &&
alias_of == other.alias_of &&
parents == other.parents &&
types == other.types &&
funcs == other.funcs &&
vars == other.vars;
definition == other.definition && alias_of == other.alias_of &&
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>
void Reflect(TVisitor& visitor, TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
template <typename TVisitor,
typename TypeId,
typename FuncId,
typename VarId,
typename Location>
void Reflect(TVisitor& visitor,
TypeDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(usr);
REFLECT_MEMBER(short_name);
@ -331,7 +319,6 @@ void Reflect(TVisitor& visitor, TypeDefDefinitionData<TypeId, FuncId, VarId, Loc
REFLECT_MEMBER_END();
}
struct IndexedTypeDef {
TypeDefDefinitionData<> def;
@ -364,7 +351,11 @@ namespace std {
};
}
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 {
// General metadata.
std::string usr;
@ -389,22 +380,31 @@ struct FuncDefDefinitionData {
// assert(usr.size() > 0);
}
bool operator==(const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>& other) const {
return
usr == other.usr &&
short_name == other.short_name &&
bool operator==(
const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>&
other) const {
return usr == other.usr && short_name == other.short_name &&
qualified_name == other.qualified_name &&
definition == other.definition &&
declaring_type == other.declaring_type &&
base == other.base &&
locals == other.locals &&
callees == other.callees;
declaring_type == other.declaring_type && base == other.base &&
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>
void Reflect(TVisitor& visitor, FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Location>& value) {
template <typename TVisitor,
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(usr);
REFLECT_MEMBER(short_name);
@ -460,7 +460,10 @@ namespace std {
};
}
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 {
// General metadata.
std::string usr;
@ -480,21 +483,27 @@ struct VarDefDefinitionData {
VarDefDefinitionData() {} // For reflection.
VarDefDefinitionData(const std::string& usr) : usr(usr) {}
bool operator==(const VarDefDefinitionData<TypeId, FuncId, VarId, Location>& other) const {
return
usr == other.usr &&
short_name == other.short_name &&
bool operator==(const VarDefDefinitionData<TypeId, FuncId, VarId, Location>&
other) const {
return usr == other.usr && short_name == other.short_name &&
qualified_name == other.qualified_name &&
declaration == other.declaration &&
definition == other.definition &&
declaration == other.declaration && definition == other.definition &&
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>
void Reflect(TVisitor& visitor, VarDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
template <typename TVisitor,
typename TypeId,
typename FuncId,
typename VarId,
typename Location>
void Reflect(TVisitor& visitor,
VarDefDefinitionData<TypeId, FuncId, VarId, Location>& value) {
REFLECT_MEMBER_START();
REFLECT_MEMBER(usr);
REFLECT_MEMBER(short_name);
@ -576,6 +585,6 @@ struct IndexedFile {
std::string ToString();
};
IndexedFile Parse(std::string filename, std::vector<std::string> args, bool dump_ast = false);
IndexedFile Parse(std::string filename,
std::vector<std::string> args,
bool dump_ast = false);