logic: fixed filepaths to always use a canonical casing (issue #516)

* added CanonicalFilePathCache to also reserve the initially recorded casing of file names
* use canonical file path cache to resolve filepaths in names of symbols (anonymous, static, ...)
* null reference fixes
This commit is contained in:
mlangkabel
2017-11-12 16:29:12 +01:00
parent 85207c6355
commit 6488c6538e
88 changed files with 277 additions and 3151 deletions
@@ -1,5 +1,6 @@
#include "data/parser/cxx/CommentHandler.h"
#include "data/parser/cxx/CanonicalFilePathCache.h"
#include "data/parser/cxx/utilityClang.h"
#include "data/parser/ParseLocation.h"
#include "data/parser/ParserClient.h"
@@ -8,7 +9,7 @@
CommentHandler::CommentHandler(
std::shared_ptr<ParserClient> client,
std::shared_ptr<FileRegister> fileRegister,
std::shared_ptr<FilePathCache> canonicalFilePathCache
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache
)
: m_client(client)
, m_fileRegister(fileRegister)
@@ -29,12 +30,12 @@ bool CommentHandler::HandleComment(clang::Preprocessor& preprocessor, clang::Sou
clang::FileID fileId = sourceManager.getFileID(sourceRange.getBegin());
// find the location file
if (!fileId.isInvalid())
if (fileId.isValid())
{
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
if (fileEntry != nullptr && fileEntry->isValid())
{
FilePath filePath = m_canonicalFilePathCache->getValue(utility::getFileNameOfFileEntry(fileEntry));
FilePath filePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsIndexed(filePath))
{
m_client->onCommentParsed(ParseLocation(