Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/lib_cxx/data/parser/cxx/CanonicalFilePathCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,23 @@ Id CanonicalFilePathCache::getFileSymbolId(const std::wstring& path)
return 0;
}

std::wstring CanonicalFilePathCache::getDeclarationFileName(const clang::Decl* declaration)
FilePath CanonicalFilePathCache::getDeclarationFilePath(const clang::Decl* declaration)
{
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
const clang::FileID fileId = sourceManager.getFileID(declaration->getBeginLoc());
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
if (fileEntry != nullptr && fileEntry->isValid())
{
return getCanonicalFilePath(fileId, sourceManager).fileName();
return getCanonicalFilePath(fileId, sourceManager);
}
return getCanonicalFilePath(
utility::decodeFromUtf8(
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()))
.fileName();
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()));
}

std::wstring CanonicalFilePathCache::getDeclarationFileName(const clang::Decl* declaration)
{
return getDeclarationFilePath(declaration).fileName();
}

bool CanonicalFilePathCache::isProjectFile(
Expand Down
1 change: 1 addition & 0 deletions src/lib_cxx/data/parser/cxx/CanonicalFilePathCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CanonicalFilePathCache
Id getFileSymbolId(const clang::FileEntry* entry);
Id getFileSymbolId(const std::wstring& path);

FilePath getDeclarationFilePath(const clang::Decl* declaration);
std::wstring getDeclarationFileName(const clang::Decl* declaration);

bool isProjectFile(const clang::FileID& fileId, const clang::SourceManager& sourceManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ Id CxxAstVisitorComponentIndexer::getOrCreateSymbolId(const clang::NamedDecl* de
symbolName.pop();
symbolName.push(NameElement(
L".:main:." +
getAstVisitor()->getCanonicalFilePathCache()->getDeclarationFileName(decl),
getAstVisitor()->getCanonicalFilePathCache()->getDeclarationFilePath(decl).wstr(),
sig.getPrefix(),
sig.getPostfix()));
}
Expand Down