logic: cxx indexer fixes

* fixed comment locations have been saved to wrong database table
* fixed usage of tryGetRealPathName on windows
* used real filename in PreprocessorCallbacks, DiagnosticsConsumer and CommentHandler
* fixed crash in IncludeValidation when only one source file was checked
This commit is contained in:
malte_langkabel
2017-08-09 10:59:47 +02:00
parent 42fc52b8f7
commit 1ac63f0158
7 changed files with 85 additions and 46 deletions
+20 -9
View File
@@ -1,5 +1,6 @@
#include "data/parser/cxx/CommentHandler.h"
#include "data/parser/cxx/utilityCxxAstVisitor.h"
#include "data/parser/ParseLocation.h"
#include "data/parser/ParserClient.h"
#include "utility/file/FileRegister.h"
@@ -25,16 +26,26 @@ bool CommentHandler::HandleComment(clang::Preprocessor& preprocessor, clang::Sou
const clang::PresumedLoc& presumedBegin = sourceManager.getPresumedLoc(sourceRange.getBegin(), false);
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false);
FilePath filePath = m_canonicalFilePathCache->getValue(presumedBegin.getFilename());
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsIndexed(filePath))
clang::FileID fileId = sourceManager.getFileID(sourceRange.getBegin());
// find the location file
if (!fileId.isInvalid())
{
m_client->onCommentParsed(ParseLocation(
filePath,
presumedBegin.getLine(),
presumedBegin.getColumn(),
presumedEnd.getLine(),
presumedEnd.getColumn()
));
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
FilePath filePath = m_canonicalFilePathCache->getValue(utility::getFileNameOfFileEntry(fileEntry));
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsIndexed(filePath))
{
m_client->onCommentParsed(ParseLocation(
filePath,
presumedBegin.getLine(),
presumedBegin.getColumn(),
presumedEnd.getLine(),
presumedEnd.getColumn()
));
}
}
}
return false;