mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 17:11:59 +00:00
wip
This commit is contained in:
parent
46cec6f083
commit
a8cdadc201
@ -165,6 +165,89 @@ std::string Cursor::get_type_description() const {
|
|||||||
return spelling;
|
return spelling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Cursor::evaluate() const {
|
||||||
|
CXEvalResult eval = clang_Cursor_Evaluate(cx_cursor);
|
||||||
|
|
||||||
|
std::string result;
|
||||||
|
auto kind = clang_EvalResult_getKind(eval);
|
||||||
|
switch (clang_EvalResult_getKind(eval)) {
|
||||||
|
case CXEval_Int:
|
||||||
|
result = std::to_string(clang_EvalResult_getAsInt(eval));
|
||||||
|
break;
|
||||||
|
case CXEval_Float:
|
||||||
|
result = std::to_string(clang_EvalResult_getAsDouble(eval));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
const char* r = clang_EvalResult_getAsStr(eval);
|
||||||
|
if (r)
|
||||||
|
result = r;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clang_EvalResult_dispose(eval);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
#if false
|
||||||
|
typedef enum {
|
||||||
|
CXEval_Int = 1,
|
||||||
|
CXEval_Float = 2,
|
||||||
|
CXEval_ObjCStrLiteral = 3,
|
||||||
|
CXEval_StrLiteral = 4,
|
||||||
|
CXEval_CFStr = 5,
|
||||||
|
CXEval_Other = 6,
|
||||||
|
|
||||||
|
CXEval_UnExposed = 0
|
||||||
|
|
||||||
|
} CXEvalResultKind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Evaluation result of a cursor
|
||||||
|
*/
|
||||||
|
typedef void * CXEvalResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief If cursor is a statement declaration tries to evaluate the
|
||||||
|
* statement and if its variable, tries to evaluate its initializer,
|
||||||
|
* into its corresponding type.
|
||||||
|
*/
|
||||||
|
CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns the kind of the evaluated result.
|
||||||
|
*/
|
||||||
|
CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns the evaluation result as integer if the
|
||||||
|
* kind is Int.
|
||||||
|
*/
|
||||||
|
CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns the evaluation result as double if the
|
||||||
|
* kind is double.
|
||||||
|
*/
|
||||||
|
CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns the evaluation result as a constant string if the
|
||||||
|
* kind is other than Int or float. User must not free this pointer,
|
||||||
|
* instead call clang_EvalResult_dispose on the CXEvalResult returned
|
||||||
|
* by clang_Cursor_Evaluate.
|
||||||
|
*/
|
||||||
|
CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Disposes the created Eval memory.
|
||||||
|
*/
|
||||||
|
CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::string Cursor::get_comments() const {
|
std::string Cursor::get_comments() const {
|
||||||
Cursor referenced = get_referenced();
|
Cursor referenced = get_referenced();
|
||||||
if (referenced)
|
if (referenced)
|
||||||
|
@ -57,6 +57,9 @@ public:
|
|||||||
Cursor get_semantic_parent() const;
|
Cursor get_semantic_parent() const;
|
||||||
std::vector<Cursor> get_arguments() const;
|
std::vector<Cursor> get_arguments() const;
|
||||||
bool is_valid_kind() const;
|
bool is_valid_kind() const;
|
||||||
|
|
||||||
|
std::string evaluate() const;
|
||||||
|
|
||||||
std::string get_type_description() const;
|
std::string get_type_description() const;
|
||||||
std::string get_comments() const;
|
std::string get_comments() const;
|
||||||
|
|
||||||
|
391
main.cpp
391
main.cpp
@ -1,3 +1,4 @@
|
|||||||
|
#include <algorithm>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -157,7 +158,7 @@ struct ParsingDatabase {
|
|||||||
FuncDef* Resolve(FuncId id);
|
FuncDef* Resolve(FuncId id);
|
||||||
VarDef* Resolve(VarId id);
|
VarDef* Resolve(VarId id);
|
||||||
|
|
||||||
std::string ToString(bool for_test);
|
std::string ToString();
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeId ParsingDatabase::ToTypeId(const std::string& usr) {
|
TypeId ParsingDatabase::ToTypeId(const std::string& usr) {
|
||||||
@ -201,64 +202,100 @@ VarDef* ParsingDatabase::Resolve(VarId id) {
|
|||||||
return &vars[id.local_id];
|
return &vars[id.local_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter>
|
|
||||||
void WriteLocation(TWriter& writer, clang::SourceLocation location) {
|
using Writer = rapidjson::PrettyWriter<rapidjson::StringBuffer>;
|
||||||
|
|
||||||
|
void Write(Writer& writer, const char* key, clang::SourceLocation location) {
|
||||||
|
if (key) writer.Key(key);
|
||||||
std::string s = location.ToString();
|
std::string s = location.ToString();
|
||||||
writer.String(s.c_str());
|
writer.String(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter>
|
void Write(Writer& writer, const char* key, std::optional<clang::SourceLocation> location) {
|
||||||
void WriteLocation(TWriter& writer, std::optional<clang::SourceLocation> location) {
|
if (location) {
|
||||||
if (location)
|
Write(writer, key, location.value());
|
||||||
WriteLocation(writer, location.value());
|
}
|
||||||
else
|
//else {
|
||||||
writer.Null();
|
// if (key) writer.Key(key);
|
||||||
|
// writer.Null();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter, typename TId>
|
void Write(Writer& writer, const char* key, const std::vector<clang::SourceLocation>& locs) {
|
||||||
void WriteId(TWriter& writer, TId id) {
|
if (locs.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (key) writer.Key(key);
|
||||||
|
writer.StartArray();
|
||||||
|
for (const clang::SourceLocation& loc : locs)
|
||||||
|
Write(writer, nullptr, loc);
|
||||||
|
writer.EndArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Write(Writer& writer, const char* key, LocalId<T> id) {
|
||||||
|
if (key) writer.Key(key);
|
||||||
writer.Uint64(id.local_id);
|
writer.Uint64(id.local_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter, typename TId>
|
template<typename T>
|
||||||
void WriteId(TWriter& writer, std::optional<TId> id) {
|
void Write(Writer& writer, const char* key, std::optional<LocalId<T>> id) {
|
||||||
if (id)
|
if (id) {
|
||||||
WriteId(writer, id.value());
|
Write(writer, key, id.value());
|
||||||
else
|
}
|
||||||
writer.Null();
|
//else {
|
||||||
|
// if (key) writer.Key(key);
|
||||||
|
// writer.Null();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter, typename TRef>
|
template<typename T>
|
||||||
void WriteRef(TWriter& writer, TRef ref) {
|
void Write(Writer& writer, const char* key, const std::vector<LocalId<T>>& ids) {
|
||||||
|
if (ids.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (key) writer.Key(key);
|
||||||
|
writer.StartArray();
|
||||||
|
for (LocalId<T> id : ids)
|
||||||
|
Write(writer, nullptr, id);
|
||||||
|
writer.EndArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Write(Writer& writer, const char* key, Ref<T> ref) {
|
||||||
|
if (key) writer.Key(key);
|
||||||
std::string s = std::to_string(ref.id.local_id) + "@" + ref.loc.ToString();
|
std::string s = std::to_string(ref.id.local_id) + "@" + ref.loc.ToString();
|
||||||
writer.String(s.c_str());
|
writer.String(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter, typename TId>
|
template<typename T>
|
||||||
void WriteIdArray(TWriter& writer, const std::vector<TId>& ids) {
|
void Write(Writer& writer, const char* key, const std::vector<Ref<T>>& refs) {
|
||||||
|
if (refs.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (key) writer.Key(key);
|
||||||
writer.StartArray();
|
writer.StartArray();
|
||||||
for (TId id : ids)
|
for (Ref<T> ref : refs)
|
||||||
WriteId(writer, id);
|
Write(writer, nullptr, ref);
|
||||||
writer.EndArray();
|
writer.EndArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter, typename TRef>
|
void Write(Writer& writer, const char* key, const std::string& value) {
|
||||||
void WriteRefArray(TWriter& writer, const std::vector<TRef>& refs) {
|
if (value.size() == 0)
|
||||||
writer.StartArray();
|
return;
|
||||||
for (TRef ref : refs)
|
|
||||||
WriteRef(writer, ref);
|
if (key) writer.Key(key);
|
||||||
writer.EndArray();
|
writer.String(value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TWriter>
|
void Write(Writer& writer, const char* key, uint64_t value) {
|
||||||
void WriteLocationArray(TWriter& writer, const std::vector<clang::SourceLocation>& locs) {
|
if (key) writer.Key(key);
|
||||||
writer.StartArray();
|
writer.Uint64(value);
|
||||||
for (const clang::SourceLocation& loc : locs)
|
|
||||||
WriteLocation(writer, loc);
|
|
||||||
writer.EndArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ParsingDatabase::ToString(bool for_test) {
|
std::string ParsingDatabase::ToString() {
|
||||||
|
#define WRITE(name) Write(writer, #name, def.name)
|
||||||
|
|
||||||
rapidjson::StringBuffer output;
|
rapidjson::StringBuffer output;
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(output);
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(output);
|
||||||
writer.SetFormatOptions(
|
writer.SetFormatOptions(
|
||||||
@ -272,50 +309,18 @@ std::string ParsingDatabase::ToString(bool for_test) {
|
|||||||
writer.StartArray();
|
writer.StartArray();
|
||||||
for (TypeDef& def : types) {
|
for (TypeDef& def : types) {
|
||||||
writer.StartObject();
|
writer.StartObject();
|
||||||
|
WRITE(id);
|
||||||
writer.String("id");
|
WRITE(usr);
|
||||||
writer.Uint64(def.id.local_id);
|
WRITE(short_name);
|
||||||
|
WRITE(qualified_name);
|
||||||
if (!for_test) {
|
WRITE(declaration);
|
||||||
writer.String("usr");
|
WRITE(definition);
|
||||||
writer.String(def.usr.c_str());
|
WRITE(parents);
|
||||||
}
|
WRITE(derived);
|
||||||
|
WRITE(types);
|
||||||
writer.String("short_name");
|
WRITE(funcs);
|
||||||
writer.String(def.short_name.c_str());
|
WRITE(vars);
|
||||||
|
WRITE(uses);
|
||||||
writer.String("qualified_name");
|
|
||||||
writer.String(def.qualified_name.c_str());
|
|
||||||
|
|
||||||
writer.String("declaration");
|
|
||||||
WriteLocation(writer, def.declaration);
|
|
||||||
|
|
||||||
if (!def.definition) {
|
|
||||||
writer.EndObject();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.String("definition");
|
|
||||||
WriteLocation(writer, def.definition);
|
|
||||||
|
|
||||||
writer.String("parents");
|
|
||||||
WriteIdArray(writer, def.parents);
|
|
||||||
|
|
||||||
writer.String("derived");
|
|
||||||
WriteIdArray(writer, def.derived);
|
|
||||||
|
|
||||||
writer.String("types");
|
|
||||||
WriteIdArray(writer, def.types);
|
|
||||||
|
|
||||||
writer.String("funcs");
|
|
||||||
WriteIdArray(writer, def.funcs);
|
|
||||||
|
|
||||||
writer.String("vars");
|
|
||||||
WriteIdArray(writer, def.vars);
|
|
||||||
|
|
||||||
writer.String("uses");
|
|
||||||
WriteLocationArray(writer, def.uses);
|
|
||||||
|
|
||||||
writer.EndObject();
|
writer.EndObject();
|
||||||
}
|
}
|
||||||
writer.EndArray();
|
writer.EndArray();
|
||||||
@ -325,54 +330,19 @@ std::string ParsingDatabase::ToString(bool for_test) {
|
|||||||
writer.StartArray();
|
writer.StartArray();
|
||||||
for (FuncDef& def : funcs) {
|
for (FuncDef& def : funcs) {
|
||||||
writer.StartObject();
|
writer.StartObject();
|
||||||
|
WRITE(id);
|
||||||
writer.String("id");
|
WRITE(usr);
|
||||||
writer.Uint64(def.id.local_id);
|
WRITE(short_name);
|
||||||
|
WRITE(qualified_name);
|
||||||
if (!for_test) {
|
WRITE(declaration);
|
||||||
writer.String("usr");
|
WRITE(definition);
|
||||||
writer.String(def.usr.c_str());
|
WRITE(declaring_type);
|
||||||
}
|
WRITE(base);
|
||||||
|
WRITE(derived);
|
||||||
writer.String("short_name");
|
WRITE(locals);
|
||||||
writer.String(def.short_name.c_str());
|
WRITE(callers);
|
||||||
|
WRITE(callees);
|
||||||
writer.String("qualified_name");
|
WRITE(uses);
|
||||||
writer.String(def.qualified_name.c_str());
|
|
||||||
|
|
||||||
writer.String("declaration");
|
|
||||||
WriteLocation(writer, def.declaration);
|
|
||||||
|
|
||||||
if (def.definition) {
|
|
||||||
writer.String("definition");
|
|
||||||
WriteLocation(writer, def.definition);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (def.definition || def.declaring_type) {
|
|
||||||
writer.String("declaring_type");
|
|
||||||
WriteId(writer, def.declaring_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (def.definition) {
|
|
||||||
writer.String("base");
|
|
||||||
WriteId(writer, def.base);
|
|
||||||
|
|
||||||
writer.String("derived");
|
|
||||||
WriteIdArray(writer, def.derived);
|
|
||||||
|
|
||||||
writer.String("locals");
|
|
||||||
WriteIdArray(writer, def.locals);
|
|
||||||
|
|
||||||
writer.String("callers");
|
|
||||||
WriteRefArray(writer, def.callers);
|
|
||||||
|
|
||||||
writer.String("callees");
|
|
||||||
WriteRefArray(writer, def.callees);
|
|
||||||
|
|
||||||
writer.String("uses");
|
|
||||||
WriteLocationArray(writer, def.uses);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.EndObject();
|
writer.EndObject();
|
||||||
}
|
}
|
||||||
writer.EndArray();
|
writer.EndArray();
|
||||||
@ -382,36 +352,15 @@ std::string ParsingDatabase::ToString(bool for_test) {
|
|||||||
writer.StartArray();
|
writer.StartArray();
|
||||||
for (VarDef& def : vars) {
|
for (VarDef& def : vars) {
|
||||||
writer.StartObject();
|
writer.StartObject();
|
||||||
|
WRITE(id);
|
||||||
writer.String("id");
|
WRITE(usr);
|
||||||
writer.Uint64(def.id.local_id);
|
WRITE(short_name);
|
||||||
|
WRITE(qualified_name);
|
||||||
if (!for_test) {
|
WRITE(declaration);
|
||||||
writer.String("usr");
|
WRITE(initializations);
|
||||||
writer.String(def.usr.c_str());
|
WRITE(variable_type);
|
||||||
}
|
WRITE(declaring_type);
|
||||||
|
WRITE(uses);
|
||||||
writer.String("short_name");
|
|
||||||
writer.String(def.short_name.c_str());
|
|
||||||
|
|
||||||
writer.String("qualified_name");
|
|
||||||
writer.String(def.qualified_name.c_str());
|
|
||||||
|
|
||||||
writer.String("declaration");
|
|
||||||
WriteLocation(writer, def.declaration);
|
|
||||||
|
|
||||||
writer.String("initializations");
|
|
||||||
WriteLocationArray(writer, def.initializations);
|
|
||||||
|
|
||||||
writer.String("variable_type");
|
|
||||||
WriteId(writer, def.variable_type);
|
|
||||||
|
|
||||||
writer.String("declaring_type");
|
|
||||||
WriteId(writer, def.declaring_type);
|
|
||||||
|
|
||||||
writer.String("uses");
|
|
||||||
WriteLocationArray(writer, def.uses);
|
|
||||||
|
|
||||||
writer.EndObject();
|
writer.EndObject();
|
||||||
}
|
}
|
||||||
writer.EndArray();
|
writer.EndArray();
|
||||||
@ -419,6 +368,8 @@ std::string ParsingDatabase::ToString(bool for_test) {
|
|||||||
writer.EndObject();
|
writer.EndObject();
|
||||||
|
|
||||||
return output.GetString();
|
return output.GetString();
|
||||||
|
|
||||||
|
#undef WRITE
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FileDef {
|
struct FileDef {
|
||||||
@ -580,7 +531,6 @@ void Dump(clang::Cursor cursor) {
|
|||||||
|
|
||||||
|
|
||||||
void HandleVarDecl(ParsingDatabase* db, NamespaceStack* ns, clang::Cursor var, std::optional<TypeId> declaring_type) {
|
void HandleVarDecl(ParsingDatabase* db, NamespaceStack* ns, clang::Cursor var, std::optional<TypeId> declaring_type) {
|
||||||
|
|
||||||
//Dump(var);
|
//Dump(var);
|
||||||
|
|
||||||
VarId var_id = db->ToVarId(var.get_usr());
|
VarId var_id = db->ToVarId(var.get_usr());
|
||||||
@ -622,25 +572,34 @@ void HandleVarDecl(ParsingDatabase* db, NamespaceStack* ns, clang::Cursor var, s
|
|||||||
|
|
||||||
// |func_id| is the function definition that is currently being processed.
|
// |func_id| is the function definition that is currently being processed.
|
||||||
void InsertReference(ParsingDatabase* db, FuncId func_id, clang::Cursor referencer) {
|
void InsertReference(ParsingDatabase* db, FuncId func_id, clang::Cursor referencer) {
|
||||||
|
clang::SourceLocation loc = referencer.get_source_location();
|
||||||
clang::Cursor referenced = referencer.get_referenced();
|
clang::Cursor referenced = referencer.get_referenced();
|
||||||
|
|
||||||
switch (referenced.get_kind()) {
|
switch (referenced.get_kind()) {
|
||||||
|
case CXCursor_CXXMethod:
|
||||||
case CXCursor_FunctionDecl:
|
case CXCursor_FunctionDecl:
|
||||||
{
|
{
|
||||||
FuncId referenced_id = db->ToFuncId(referenced.get_usr());
|
FuncId referenced_id = db->ToFuncId(referenced.get_usr());
|
||||||
clang::SourceLocation loc = referencer.get_source_location();
|
|
||||||
|
|
||||||
FuncDef* func_def = db->Resolve(func_id);
|
|
||||||
FuncDef* referenced_def = db->Resolve(referenced_id);
|
FuncDef* referenced_def = db->Resolve(referenced_id);
|
||||||
|
FuncDef* func_def = db->Resolve(func_id);
|
||||||
|
|
||||||
func_def->callees.push_back(FuncRef(referenced_id, loc));
|
func_def->callees.push_back(FuncRef(referenced_id, loc));
|
||||||
referenced_def->callers.push_back(FuncRef(func_id, loc));
|
referenced_def->callers.push_back(FuncRef(func_id, loc));
|
||||||
referenced_def->uses.push_back(loc);
|
referenced_def->uses.push_back(loc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case CXCursor_VarDecl:
|
||||||
|
{
|
||||||
|
VarId referenced_id = db->ToVarId(referenced.get_usr());
|
||||||
|
VarDef* referenced_def = db->Resolve(referenced_id);
|
||||||
|
|
||||||
|
referenced_def->uses.push_back(loc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
std::cerr << "Unhandled reference from " << referencer.ToString() << " to "
|
std::cerr << "Unhandled reference from \"" << referencer.ToString()
|
||||||
<< referenced.ToString() << std::endl;
|
<< "\" to \"" << referenced.ToString() << "\"" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,21 +615,27 @@ struct FuncDefinitionParam {
|
|||||||
};
|
};
|
||||||
|
|
||||||
clang::VisiterResult VisitFuncDefinition(clang::Cursor cursor, clang::Cursor parent, FuncDefinitionParam* param) {
|
clang::VisiterResult VisitFuncDefinition(clang::Cursor cursor, clang::Cursor parent, FuncDefinitionParam* param) {
|
||||||
//std::cout << "VistFunc got " << cursor.ToString() << std::endl;
|
//std::cout << "VistFuncDefinition got " << cursor.ToString() << std::endl;
|
||||||
switch (cursor.get_kind()) {
|
switch (cursor.get_kind()) {
|
||||||
// TODO: Maybe we should default to recurse?
|
// TODO: Maybe we should default to recurse?
|
||||||
/*
|
/*
|
||||||
case CXCursor_CompoundStmt:
|
case CXCursor_CompoundStmt:
|
||||||
case CXCursor_DeclStmt:
|
case CXCursor_DeclStmt:
|
||||||
case CXCursor_CallExpr:
|
case CXCursor_CallExpr:
|
||||||
case CXCursor_UnexposedExpr:
|
case CXCursor_UnexposedExpr:
|
||||||
case CXCursor_UnaryExpr:
|
case CXCursor_UnaryExpr:
|
||||||
return clang::VisiterResult::Recurse;
|
return clang::VisiterResult::Recurse;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
case CXCursor_CallExpr:
|
||||||
|
// The called element is handled by DeclRefExpr below.
|
||||||
|
//InsertReference(param->db, param->func_id, cursor);
|
||||||
|
return clang::VisiterResult::Recurse;
|
||||||
|
|
||||||
|
case CXCursor_MemberRefExpr:
|
||||||
case CXCursor_DeclRefExpr:
|
case CXCursor_DeclRefExpr:
|
||||||
InsertReference(param->db, param->func_id, cursor);
|
InsertReference(param->db, param->func_id, cursor);
|
||||||
break;
|
return clang::VisiterResult::Continue;
|
||||||
|
|
||||||
case CXCursor_VarDecl:
|
case CXCursor_VarDecl:
|
||||||
case CXCursor_ParmDecl:
|
case CXCursor_ParmDecl:
|
||||||
@ -832,6 +797,7 @@ clang::VisiterResult VisitFile(clang::Cursor cursor, clang::Cursor parent, FileP
|
|||||||
param->ns->Pop();
|
param->ns->Pop();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CXCursor_StructDecl:
|
||||||
case CXCursor_ClassDecl:
|
case CXCursor_ClassDecl:
|
||||||
// TODO: Cleanup Handle* param order.
|
// TODO: Cleanup Handle* param order.
|
||||||
HandleClassDecl(cursor, param->db, param->ns);
|
HandleClassDecl(cursor, param->db, param->ns);
|
||||||
@ -900,12 +866,76 @@ void Write(const std::vector<std::string>& strs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> split_string(const std::string& str, const std::string& delimiter) {
|
||||||
|
// http://stackoverflow.com/a/13172514
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
|
||||||
|
std::string::size_type pos = 0;
|
||||||
|
std::string::size_type prev = 0;
|
||||||
|
while ((pos = str.find(delimiter, prev)) != std::string::npos) {
|
||||||
|
strings.push_back(str.substr(prev, pos - prev));
|
||||||
|
prev = pos + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To get the last substring (or only, if delimiter is not found)
|
||||||
|
strings.push_back(str.substr(prev));
|
||||||
|
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiffDocuments(rapidjson::Document& expected, rapidjson::Document& actual) {
|
||||||
|
std::vector<std::string> actual_output;
|
||||||
|
{
|
||||||
|
rapidjson::StringBuffer buffer;
|
||||||
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||||
|
writer.SetFormatOptions(
|
||||||
|
rapidjson::PrettyFormatOptions::kFormatSingleLineArray);
|
||||||
|
writer.SetIndent(' ', 2);
|
||||||
|
|
||||||
|
buffer.Clear();
|
||||||
|
actual.Accept(writer);
|
||||||
|
actual_output = split_string(buffer.GetString(), "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> expected_output;
|
||||||
|
{
|
||||||
|
rapidjson::StringBuffer buffer;
|
||||||
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||||
|
writer.SetFormatOptions(
|
||||||
|
rapidjson::PrettyFormatOptions::kFormatSingleLineArray);
|
||||||
|
writer.SetIndent(' ', 2);
|
||||||
|
|
||||||
|
buffer.Clear();
|
||||||
|
expected.Accept(writer);
|
||||||
|
expected_output = split_string(buffer.GetString(), "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int len = std::min(actual_output.size(), expected_output.size());
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
if (actual_output[i] != expected_output[i]) {
|
||||||
|
std::cout << "Line " << i << " differs" << std::endl;
|
||||||
|
std::cout << " expected: " << expected_output[i] << std::endl;
|
||||||
|
std::cout << " actual: " << actual_output[i] << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actual_output.size() > len) {
|
||||||
|
std::cout << "Additional output in actual:" << std::endl;
|
||||||
|
for (int i = len; i < actual_output.size(); ++i)
|
||||||
|
std::cout << " " << actual_output[i] << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expected_output.size() > len) {
|
||||||
|
std::cout << "Additional output in expected:" << std::endl;
|
||||||
|
for (int i = len; i < expected_output.size(); ++i)
|
||||||
|
std::cout << " " << expected_output[i] << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
for (std::string path : GetFilesInFolder("tests")) {
|
for (std::string path : GetFilesInFolder("tests")) {
|
||||||
// TODO: Fix all existing tests.
|
// TODO: Fix all existing tests.
|
||||||
if (path != "tests/usage/func_usage_addr_func.cc") continue;
|
//if (path != "tests/usage/func_usage_class_inline_var_def.cc") continue;
|
||||||
|
|
||||||
// Parse expected output from the test, parse it into JSON document.
|
// Parse expected output from the test, parse it into JSON document.
|
||||||
std::string expected_output;
|
std::string expected_output;
|
||||||
@ -916,7 +946,7 @@ int main(int argc, char** argv) {
|
|||||||
// Run test.
|
// Run test.
|
||||||
std::cout << "[START] " << path << std::endl;
|
std::cout << "[START] " << path << std::endl;
|
||||||
ParsingDatabase db = Parse(path);
|
ParsingDatabase db = Parse(path);
|
||||||
std::string actual_output = db.ToString(true /*for_test*/);
|
std::string actual_output = db.ToString();
|
||||||
rapidjson::Document actual;
|
rapidjson::Document actual;
|
||||||
actual.Parse(actual_output.c_str());
|
actual.Parse(actual_output.c_str());
|
||||||
|
|
||||||
@ -929,10 +959,15 @@ int main(int argc, char** argv) {
|
|||||||
std::cout << expected_output;
|
std::cout << expected_output;
|
||||||
std::cout << "Actual output for " << path << ":" << std::endl;
|
std::cout << "Actual output for " << path << ":" << std::endl;
|
||||||
std::cout << actual_output;
|
std::cout << actual_output;
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
DiffDocuments(expected, actual);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cin.get();
|
std::cin.get();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: ctor/dtor, copy ctor
|
@ -8,16 +8,11 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": "tests/class_forward_declaration.cc:1:7",
|
"declaration": "tests/class_forward_declaration.cc:1:7",
|
||||||
"definition": "tests/class_forward_declaration.cc:3:7",
|
"definition": "tests/class_forward_declaration.cc:3:7"
|
||||||
"parents": [],
|
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"variables": []
|
"variables": []
|
||||||
|
@ -6,6 +6,7 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#I#I#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": "tests/function_declaration.cc:1:6"
|
"declaration": "tests/function_declaration.cc:1:6"
|
||||||
|
@ -8,17 +8,11 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": "tests/function_declaration_definition.cc:1:6",
|
"declaration": "tests/function_declaration_definition.cc:1:6",
|
||||||
"definition": "tests/function_declaration_definition.cc:3:6",
|
"definition": "tests/function_declaration_definition.cc:3:6"
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,10 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": null,
|
"definition": "tests/function_definition.cc:1:6"
|
||||||
"definition": "tests/function_definition.cc:1:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,15 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/method_declaration.cc:1:7",
|
"definition": "tests/method_declaration.cc:1:7",
|
||||||
"parents": [],
|
"funcs": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [0],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "Foo::foo",
|
"qualified_name": "Foo::foo",
|
||||||
"declaration": "tests/method_declaration.cc:2:8",
|
"declaration": "tests/method_declaration.cc:2:8",
|
||||||
|
@ -5,36 +5,24 @@ class Foo {
|
|||||||
void Foo::foo() {}
|
void Foo::foo() {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// TODO: We are not inserting methods into declaring TypeDef.
|
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/method_definition.cc:1:7",
|
"definition": "tests/method_definition.cc:1:7",
|
||||||
"parents": [],
|
"funcs": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [0],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "Foo::foo",
|
"qualified_name": "Foo::foo",
|
||||||
"declaration": "tests/method_definition.cc:2:8",
|
"declaration": "tests/method_definition.cc:2:8",
|
||||||
"definition": "tests/method_definition.cc:5:11",
|
"definition": "tests/method_definition.cc:5:11",
|
||||||
"declaring_type": 0,
|
"declaring_type": 0
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -7,30 +7,19 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/method_inline_declaration.cc:1:7",
|
"definition": "tests/method_inline_declaration.cc:1:7",
|
||||||
"parents": [],
|
"funcs": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [0],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "Foo::foo",
|
"qualified_name": "Foo::foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/method_inline_declaration.cc:2:8",
|
"definition": "tests/method_inline_declaration.cc:2:8",
|
||||||
"declaring_type": 0,
|
"declaring_type": 0
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:anonymous_function.cc@aN@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "::foo",
|
"qualified_name": "::foo",
|
||||||
"declaration": "tests/namespaces/anonymous_function.cc:2:6"
|
"declaration": "tests/namespaces/anonymous_function.cc:2:6"
|
||||||
|
@ -8,6 +8,7 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@F@foo#I#I#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "hello::foo",
|
"qualified_name": "hello::foo",
|
||||||
"declaration": "tests/namespaces/function_declaration.cc:2:6"
|
"declaration": "tests/namespaces/function_declaration.cc:2:6"
|
||||||
|
@ -8,17 +8,10 @@ OUTPUT:
|
|||||||
"types": [],
|
"types": [],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "hello::foo",
|
"qualified_name": "hello::foo",
|
||||||
"declaration": null,
|
"definition": "tests/namespaces/function_definition.cc:2:6"
|
||||||
"definition": "tests/namespaces/function_definition.cc:2:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,15 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "hello::Foo",
|
"qualified_name": "hello::Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/namespaces/method_declaration.cc:2:7",
|
"definition": "tests/namespaces/method_declaration.cc:2:7",
|
||||||
"parents": [],
|
"funcs": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [0],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@S@Foo@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "hello::Foo::foo",
|
"qualified_name": "hello::Foo::foo",
|
||||||
"declaration": "tests/namespaces/method_declaration.cc:3:8",
|
"declaration": "tests/namespaces/method_declaration.cc:3:8",
|
||||||
|
@ -11,30 +11,20 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "hello::Foo",
|
"qualified_name": "hello::Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/namespaces/method_definition.cc:2:7",
|
"definition": "tests/namespaces/method_definition.cc:2:7",
|
||||||
"parents": [],
|
"funcs": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [0],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@S@Foo@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "hello::Foo::foo",
|
"qualified_name": "hello::Foo::foo",
|
||||||
"declaration": "tests/namespaces/method_definition.cc:3:8",
|
"declaration": "tests/namespaces/method_definition.cc:3:8",
|
||||||
"definition": "tests/namespaces/method_definition.cc:6:11",
|
"definition": "tests/namespaces/method_definition.cc:6:11",
|
||||||
"declaring_type": 0,
|
"declaring_type": 0
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -9,30 +9,19 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "hello::Foo",
|
"qualified_name": "hello::Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/namespaces/method_inline_declaration.cc:2:7",
|
"definition": "tests/namespaces/method_inline_declaration.cc:2:7",
|
||||||
"parents": [],
|
"funcs": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [0],
|
|
||||||
"vars": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@N@hello@S@Foo@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "hello::Foo::foo",
|
"qualified_name": "hello::Foo::foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/namespaces/method_inline_declaration.cc:3:8",
|
"definition": "tests/namespaces/method_inline_declaration.cc:3:8",
|
||||||
"declaring_type": 0,
|
"declaring_type": 0
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -8,72 +8,50 @@ void user() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
// NOTE: used only has one caller!!
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@consume#*v#",
|
||||||
"short_name": "consume",
|
"short_name": "consume",
|
||||||
"qualified_name": "consume",
|
"qualified_name": "consume",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/usage/func_usage_addr_func.cc:1:6",
|
"definition": "tests/usage/func_usage_addr_func.cc:1:6",
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": ["2@tests/usage/func_usage_addr_func.cc:7:3"],
|
"callers": ["2@tests/usage/func_usage_addr_func.cc:7:3"],
|
||||||
"callees": [],
|
|
||||||
"uses": ["tests/usage/func_usage_addr_func.cc:7:3"]
|
"uses": ["tests/usage/func_usage_addr_func.cc:7:3"]
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
"usr": "c:@F@used#",
|
||||||
"short_name": "used",
|
"short_name": "used",
|
||||||
"qualified_name": "used",
|
"qualified_name": "used",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/usage/func_usage_addr_func.cc:3:6",
|
"definition": "tests/usage/func_usage_addr_func.cc:3:6",
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": ["2@tests/usage/func_usage_addr_func.cc:6:13", "2@tests/usage/func_usage_addr_func.cc:7:12"],
|
"callers": ["2@tests/usage/func_usage_addr_func.cc:6:13", "2@tests/usage/func_usage_addr_func.cc:7:12"],
|
||||||
"callees": [],
|
|
||||||
"uses": ["tests/usage/func_usage_addr_func.cc:6:13", "tests/usage/func_usage_addr_func.cc:7:12"]
|
"uses": ["tests/usage/func_usage_addr_func.cc:6:13", "tests/usage/func_usage_addr_func.cc:7:12"]
|
||||||
}, {
|
}, {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
|
"usr": "c:@F@user#",
|
||||||
"short_name": "user",
|
"short_name": "user",
|
||||||
"qualified_name": "user",
|
"qualified_name": "user",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/usage/func_usage_addr_func.cc:5:6",
|
"definition": "tests/usage/func_usage_addr_func.cc:5:6",
|
||||||
"declaring_type": null,
|
"callees": ["1@tests/usage/func_usage_addr_func.cc:6:13", "0@tests/usage/func_usage_addr_func.cc:7:3", "1@tests/usage/func_usage_addr_func.cc:7:12"]
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": ["1@tests/usage/func_usage_addr_func.cc:6:13", "0@tests/usage/func_usage_addr_func.cc:7:3", "1@tests/usage/func_usage_addr_func.cc:7:12"],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": "tests/usage/func_usage_addr_func.cc:1:19",
|
"declaration": "tests/usage/func_usage_addr_func.cc:1:19",
|
||||||
"initializations": ["tests/usage/func_usage_addr_func.cc:1:19"],
|
"initializations": ["tests/usage/func_usage_addr_func.cc:1:19"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
"usr": "c:func_usage_addr_func.cc@61@F@user#@x",
|
||||||
"short_name": "x",
|
"short_name": "x",
|
||||||
"qualified_name": "x",
|
"qualified_name": "x",
|
||||||
"declaration": "tests/usage/func_usage_addr_func.cc:6:8",
|
"declaration": "tests/usage/func_usage_addr_func.cc:6:8",
|
||||||
"initializations": ["tests/usage/func_usage_addr_func.cc:6:8"],
|
"initializations": ["tests/usage/func_usage_addr_func.cc:6:8"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -1,8 +1,50 @@
|
|||||||
|
struct Foo {
|
||||||
|
void Used();
|
||||||
|
};
|
||||||
|
|
||||||
|
void user() {
|
||||||
|
auto x = &Foo::Used;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [],
|
"types": [{
|
||||||
"functions": [],
|
"id": 0,
|
||||||
"variables": []
|
"usr": "c:@S@Foo",
|
||||||
|
"short_name": "Foo",
|
||||||
|
"qualified_name": "Foo",
|
||||||
|
"definition": "tests/usage/func_usage_addr_method.cc:1:8",
|
||||||
|
"funcs": [0]
|
||||||
|
}, {
|
||||||
|
"id": 1
|
||||||
|
}],
|
||||||
|
"functions": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@F@Used#",
|
||||||
|
"short_name": "Used",
|
||||||
|
"qualified_name": "Foo::Used",
|
||||||
|
"declaration": "tests/usage/func_usage_addr_method.cc:2:8",
|
||||||
|
"declaring_type": 0,
|
||||||
|
"callers": ["1@tests/usage/func_usage_addr_method.cc:6:18"],
|
||||||
|
"uses": ["tests/usage/func_usage_addr_method.cc:6:18"]
|
||||||
|
}, {
|
||||||
|
"id": 1,
|
||||||
|
"usr": "c:@F@user#",
|
||||||
|
"short_name": "user",
|
||||||
|
"qualified_name": "user",
|
||||||
|
"definition": "tests/usage/func_usage_addr_method.cc:5:6",
|
||||||
|
"callees": ["0@tests/usage/func_usage_addr_method.cc:6:18"]
|
||||||
|
}],
|
||||||
|
"variables": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:func_usage_addr_method.cc@53@F@user#@x",
|
||||||
|
"short_name": "x",
|
||||||
|
"qualified_name": "x",
|
||||||
|
"declaration": "tests/usage/func_usage_addr_method.cc:6:8",
|
||||||
|
"initializations": ["tests/usage/func_usage_addr_method.cc:6:8"],
|
||||||
|
"variable_type": 1
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -1,8 +1,28 @@
|
|||||||
|
void called() {}
|
||||||
|
void caller() {
|
||||||
|
called();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [],
|
"types": [],
|
||||||
"functions": [],
|
"functions": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@F@called#",
|
||||||
|
"short_name": "called",
|
||||||
|
"qualified_name": "called",
|
||||||
|
"definition": "tests/usage/func_usage_call_func.cc:1:6",
|
||||||
|
"callers": ["1@tests/usage/func_usage_call_func.cc:3:3"],
|
||||||
|
"uses": ["tests/usage/func_usage_call_func.cc:3:3"]
|
||||||
|
}, {
|
||||||
|
"id": 1,
|
||||||
|
"usr": "c:@F@caller#",
|
||||||
|
"short_name": "caller",
|
||||||
|
"qualified_name": "caller",
|
||||||
|
"definition": "tests/usage/func_usage_call_func.cc:2:6",
|
||||||
|
"callees": ["0@tests/usage/func_usage_call_func.cc:3:3"]
|
||||||
|
}],
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -1,8 +1,50 @@
|
|||||||
|
struct Foo {
|
||||||
|
void Used();
|
||||||
|
};
|
||||||
|
|
||||||
|
void user() {
|
||||||
|
Foo* f = nullptr;
|
||||||
|
f->Used();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [],
|
"types": [{
|
||||||
"functions": [],
|
"id": 0,
|
||||||
"variables": []
|
"usr": "c:@S@Foo",
|
||||||
|
"short_name": "Foo",
|
||||||
|
"qualified_name": "Foo",
|
||||||
|
"definition": "tests/usage/func_usage_call_method.cc:1:8",
|
||||||
|
"funcs": [0]
|
||||||
|
}, {
|
||||||
|
"id": 1
|
||||||
|
}],
|
||||||
|
"functions": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@F@Used#",
|
||||||
|
"short_name": "Used",
|
||||||
|
"qualified_name": "Foo::Used",
|
||||||
|
"declaration": "tests/usage/func_usage_call_method.cc:2:8",
|
||||||
|
"declaring_type": 0,
|
||||||
|
"callers": ["1@tests/usage/func_usage_call_method.cc:7:6"],
|
||||||
|
"uses": ["tests/usage/func_usage_call_method.cc:7:6"]
|
||||||
|
}, {
|
||||||
|
"id": 1,
|
||||||
|
"usr": "c:@F@user#",
|
||||||
|
"short_name": "user",
|
||||||
|
"qualified_name": "user",
|
||||||
|
"definition": "tests/usage/func_usage_call_method.cc:5:6",
|
||||||
|
"callees": ["0@tests/usage/func_usage_call_method.cc:7:6"]
|
||||||
|
}],
|
||||||
|
"variables": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:func_usage_call_method.cc@53@F@user#@f",
|
||||||
|
"short_name": "f",
|
||||||
|
"qualified_name": "f",
|
||||||
|
"declaration": "tests/usage/func_usage_call_method.cc:6:8",
|
||||||
|
"initializations": ["tests/usage/func_usage_call_method.cc:6:8"],
|
||||||
|
"variable_type": 1
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -1,8 +1,43 @@
|
|||||||
|
static int helper() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
int x = helper();
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO(libclang): libclang doesn't expose the |helper| reference in the ast,
|
||||||
|
// so we can't add the |helper| usage.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [],
|
"types": [{
|
||||||
"functions": [],
|
"id": 0,
|
||||||
"variables": []
|
"usr": "c:@S@Foo",
|
||||||
|
"short_name": "Foo",
|
||||||
|
"qualified_name": "Foo",
|
||||||
|
"definition": "tests/usage/func_usage_class_inline_var_def.cc:5:7",
|
||||||
|
"vars": [0]
|
||||||
|
}, {
|
||||||
|
"id": 1
|
||||||
|
}],
|
||||||
|
"functions": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:func_usage_class_inline_var_def.cc@F@helper#",
|
||||||
|
"short_name": "helper",
|
||||||
|
"qualified_name": "helper",
|
||||||
|
"definition": "tests/usage/func_usage_class_inline_var_def.cc:1:12"
|
||||||
|
}],
|
||||||
|
"variables": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@FI@x",
|
||||||
|
"short_name": "x",
|
||||||
|
"qualified_name": "Foo::x",
|
||||||
|
"declaration": "tests/usage/func_usage_class_inline_var_def.cc:6:7",
|
||||||
|
"initializations": ["tests/usage/func_usage_class_inline_var_def.cc:6:7"],
|
||||||
|
"variable_type": 1,
|
||||||
|
"declaring_type": 0
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
28
tests/usage/func_usage_forward_decl_func.cc
Normal file
28
tests/usage/func_usage_forward_decl_func.cc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
void foo();
|
||||||
|
|
||||||
|
void usage() {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
{
|
||||||
|
"types": [],
|
||||||
|
"functions": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#",
|
||||||
|
"short_name": "foo",
|
||||||
|
"qualified_name": "foo",
|
||||||
|
"declaration": "tests/usage/func_usage_forward_decl_func.cc:1:6",
|
||||||
|
"callers": ["1@tests/usage/func_usage_forward_decl_func.cc:4:3"],
|
||||||
|
"uses": ["tests/usage/func_usage_forward_decl_func.cc:4:3"]
|
||||||
|
}, {
|
||||||
|
"id": 1,
|
||||||
|
"usr": "c:@F@usage#",
|
||||||
|
"short_name": "usage",
|
||||||
|
"qualified_name": "usage",
|
||||||
|
"definition": "tests/usage/func_usage_forward_decl_func.cc:3:6",
|
||||||
|
"callees": ["0@tests/usage/func_usage_forward_decl_func.cc:4:3"]
|
||||||
|
}],
|
||||||
|
"variables": []
|
||||||
|
}
|
||||||
|
*/
|
49
tests/usage/func_usage_forward_decl_method.cc
Normal file
49
tests/usage/func_usage_forward_decl_method.cc
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
struct Foo {
|
||||||
|
void foo();
|
||||||
|
};
|
||||||
|
|
||||||
|
void usage() {
|
||||||
|
Foo* f = nullptr;
|
||||||
|
f->foo();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
{
|
||||||
|
"types": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
|
"short_name": "Foo",
|
||||||
|
"qualified_name": "Foo",
|
||||||
|
"definition": "tests/usage/func_usage_forward_decl_method.cc:1:8",
|
||||||
|
"funcs": [0]
|
||||||
|
}, {
|
||||||
|
"id": 1
|
||||||
|
}],
|
||||||
|
"functions": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@F@foo#",
|
||||||
|
"short_name": "foo",
|
||||||
|
"qualified_name": "Foo::foo",
|
||||||
|
"declaration": "tests/usage/func_usage_forward_decl_method.cc:2:8",
|
||||||
|
"declaring_type": 0,
|
||||||
|
"callers": ["1@tests/usage/func_usage_forward_decl_method.cc:7:6"],
|
||||||
|
"uses": ["tests/usage/func_usage_forward_decl_method.cc:7:6"]
|
||||||
|
}, {
|
||||||
|
"id": 1,
|
||||||
|
"usr": "c:@F@usage#",
|
||||||
|
"short_name": "usage",
|
||||||
|
"qualified_name": "usage",
|
||||||
|
"definition": "tests/usage/func_usage_forward_decl_method.cc:5:6",
|
||||||
|
"callees": ["0@tests/usage/func_usage_forward_decl_method.cc:7:6"]
|
||||||
|
}],
|
||||||
|
"variables": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:func_usage_forward_decl_method.cc@53@F@usage#@f",
|
||||||
|
"short_name": "f",
|
||||||
|
"qualified_name": "f",
|
||||||
|
"declaration": "tests/usage/func_usage_forward_decl_method.cc:6:8",
|
||||||
|
"initializations": ["tests/usage/func_usage_forward_decl_method.cc:6:8"],
|
||||||
|
"variable_type": 1
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
*/
|
23
tests/usage/type_usage_declare_extern.cc
Normal file
23
tests/usage/type_usage_declare_extern.cc
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
struct T {};
|
||||||
|
|
||||||
|
extern T t;
|
||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
{
|
||||||
|
"types": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@S@T",
|
||||||
|
"short_name": "T",
|
||||||
|
"qualified_name": "T",
|
||||||
|
"definition": "tests/usage/type_usage_declare_extern.cc:1:8"
|
||||||
|
}],
|
||||||
|
"functions": [],
|
||||||
|
"variables": [{
|
||||||
|
"id": 0,
|
||||||
|
"usr": "c:@t",
|
||||||
|
"short_name": "t",
|
||||||
|
"qualified_name": "t",
|
||||||
|
"declaration": "tests/usage/type_usage_declare_extern.cc:3:10"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
*/
|
8
tests/usage/type_usage_declare_param.cc
Normal file
8
tests/usage/type_usage_declare_param.cc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
{
|
||||||
|
"types": [],
|
||||||
|
"functions": [],
|
||||||
|
"variables": []
|
||||||
|
}
|
||||||
|
*/
|
8
tests/usage/type_usage_declare_static.cc
Normal file
8
tests/usage/type_usage_declare_static.cc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
OUTPUT:
|
||||||
|
{
|
||||||
|
"types": [],
|
||||||
|
"functions": [],
|
||||||
|
"variables": []
|
||||||
|
}
|
||||||
|
*/
|
@ -6,32 +6,24 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/vars/class_member.cc:1:7",
|
"definition": "tests/vars/class_member.cc:1:7",
|
||||||
"parents": [],
|
"vars": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [],
|
|
||||||
"vars": [0],
|
|
||||||
"uses": []
|
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@FI@member",
|
||||||
"short_name": "member",
|
"short_name": "member",
|
||||||
"qualified_name": "Foo::member",
|
"qualified_name": "Foo::member",
|
||||||
"declaration": "tests/vars/class_member.cc:2:7",
|
"declaration": "tests/vars/class_member.cc:2:7",
|
||||||
"initializations": ["tests/vars/class_member.cc:2:7"],
|
"initializations": ["tests/vars/class_member.cc:2:7"],
|
||||||
"variable_type": 1,
|
"variable_type": 1,
|
||||||
"declaring_type": 0,
|
"declaring_type": 0
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -7,32 +7,24 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/vars/class_static_member.cc:1:7",
|
"definition": "tests/vars/class_static_member.cc:1:7",
|
||||||
"parents": [],
|
"vars": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [],
|
|
||||||
"vars": [0],
|
|
||||||
"uses": []
|
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@member",
|
||||||
"short_name": "member",
|
"short_name": "member",
|
||||||
"qualified_name": "Foo::member",
|
"qualified_name": "Foo::member",
|
||||||
"declaration": "tests/vars/class_static_member.cc:2:14",
|
"declaration": "tests/vars/class_static_member.cc:2:14",
|
||||||
"initializations": ["tests/vars/class_static_member.cc:4:10"],
|
"initializations": ["tests/vars/class_static_member.cc:4:10"],
|
||||||
"variable_type": 1,
|
"variable_type": 1,
|
||||||
"declaring_type": 0,
|
"declaring_type": 0
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -6,27 +6,20 @@ OUTPUT:
|
|||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo",
|
||||||
"short_name": "Foo",
|
"short_name": "Foo",
|
||||||
"qualified_name": "Foo",
|
"qualified_name": "Foo",
|
||||||
"declaration": null,
|
|
||||||
"definition": "tests/vars/class_static_member_decl_only.cc:1:7",
|
"definition": "tests/vars/class_static_member_decl_only.cc:1:7",
|
||||||
"parents": [],
|
"vars": [0]
|
||||||
"derived": [],
|
|
||||||
"types": [],
|
|
||||||
"funcs": [],
|
|
||||||
"vars": [0],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@S@Foo@member",
|
||||||
"short_name": "member",
|
"short_name": "member",
|
||||||
"qualified_name": "Foo::member",
|
"qualified_name": "Foo::member",
|
||||||
"declaration": "tests/vars/class_static_member_decl_only.cc:2:14",
|
"declaration": "tests/vars/class_static_member_decl_only.cc:2:14",
|
||||||
"initializations": [],
|
"declaring_type": 0
|
||||||
"variable_type": null,
|
|
||||||
"declaring_type": 0,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -5,34 +5,23 @@ void foo() {
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": null,
|
"definition": "tests/vars/function_local.cc:1:6"
|
||||||
"definition": "tests/vars/function_local.cc:1:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:function_local.cc@16@F@foo#@a",
|
||||||
"short_name": "a",
|
"short_name": "a",
|
||||||
"qualified_name": "a",
|
"qualified_name": "a",
|
||||||
"declaration": "tests/vars/function_local.cc:2:7",
|
"declaration": "tests/vars/function_local.cc:2:7",
|
||||||
"initializations": ["tests/vars/function_local.cc:2:7"],
|
"initializations": ["tests/vars/function_local.cc:2:7"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -3,43 +3,31 @@ void foo(int p0, int p1) {}
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#I#I#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": null,
|
"definition": "tests/vars/function_param.cc:1:6"
|
||||||
"definition": "tests/vars/function_param.cc:1:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:function_param.cc@9@F@foo#I#I#@p0",
|
||||||
"short_name": "p0",
|
"short_name": "p0",
|
||||||
"qualified_name": "p0",
|
"qualified_name": "p0",
|
||||||
"declaration": "tests/vars/function_param.cc:1:14",
|
"declaration": "tests/vars/function_param.cc:1:14",
|
||||||
"initializations": ["tests/vars/function_param.cc:1:14"],
|
"initializations": ["tests/vars/function_param.cc:1:14"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
"usr": "c:function_param.cc@17@F@foo#I#I#@p1",
|
||||||
"short_name": "p1",
|
"short_name": "p1",
|
||||||
"qualified_name": "p1",
|
"qualified_name": "p1",
|
||||||
"declaration": "tests/vars/function_param.cc:1:22",
|
"declaration": "tests/vars/function_param.cc:1:22",
|
||||||
"initializations": ["tests/vars/function_param.cc:1:22"],
|
"initializations": ["tests/vars/function_param.cc:1:22"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -2,47 +2,26 @@ void foo(int, int) {}
|
|||||||
/*
|
/*
|
||||||
// TODO: We should probably not emit variables for unnamed variables. But we
|
// TODO: We should probably not emit variables for unnamed variables. But we
|
||||||
// still need to emit reference information.
|
// still need to emit reference information.
|
||||||
|
// TODO: This test is broken. Notice how we only emit one variable because
|
||||||
|
// unnamed vars have no usr!
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#I#I#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": null,
|
"definition": "tests/vars/function_param_unnamed.cc:1:6"
|
||||||
"definition": "tests/vars/function_param.cc:1:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"short_name": "p0",
|
"declaration": "tests/vars/function_param_unnamed.cc:1:13",
|
||||||
"qualified_name": "p0",
|
"initializations": ["tests/vars/function_param_unnamed.cc:1:13", "tests/vars/function_param_unnamed.cc:1:18"],
|
||||||
"declaration": "tests/vars/function_param.cc:1:14",
|
"variable_type": 0
|
||||||
"initializations": ["tests/vars/function_param.cc:1:14"],
|
|
||||||
"variable_type": 0,
|
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}, {
|
|
||||||
"id": 1,
|
|
||||||
"short_name": "p1",
|
|
||||||
"qualified_name": "p1",
|
|
||||||
"declaration": "tests/vars/function_param.cc:1:22",
|
|
||||||
"initializations": ["tests/vars/function_param.cc:1:22"],
|
|
||||||
"variable_type": 0,
|
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -8,43 +8,31 @@ void foo() {
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": null,
|
"definition": "tests/vars/function_shadow_local.cc:1:6"
|
||||||
"definition": "tests/vars/function_shadow_local.cc:1:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:function_shadow_local.cc@16@F@foo#@a",
|
||||||
"short_name": "a",
|
"short_name": "a",
|
||||||
"qualified_name": "a",
|
"qualified_name": "a",
|
||||||
"declaration": "tests/vars/function_shadow_local.cc:2:7",
|
"declaration": "tests/vars/function_shadow_local.cc:2:7",
|
||||||
"initializations": ["tests/vars/function_shadow_local.cc:2:7"],
|
"initializations": ["tests/vars/function_shadow_local.cc:2:7"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
"usr": "c:function_shadow_local.cc@33@F@foo#@a",
|
||||||
"short_name": "a",
|
"short_name": "a",
|
||||||
"qualified_name": "a",
|
"qualified_name": "a",
|
||||||
"declaration": "tests/vars/function_shadow_local.cc:4:9",
|
"declaration": "tests/vars/function_shadow_local.cc:4:9",
|
||||||
"initializations": ["tests/vars/function_shadow_local.cc:4:9"],
|
"initializations": ["tests/vars/function_shadow_local.cc:4:9"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -5,43 +5,31 @@ void foo(int p) {
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [{
|
"functions": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@F@foo#I#",
|
||||||
"short_name": "foo",
|
"short_name": "foo",
|
||||||
"qualified_name": "foo",
|
"qualified_name": "foo",
|
||||||
"declaration": null,
|
"definition": "tests/vars/function_shadow_param.cc:1:6"
|
||||||
"definition": "tests/vars/function_shadow_param.cc:1:6",
|
|
||||||
"declaring_type": null,
|
|
||||||
"base": null,
|
|
||||||
"derived": [],
|
|
||||||
"locals": [],
|
|
||||||
"callers": [],
|
|
||||||
"callees": [],
|
|
||||||
"uses": []
|
|
||||||
}],
|
}],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:function_shadow_param.cc@9@F@foo#I#@p",
|
||||||
"short_name": "p",
|
"short_name": "p",
|
||||||
"qualified_name": "p",
|
"qualified_name": "p",
|
||||||
"declaration": "tests/vars/function_shadow_param.cc:1:14",
|
"declaration": "tests/vars/function_shadow_param.cc:1:14",
|
||||||
"initializations": ["tests/vars/function_shadow_param.cc:1:14"],
|
"initializations": ["tests/vars/function_shadow_param.cc:1:14"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}, {
|
}, {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
"usr": "c:function_shadow_param.cc@21@F@foo#I#@p",
|
||||||
"short_name": "p",
|
"short_name": "p",
|
||||||
"qualified_name": "p",
|
"qualified_name": "p",
|
||||||
"declaration": "tests/vars/function_shadow_param.cc:2:7",
|
"declaration": "tests/vars/function_shadow_param.cc:2:7",
|
||||||
"initializations": ["tests/vars/function_shadow_param.cc:2:7"],
|
"initializations": ["tests/vars/function_shadow_param.cc:2:7"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -3,21 +3,17 @@ static int global = 0;
|
|||||||
OUTPUT:
|
OUTPUT:
|
||||||
{
|
{
|
||||||
"types": [{
|
"types": [{
|
||||||
"id": 0,
|
"id": 0
|
||||||
"short_name": "",
|
|
||||||
"qualified_name": "",
|
|
||||||
"declaration": null
|
|
||||||
}],
|
}],
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:global_variable.cc@global",
|
||||||
"short_name": "global",
|
"short_name": "global",
|
||||||
"qualified_name": "global",
|
"qualified_name": "global",
|
||||||
"declaration": "tests/vars/global_variable.cc:1:12",
|
"declaration": "tests/vars/global_variable.cc:1:12",
|
||||||
"initializations": ["tests/vars/global_variable.cc:1:12"],
|
"initializations": ["tests/vars/global_variable.cc:1:12"],
|
||||||
"variable_type": 0,
|
"variable_type": 0
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
@ -6,13 +6,10 @@ OUTPUT:
|
|||||||
"functions": [],
|
"functions": [],
|
||||||
"variables": [{
|
"variables": [{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
|
"usr": "c:@global",
|
||||||
"short_name": "global",
|
"short_name": "global",
|
||||||
"qualified_name": "global",
|
"qualified_name": "global",
|
||||||
"declaration": "tests/vars/global_variable_decl_only.cc:1:12",
|
"declaration": "tests/vars/global_variable_decl_only.cc:1:12"
|
||||||
"initializations": [],
|
|
||||||
"variable_type": null,
|
|
||||||
"declaring_type": null,
|
|
||||||
"uses": []
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
Loading…
Reference in New Issue
Block a user