data, utility: Fixes to run Opensource Projects
templateSpecializationArgsAsWritten returning null caused a crash VisitMemberExprInDeclBody for vardecl was missing subdirectories for headersearchpaths, that the user does not need to add a hugh amount of folders
This commit is contained in:
@@ -383,6 +383,7 @@ if(UNIX AND NOT APPLE)
|
||||
SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
|
||||
SET(CPACK_PACKAGE_VERSION ${GIT_VERSION_NUMBER})
|
||||
SET(CPACK_PACKAGE_EXECUTABLES "Coati")
|
||||
SET(CPACK_STRIP_FILES "share/coati/Coati")
|
||||
|
||||
INCLUDE(CPack)
|
||||
|
||||
|
||||
+11
-1
@@ -9,6 +9,7 @@
|
||||
#include "data/parser/cxx/TaskParseCxx.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(StorageAccessProxy* storageAccessProxy)
|
||||
{
|
||||
@@ -146,7 +147,16 @@ Parser::Arguments Project::getParserArguments() const
|
||||
|
||||
// Add the include paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
utility::append(args.systemHeaderSearchPaths, m_fileManager.getIncludePaths());
|
||||
utility::append(args.systemHeaderSearchPaths, projSettings->getHeaderSearchPaths());
|
||||
|
||||
std::vector<FilePath> headerSearchPaths;
|
||||
for(FilePath p : projSettings->getHeaderSearchPaths())
|
||||
{
|
||||
std::vector<FilePath> tempPaths = FileSystem::getSubDirectoies(p);
|
||||
headerSearchPaths.insert( headerSearchPaths.end(), tempPaths.begin(), tempPaths.end() );
|
||||
}
|
||||
|
||||
std::unique(headerSearchPaths.begin(),headerSearchPaths.end());
|
||||
utility::append(args.systemHeaderSearchPaths, headerSearchPaths);
|
||||
utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPaths());
|
||||
|
||||
utility::append(args.frameworkSearchPaths, projSettings->getFrameworkSearchPaths());
|
||||
|
||||
@@ -309,6 +309,17 @@ Id Storage::onFieldUsageParsed(
|
||||
return edgeId;
|
||||
}
|
||||
|
||||
Id Storage::onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy
|
||||
){
|
||||
Id userNodeId = addNodeHierarchy(Node::NODE_UNDEFINED_FUNCTION, user.nameHierarchy);
|
||||
Id usedNodeId = addNodeHierarchy(Node::NODE_UNDEFINED_VARIABLE, usedNameHierarchy);
|
||||
|
||||
Id edgeId = addEdge(userNodeId, usedNodeId, Edge::EDGE_USAGE, location);
|
||||
|
||||
return edgeId;
|
||||
}
|
||||
|
||||
Id Storage::onGlobalVariableUsageParsed( // or static variable used
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy
|
||||
){
|
||||
|
||||
@@ -76,6 +76,8 @@ public:
|
||||
const ParseLocation& location, const ParseVariable& caller, const ParseFunction& callee);
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy);
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy);
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy);
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
|
||||
@@ -95,6 +95,8 @@ public:
|
||||
const ParseLocation& location, const ParseVariable& caller, const ParseFunction& callee) = 0;
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy) = 0;
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy) = 0;
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy) = 0;
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
|
||||
@@ -80,7 +80,14 @@ void ASTBodyVisitor::VisitMemberExpr(clang::make_ptr<clang::MemberExpr>::type ex
|
||||
{
|
||||
if (expr->getMemberDecl()->getKind() == clang::Decl::Kind::Field)
|
||||
{
|
||||
m_client->VisitMemberExprInDeclBody(m_functionDecl, expr);
|
||||
if(m_functionDecl)
|
||||
{
|
||||
m_client->VisitMemberExprInDeclBody(m_functionDecl, expr);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_client->VisitMemberExprInDeclBody(m_varDecl, expr);
|
||||
}
|
||||
}
|
||||
VisitStmt(expr);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
virtual void VisitCXXNewExprInDeclBody(clang::FunctionDecl* decl, clang::CXXNewExpr* expr) = 0;
|
||||
virtual void VisitCXXNewExprInDeclBody(clang::VarDecl* decl, clang::CXXNewExpr* expr) = 0;
|
||||
virtual void VisitMemberExprInDeclBody(clang::FunctionDecl* decl, clang::MemberExpr* expr) = 0;
|
||||
virtual void VisitMemberExprInDeclBody(clang::VarDecl* decl, clang::MemberExpr* expr) = 0;
|
||||
virtual void VisitGlobalVariableExprInDeclBody(clang::FunctionDecl* decl, clang::DeclRefExpr* expr) = 0;
|
||||
virtual void VisitGlobalVariableExprInDeclBody(clang::VarDecl* decl, clang::DeclRefExpr* expr) = 0;
|
||||
virtual void VisitEnumExprInDeclBody(clang::FunctionDecl* decl, clang::DeclRefExpr* expr) = 0;
|
||||
|
||||
@@ -456,16 +456,33 @@ bool ASTVisitor::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl *declarat
|
||||
specializedFunction,
|
||||
templateFunction);
|
||||
|
||||
const clang::ASTTemplateArgumentListInfo* argumentInfoList = specializedFunctionDecl->getTemplateSpecializationArgsAsWritten();
|
||||
for (size_t i = 0; i < argumentInfoList->NumTemplateArgs; i++)
|
||||
if(specializedFunctionDecl->getTemplateSpecializationArgsAsWritten())
|
||||
{
|
||||
const clang::TemplateArgumentLoc& argumentLoc = argumentInfoList->operator[](i);
|
||||
const clang::QualType argumentType = argumentLoc.getArgument().getAsType();
|
||||
const clang::ASTTemplateArgumentListInfo* argumentInfoList = specializedFunctionDecl->getTemplateSpecializationArgsAsWritten();
|
||||
for (size_t i = 0; i < argumentInfoList->NumTemplateArgs; i++)
|
||||
{
|
||||
const clang::TemplateArgumentLoc& argumentLoc = argumentInfoList->operator[](i);
|
||||
const clang::QualType argumentType = argumentLoc.getArgument().getAsType();
|
||||
|
||||
m_client->onTemplateArgumentTypeParsed(
|
||||
getParseLocation(argumentLoc.getSourceRange()),
|
||||
utility::qualTypeToDataType(argumentType)->getTypeNameHierarchy(),
|
||||
specializedFunction.nameHierarchy);
|
||||
m_client->onTemplateArgumentTypeParsed(
|
||||
getParseLocation(argumentLoc.getSourceRange()),
|
||||
utility::qualTypeToDataType(argumentType)->getTypeNameHierarchy(),
|
||||
specializedFunction.nameHierarchy);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const clang::TemplateArgumentList* argumentList = specializedFunctionDecl->getTemplateSpecializationArgs();
|
||||
for(size_t i = 0; i < argumentList->size(); ++i)
|
||||
{
|
||||
const clang::TemplateArgumentLoc& argumentLoc = clang::TemplateArgumentLoc(argumentList->get(i), specializedFunctionDecl->getTypeSourceInfo());
|
||||
const clang::QualType argumentType = argumentLoc.getArgument().getAsType();
|
||||
|
||||
m_client->onTemplateArgumentTypeParsed(
|
||||
getParseLocation(argumentLoc.getSourceRange()),
|
||||
utility::qualTypeToDataType(argumentType)->getTypeNameHierarchy(),
|
||||
specializedFunction.nameHierarchy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -649,6 +666,20 @@ void ASTVisitor::VisitMemberExprInDeclBody(clang::FunctionDecl* decl, clang::Mem
|
||||
);
|
||||
}
|
||||
|
||||
void ASTVisitor::VisitMemberExprInDeclBody(clang::VarDecl* decl, clang::MemberExpr* expr)
|
||||
{
|
||||
ParseLocation parseLocation = getParseLocation(expr->getSourceRange());
|
||||
|
||||
const std::string exprName = expr->getMemberNameInfo().getAsString();
|
||||
parseLocation.endColumnNumber += exprName.size() - 1;
|
||||
|
||||
m_client->onFieldUsageParsed(
|
||||
parseLocation,
|
||||
getParseVariable(decl),
|
||||
utility::getDeclNameHierarchy(expr->getMemberDecl())
|
||||
);
|
||||
}
|
||||
|
||||
void ASTVisitor::VisitGlobalVariableExprInDeclBody(clang::FunctionDecl* decl, clang::DeclRefExpr* expr)
|
||||
{
|
||||
ParseLocation parseLocation = getParseLocation(expr->getSourceRange());
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
virtual void VisitCXXNewExprInDeclBody(clang::FunctionDecl* decl, clang::CXXNewExpr* expr); // type use of new operator
|
||||
virtual void VisitCXXNewExprInDeclBody(clang::VarDecl* decl, clang::CXXNewExpr* expr); // type use of new operator in global space
|
||||
virtual void VisitMemberExprInDeclBody(clang::FunctionDecl* decl, clang::MemberExpr* expr); // field usages
|
||||
virtual void VisitMemberExprInDeclBody(clang::VarDecl* decl, clang::MemberExpr* expr); // field usages
|
||||
virtual void VisitGlobalVariableExprInDeclBody(clang::FunctionDecl* decl, clang::DeclRefExpr* expr); // global variable usage
|
||||
virtual void VisitGlobalVariableExprInDeclBody(clang::VarDecl* decl, clang::DeclRefExpr* expr); // global variable usage
|
||||
virtual void VisitEnumExprInDeclBody(clang::FunctionDecl* decl, clang::DeclRefExpr* expr); // enum field usage
|
||||
|
||||
@@ -99,7 +99,7 @@ std::string CxxDeclNameResolver::getDeclName()
|
||||
clang::dyn_cast<clang::ClassTemplatePartialSpecializationDecl>(declaration);
|
||||
|
||||
clang::TemplateParameterList* parameterList = partialSpecializationDecl->getTemplateParameters();
|
||||
int currentParameterIndex = 0;
|
||||
unsigned int currentParameterIndex = 0;
|
||||
|
||||
std::string specializedParameterNamePart = "<";
|
||||
int templateArgumentCount = partialSpecializationDecl->getTemplateArgs().size();
|
||||
@@ -109,7 +109,16 @@ std::string CxxDeclNameResolver::getDeclName()
|
||||
const clang::TemplateArgument& templateArgument = templateArgumentList.get(i);
|
||||
if (templateArgument.isDependent()) // IMPORTANT_TODO: fix case when arg depends on template parameter of outer template class, or depends on first template parameter.
|
||||
{
|
||||
specializedParameterNamePart += getTemplateParameterString(parameterList->getParam(currentParameterIndex));
|
||||
if(currentParameterIndex < parameterList->size())
|
||||
{
|
||||
specializedParameterNamePart += getTemplateParameterString(parameterList->getParam(currentParameterIndex));
|
||||
}
|
||||
else
|
||||
{
|
||||
//this if fixes the crash, but not the problem TODO
|
||||
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
|
||||
LOG_ERROR("Template getParam out of Range "+declaration->getLocation().printToString(sourceManager));
|
||||
}
|
||||
currentParameterIndex++;
|
||||
}
|
||||
else
|
||||
@@ -250,4 +259,3 @@ std::string CxxDeclNameResolver::getTemplateArgumentName(const clang::TemplateAr
|
||||
CxxTemplateArgumentNameResolver resolver(getIgnoredContextDecls());
|
||||
return resolver.getTemplateArgumentName(argument);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ bool Settings::load(const FilePath& filePath)
|
||||
else
|
||||
{
|
||||
clear();
|
||||
LOG_WARNING("File for Settings not found.");
|
||||
LOG_WARNING("File for Settings not found: " + filePath.str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ void Settings::save()
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Settings were not saved.");
|
||||
LOG_WARNING("Settings were not saved: " + m_filePath.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void Settings::save(const FilePath& filePath)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Settings were not saved.");
|
||||
LOG_WARNING("Settings were not saved: " + filePath.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ std::vector<std::string> FileSystem::getFileNamesFromDirectoryUpdatedAfter(
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
const std::vector<FilePath>& paths, const std::vector<std::string>& fileExtensions
|
||||
){
|
||||
@@ -136,3 +138,13 @@ bool FileSystem::equivalent(const std::string& pathA, const std::string& pathB)
|
||||
|
||||
return boost::filesystem::path(pathA).compare(boost::filesystem::path(pathB)) == 0;
|
||||
}
|
||||
|
||||
std::vector<FilePath> FileSystem::getSubDirectoies(const FilePath &path) {
|
||||
std::vector<FilePath> v;
|
||||
for ( boost::filesystem::recursive_directory_iterator end, dir(path.str());
|
||||
dir != end; ++dir ) {
|
||||
if(boost::filesystem::is_directory(dir->path()))
|
||||
v.push_back(FilePath(dir->path()));
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
const std::vector<FilePath>& paths, const std::vector<std::string>& fileExtensions);
|
||||
|
||||
static std::string getTimeStringNow();
|
||||
static std::vector<FilePath> getSubDirectoies(const FilePath& path);
|
||||
|
||||
static bool exists(const std::string& path);
|
||||
static std::string fileName(const std::string& path);
|
||||
|
||||
@@ -2600,6 +2600,13 @@ private:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy)
|
||||
{
|
||||
usages.push_back(addLocationSuffix(variableStr(user) + " -> " + usedNameHierarchy.getFullName(), location));
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user