logic: fixed some crashes
* verbose ast visitor logs the file that is currently visited. * fixed crash in log controller * fixed crash when solving the name of an anonymous element that has no valid location
This commit is contained in:
@@ -8,6 +8,7 @@ LogController::LogController()
|
||||
: Logger("WindowLogger")
|
||||
, m_enabled(false)
|
||||
, m_previousLogCount(0)
|
||||
, m_waiting(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -97,14 +98,16 @@ void LogController::addLog(Logger::LogLevel type, const LogMessage& message)
|
||||
)
|
||||
);
|
||||
|
||||
if (m_waiting.try_lock())
|
||||
if (!m_waiting)
|
||||
{
|
||||
m_waiting = true;
|
||||
std::thread([&]()
|
||||
{
|
||||
std::this_thread::sleep_for( std::chrono::seconds(1) );
|
||||
syncLogs();
|
||||
m_waiting.unlock();
|
||||
}).detach();
|
||||
m_waiting = false;
|
||||
}
|
||||
).detach();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef LOG_CONTROLLER_H
|
||||
#define LOG_CONTROLLER_H
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/view/LogView.h"
|
||||
|
||||
@@ -44,7 +42,7 @@ private:
|
||||
|
||||
void addLog(Logger::LogLevel type, const LogMessage& message);
|
||||
void syncLogs();
|
||||
std::mutex m_waiting;
|
||||
bool m_waiting;
|
||||
int m_previousLogCount;
|
||||
Logger::LogLevelMask m_logLevel;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
CxxVerboseAstVisitor::CxxVerboseAstVisitor(clang::ASTContext* context, clang::Preprocessor* preprocessor, ParserClient* client, FileRegister* fileRegister)
|
||||
: base(context, preprocessor, client, fileRegister)
|
||||
, m_currentFilePath("")
|
||||
, m_indentation(0)
|
||||
{
|
||||
}
|
||||
@@ -36,6 +37,12 @@ bool CxxVerboseAstVisitor::TraverseDecl(clang::Decl *d)
|
||||
ParseLocation loc = getParseLocation(d->getSourceRange());
|
||||
stream << " <" << loc.startLineNumber << ":" << loc.startColumnNumber << ", " << loc.endLineNumber << ":" << loc.endColumnNumber << ">";
|
||||
|
||||
if (m_currentFilePath != loc.filePath.str())
|
||||
{
|
||||
m_currentFilePath = loc.filePath.str();
|
||||
LOG_INFO_STREAM_BARE(<< "Indexer - Traversing \"" + m_currentFilePath + "\"" );
|
||||
}
|
||||
|
||||
LOG_INFO_STREAM_BARE(<< "Indexer - " << stream.str());
|
||||
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ private:
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string m_currentFilePath;
|
||||
unsigned int m_indentation;
|
||||
};
|
||||
|
||||
|
||||
@@ -288,8 +288,12 @@ std::shared_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
|
||||
|
||||
std::string CxxDeclNameResolver::getNameForAnonymousSymbol(const std::string& symbolKindName, const clang::PresumedLoc& presumedBegin)
|
||||
{
|
||||
return "anonymous " + symbolKindName +
|
||||
" (" + FilePath(presumedBegin.getFilename()).fileName() + "<" + std::to_string(presumedBegin.getLine()) + ":" + std::to_string(presumedBegin.getColumn()) + ">)";
|
||||
if (presumedBegin.isValid())
|
||||
{
|
||||
return "anonymous " + symbolKindName +
|
||||
" (" + FilePath(presumedBegin.getFilename()).fileName() + "<" + std::to_string(presumedBegin.getLine()) + ":" + std::to_string(presumedBegin.getColumn()) + ">)";
|
||||
}
|
||||
return "anonymous " + symbolKindName;
|
||||
}
|
||||
|
||||
std::string CxxDeclNameResolver::getTemplateParameterString(const clang::NamedDecl* parameter)
|
||||
@@ -333,7 +337,7 @@ std::string CxxDeclNameResolver::getTemplateParameterTypeString(const clang::Non
|
||||
{
|
||||
typeNameResolver.ignoreContextDecl(m_currentDecl);
|
||||
}
|
||||
|
||||
|
||||
std::string typeString = "";
|
||||
|
||||
std::shared_ptr<CxxTypeName> typeName = typeNameResolver.getName(parameter->getType());
|
||||
|
||||
Reference in New Issue
Block a user