Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

Commit 31cbf6c

Browse files
authored
logic: Fixed multiple main declarations not shown as separate symbols when declaring file has same name (#950)
regards #233
1 parent f37716d commit 31cbf6c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/lib_cxx/data/parser/cxx/CanonicalFilePathCache.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,23 @@ Id CanonicalFilePathCache::getFileSymbolId(const std::wstring& path)
121121
return 0;
122122
}
123123

124-
std::wstring CanonicalFilePathCache::getDeclarationFileName(const clang::Decl* declaration)
124+
FilePath CanonicalFilePathCache::getDeclarationFilePath(const clang::Decl* declaration)
125125
{
126126
const clang::SourceManager& sourceManager = declaration->getASTContext().getSourceManager();
127127
const clang::FileID fileId = sourceManager.getFileID(declaration->getBeginLoc());
128128
const clang::FileEntry* fileEntry = sourceManager.getFileEntryForID(fileId);
129129
if (fileEntry != nullptr && fileEntry->isValid())
130130
{
131-
return getCanonicalFilePath(fileId, sourceManager).fileName();
131+
return getCanonicalFilePath(fileId, sourceManager);
132132
}
133133
return getCanonicalFilePath(
134134
utility::decodeFromUtf8(
135-
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()))
136-
.fileName();
135+
sourceManager.getPresumedLoc(declaration->getBeginLoc()).getFilename()));
136+
}
137+
138+
std::wstring CanonicalFilePathCache::getDeclarationFileName(const clang::Decl* declaration)
139+
{
140+
return getDeclarationFilePath(declaration).fileName();
137141
}
138142

139143
bool CanonicalFilePathCache::isProjectFile(

src/lib_cxx/data/parser/cxx/CanonicalFilePathCache.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CanonicalFilePathCache
2929
Id getFileSymbolId(const clang::FileEntry* entry);
3030
Id getFileSymbolId(const std::wstring& path);
3131

32+
FilePath getDeclarationFilePath(const clang::Decl* declaration);
3233
std::wstring getDeclarationFileName(const clang::Decl* declaration);
3334

3435
bool isProjectFile(const clang::FileID& fileId, const clang::SourceManager& sourceManager);

src/lib_cxx/data/parser/cxx/CxxAstVisitorComponentIndexer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ Id CxxAstVisitorComponentIndexer::getOrCreateSymbolId(const clang::NamedDecl* de
999999
symbolName.pop();
10001000
symbolName.push(NameElement(
10011001
L".:main:." +
1002-
getAstVisitor()->getCanonicalFilePathCache()->getDeclarationFileName(decl),
1002+
getAstVisitor()->getCanonicalFilePathCache()->getDeclarationFilePath(decl).wstr(),
10031003
sig.getPrefix(),
10041004
sig.getPostfix()));
10051005
}

0 commit comments

Comments
 (0)