This commit is contained in:
Jacob Dufault 2017-02-19 22:40:55 -08:00
parent d26cb81854
commit 6970d60dca

134
main.cpp
View File

@ -483,6 +483,7 @@ VarDef* Resolve(Database* db, VarId id) {
} }
*/ */
#if false
struct NamespaceStack { struct NamespaceStack {
std::vector<std::string> stack; std::vector<std::string> stack;
@ -602,22 +603,6 @@ void InsertReference(ParsingDatabase* db, std::optional<FuncId> func_id, clang::
clang::VisiterResult DumpVisitor(clang::Cursor cursor, clang::Cursor parent, int* level) {
for (int i = 0; i < *level; ++i)
std::cout << " ";
std::cout << clang::ToString(cursor.get_kind()) << " " << cursor.get_spelling() << std::endl;
*level += 1;
cursor.VisitChildren(&DumpVisitor, level);
*level -= 1;
return clang::VisiterResult::Continue;
}
void Dump(clang::Cursor cursor) {
int level = 0;
cursor.VisitChildren(&DumpVisitor, &level);
}
@ -1036,6 +1021,88 @@ clang::VisiterResult VisitFile(clang::Cursor cursor, clang::Cursor parent, FileP
return clang::VisiterResult::Continue; return clang::VisiterResult::Continue;
} }
ParsingDatabase Parse2(std::string filename) {
std::vector<std::string> args;
clang::Index index(0 /*excludeDeclarationsFromPCH*/, 0 /*displayDiagnostics*/);
clang::TranslationUnit tu(index, filename, args);
std::cout << "Start document dump" << std::endl;
Dump(tu.document_cursor());
std::cout << "Done document dump" << std::endl << std::endl;
ParsingDatabase db;
NamespaceStack ns;
FileParam file_param(&db, &ns);
tu.document_cursor().VisitChildren(&VisitFile, &file_param);
return db;
}
#endif
@ -1068,6 +1135,23 @@ CXIdxClientContainer startedTranslationUnit(CXClientData client_data, void *rese
clang::VisiterResult DumpVisitor(clang::Cursor cursor, clang::Cursor parent, int* level) {
for (int i = 0; i < *level; ++i)
std::cout << " ";
std::cout << clang::ToString(cursor.get_kind()) << " " << cursor.get_spelling() << std::endl;
*level += 1;
cursor.VisitChildren(&DumpVisitor, level);
*level -= 1;
return clang::VisiterResult::Continue;
}
void Dump(clang::Cursor cursor) {
int level = 0;
cursor.VisitChildren(&DumpVisitor, &level);
}
@ -1591,24 +1675,6 @@ ParsingDatabase Parse(std::string filename) {
} }
ParsingDatabase Parse2(std::string filename) {
std::vector<std::string> args;
clang::Index index(0 /*excludeDeclarationsFromPCH*/, 0 /*displayDiagnostics*/);
clang::TranslationUnit tu(index, filename, args);
std::cout << "Start document dump" << std::endl;
Dump(tu.document_cursor());
std::cout << "Done document dump" << std::endl << std::endl;
ParsingDatabase db;
NamespaceStack ns;
FileParam file_param(&db, &ns);
tu.document_cursor().VisitChildren(&VisitFile, &file_param);
return db;
}
template<typename T> template<typename T>
bool AreEqual(const std::vector<T>& a, const std::vector<T>& b) { bool AreEqual(const std::vector<T>& a, const std::vector<T>& b) {
if (a.size() != b.size()) if (a.size() != b.size())