data: Fixed uppercase CXX header files saved in lowercase & remove symlinks from FilePath when canonicalizing (issue #437)

bug id = 437
This commit is contained in:
Eberhard Graether
2017-08-02 14:19:44 +02:00
parent 8c5b69dce6
commit e089900571
6 changed files with 32 additions and 6 deletions
+13
View File
@@ -124,6 +124,7 @@ FilePath FilePath::canonical() const
{
return FilePath(*this);
}
if (!exists())
{
return FilePath(*this);
@@ -137,14 +138,20 @@ FilePath FilePath::canonical() const
{
// /a/b/.. is not necessarily /a if b is a symbolic link
if (boost::filesystem::is_symlink(canonicalPath))
{
canonicalPath /= *it;
}
// /a/b/../.. is not /a/b/.. under most circumstances
// We can end up with ..s in our result because of symbolic links
else if (canonicalPath.filename() == "..")
{
canonicalPath /= *it;
}
// Otherwise it should be safe to resolve the parent
else
{
canonicalPath = canonicalPath.parent_path();
}
}
else if (*it == ".")
{
@@ -155,7 +162,13 @@ FilePath FilePath::canonical() const
// Just cat other path entries
canonicalPath /= *it;
}
if (boost::filesystem::is_symlink(canonicalPath))
{
canonicalPath = boost::filesystem::canonical(canonicalPath);
}
}
FilePath ret(canonicalPath);
ret.m_canonicalized = true;
return ret;
@@ -652,7 +652,7 @@ ParseLocation CxxAstVisitor::getParseLocation(const clang::SourceLocation& loc)
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
parseLocation.filePath = m_canonicalFilePathCache->getValue(fileEntry->getName());
parseLocation.filePath = m_canonicalFilePathCache->getValue(utility::getFileNameOfFileEntry(fileEntry));
}
}
@@ -767,7 +767,8 @@ bool CxxAstVisitorComponentIndexer::isLocatedInUnparsedProjectFile(clang::Source
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
FilePath filePath = getAstVisitor()->getCanonicalFilePathCache()->getValue(fileEntry->getName());
FilePath filePath =
getAstVisitor()->getCanonicalFilePathCache()->getValue(utility::getFileNameOfFileEntry(fileEntry));
if (m_fileRegister->hasFilePath(filePath))
{
@@ -805,8 +806,8 @@ bool CxxAstVisitorComponentIndexer::isLocatedInProjectFile(clang::SourceLocation
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != NULL)
{
std::string fileName = fileEntry->getName();
FilePath filePath = getAstVisitor()->getCanonicalFilePathCache()->getValue(fileName);
FilePath filePath =
getAstVisitor()->getCanonicalFilePathCache()->getValue(utility::getFileNameOfFileEntry(fileEntry));
bool ret = m_fileRegister->hasFilePath(filePath);
m_inProjectFileMap[fileId] = ret;
return ret;
@@ -7,6 +7,7 @@
#include "utility/file/FileSystem.h"
#include "utility/file/FileRegister.h"
#include "data/parser/cxx/utilityCxxAstVisitor.h"
#include "data/parser/ParserClient.h"
#include "data/parser/ParseLocation.h"
@@ -33,7 +34,7 @@ void PreprocessorCallbacks::FileChanged(
const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(m_sourceManager.getFileID(location));
if (fileEntry)
{
filePath = m_canonicalFilePathCache->getValue(fileEntry->getName());
filePath = m_canonicalFilePathCache->getValue(utility::getFileNameOfFileEntry(fileEntry));
}
if (!filePath.empty() && m_fileRegister->hasFilePath(filePath))
@@ -59,7 +60,7 @@ void PreprocessorCallbacks::InclusionDirective(
){
if (!m_currentPath.empty() && fileEntry)
{
FilePath includedFilePath = m_canonicalFilePathCache->getValue(fileEntry->getName());
FilePath includedFilePath = m_canonicalFilePathCache->getValue(utility::getFileNameOfFileEntry(fileEntry));
if (m_fileRegister->hasFilePath(includedFilePath))
{
const NameHierarchy referencedNameHierarchy(includedFilePath.str(), NAME_DELIMITER_FILE);
@@ -71,3 +71,13 @@ SymbolKind utility::convertTagKind(clang::TagTypeKind tagKind)
return SYMBOL_KIND_MAX;
}
}
clang::StringRef utility::getFileNameOfFileEntry(const clang::FileEntry* entry)
{
clang::StringRef fileName = entry->tryGetRealPathName();
if (!fileName.size())
{
fileName = entry->getName();
}
return fileName;
}
@@ -11,6 +11,7 @@ namespace utility
bool isImplicit(const clang::Decl* d);
AccessKind convertAccessSpecifier(clang::AccessSpecifier access);
SymbolKind convertTagKind(clang::TagTypeKind tagKind);
clang::StringRef getFileNameOfFileEntry(const clang::FileEntry* entry);
}
#endif // UTILITY_CXX_AST_VISITOR_H