data: Added CxxParser, currently only detecting classes
This change adds CxxParser a class for parsing cxx files. It holds basic functionality to detect classes using the clang libTooling classes. CxxParser is derived from a common Parser interface, which can later be used for other language parsers. The Parser forwards detected elements to a ParserClient interface, which is implemented by the Storage class. The detected classes only get logged so far. review id = 6 * bd3c63a - (HEAD, origin/class, class) applied second review <Eberhard Graether> (4 minutes ago) * 3db7d93 - added missing files <Eberhard Graether> (4 days ago) * 6d09f4e - applied review <Eberhard Graether> (4 days ago) * d9d3e64 - fixed CMake files <Eberhard Graether> (4 days ago) * f22a771 - only one Storage class <Eberhard Graether> (4 days ago) * 6ee9553 - added tests <Eberhard Graether> (4 days ago) * 0a525e8 - fixed includes <Eberhard Graether> (4 days ago) * ca3fbb8 - added StorageManager as ParserClient <Eberhard Graether> (4 days ago) * fa185a5 - renamed ParseLocation to ParseObject <Eberhard Graether> (4 days ago) * 8b89808 - pass location with ParseLocation object <Eberhard Graether> (4 days ago) * 548ae3c - renamed clang AST classes <Eberhard Graether> (4 days ago) * d3b2caf - cleaned includes <Eberhard Graether> (4 days ago) * f7fdf33 - removed using namespace stmts <Eberhard Graether> (4 days ago) * 5378ef6 - using ParserClient <Eberhard Graether> (4 days ago) * b9ce2f6 - working with test file <Eberhard Graether> (4 days ago) * 5585abc - added CxxParser and ParserClient <Eberhard Graether> (4 days ago)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
|
||||
#include "data/parser/cxx/ASTActionFactory.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
CxxParser::CxxParser(std::shared_ptr<ParserClient> client)
|
||||
: Parser(client)
|
||||
{
|
||||
}
|
||||
|
||||
CxxParser::~CxxParser()
|
||||
{
|
||||
}
|
||||
|
||||
void CxxParser::parseFiles(const std::vector<std::string>& filePaths)
|
||||
{
|
||||
const char* argv[] = { "app", "--" };
|
||||
int argc = 2;
|
||||
|
||||
std::shared_ptr<clang::tooling::FixedCompilationDatabase> compilationDatabase(
|
||||
clang::tooling::FixedCompilationDatabase::loadFromCommandLine(argc, argv)
|
||||
);
|
||||
|
||||
if (!compilationDatabase)
|
||||
{
|
||||
LOG_ERROR("Failed to load compilation database");
|
||||
return;
|
||||
}
|
||||
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, filePaths);
|
||||
|
||||
ASTActionFactory actionFactory(m_client);
|
||||
|
||||
tool.run(&actionFactory);
|
||||
}
|
||||
Reference in New Issue
Block a user