logic: Added compilation database project setup

* Added CDB option to project type selection
* show CDB source files in popup
* define header paths separately
* made generic content summary in wizzard and use it everywhere
* fixed file paths not canonical in analysis
* refactored wizzard content paths to use summary instead of subpaths
* refactored files popup to simpler communication with content

bug id = 35
This commit is contained in:
Eberhard Graether
2016-03-08 13:20:37 +01:00
parent 90c0d15d20
commit 8cc8f5d534
45 changed files with 919 additions and 734 deletions
+48 -18
View File
@@ -8,6 +8,7 @@
#include "utility/text/TextAccess.h"
#include "data/parser/cxx/ASTActionFactory.h"
#include "data/parser/cxx/CxxCompilationDatabaseSingle.h"
#include "data/parser/cxx/CxxDiagnosticConsumer.h"
namespace
@@ -51,6 +52,7 @@ namespace
}
}
CxxParser::CxxParser(ParserClient* client, const FileManager* fileManager)
: Parser(client)
, m_fileRegister(std::make_shared<FileRegister>(fileManager))
@@ -94,7 +96,7 @@ void CxxParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess>
runToolOnCodeWithArgs(diagnostics.get(), actionFactory.create(), textAccess->getText(), args);
}
std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arguments) const
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(const Arguments& arguments) const
{
std::vector<std::string> args;
@@ -111,6 +113,32 @@ std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arg
// The option -c signals that no executable is built.
args.push_back("-c");
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
for (const FilePath& path : arguments.headerSearchPaths)
{
args.push_back("-I" + path.str());
}
for (const FilePath& path : arguments.systemHeaderSearchPaths)
{
args.push_back("-isystem");
args.push_back(path.str());
}
for (const FilePath& path : arguments.frameworkSearchPaths)
{
args.push_back("-iframework");
args.push_back(path.str());
}
return args;
}
std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arguments) const
{
std::vector<std::string> args = getCommandlineArgumentsEssential(arguments);
// The option '-x c++' treats subsequent input files as C++.
args.push_back("-x");
std::string language = getLanguageArgument(arguments.language);
@@ -122,23 +150,6 @@ std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arg
standard += arguments.languageStandard;
args.push_back(standard);
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
for (const FilePath& path : arguments.headerSearchPaths)
{
args.push_back("-I" + path.str());
}
for (const FilePath& path : arguments.systemHeaderSearchPaths)
{
args.push_back("-isystem" + path.str());
}
for (const FilePath& path : arguments.frameworkSearchPaths)
{
args.push_back("-iframework" + path.str());
}
return args;
}
@@ -186,6 +197,12 @@ void CxxParser::setupParsing(const std::vector<FilePath>& filePaths, const Argum
m_diagnostics = getDiagnostics(arguments);
}
void CxxParser::setupParsingCDB(const std::vector<FilePath>& filePaths, const Arguments& arguments)
{
m_fileRegister->setFilePaths(filePaths);
m_diagnostics = getDiagnostics(arguments);
}
void CxxParser::runTool(const std::vector<std::string>& files)
{
clang::tooling::ClangTool tool(*m_compilationDatabase, files);
@@ -195,6 +212,19 @@ void CxxParser::runTool(const std::vector<std::string>& files)
tool.run(&actionFactory);
}
void CxxParser::runTool(clang::tooling::CompileCommand command, const Arguments& arguments)
{
std::vector<std::string> args = getCommandlineArgumentsEssential(arguments);
command.CommandLine.insert(command.CommandLine.end(), args.begin(), args.end());
CxxCompilationDatabaseSingle compilationDatabase(command);
clang::tooling::ClangTool tool(compilationDatabase, std::vector<std::string>(1, command.Filename));
tool.setDiagnosticConsumer(m_diagnostics.get());
ASTActionFactory actionFactory(m_client, m_fileRegister.get());
tool.run(&actionFactory);
}
FileRegister* CxxParser::getFileRegister()
{
return m_fileRegister.get();