[NativePDB] Make GetOrCreateDeclForUid return an lldb CompilerDecl

We intend to make PdbAstBuilder abstract and implement
PdbAstBuilderClang along with any other languages that wish to use
PDBs. Thus, change GetOrCreateDeclForUid from returning a clang decl
to a lldb_private::CompilerDecl.

llvm-svn: 366650
This commit is contained in:
Nathan Lanza 2019-07-21 07:46:18 +00:00
parent 1d149d08d3
commit fe1b8a0911
3 changed files with 16 additions and 12 deletions

View File

@ -465,9 +465,9 @@ clang::Decl *PdbAstBuilder::GetOrCreateSymbolForId(PdbCompilandSymId id) {
}
}
clang::Decl *PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid) {
llvm::Optional<CompilerDecl> PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid) {
if (clang::Decl *result = TryGetDecl(uid))
return result;
return ToCompilerDecl(*result);
clang::Decl *result = nullptr;
switch (uid.kind()) {
@ -480,13 +480,13 @@ clang::Decl *PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid) {
result = tag;
break;
}
return nullptr;
return llvm::None;
}
default:
return nullptr;
return llvm::None;
}
m_uid_to_decl[toOpaqueUid(uid)] = result;
return result;
return ToCompilerDecl(*result);
}
clang::DeclContext *PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) {
@ -494,8 +494,10 @@ clang::DeclContext *PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) {
if (uid.asCompilandSym().offset == 0)
return FromCompilerDeclContext(GetTranslationUnitDecl());
}
clang::Decl *decl = GetOrCreateDeclForUid(uid);
auto option = GetOrCreateDeclForUid(uid);
if (!option)
return nullptr;
clang::Decl *decl = FromCompilerDecl(option.getValue());
if (!decl)
return nullptr;

View File

@ -55,7 +55,8 @@ public:
lldb_private::CompilerDeclContext GetTranslationUnitDecl();
clang::Decl *GetOrCreateDeclForUid(PdbSymUid uid);
llvm::Optional<lldb_private::CompilerDecl>
GetOrCreateDeclForUid(PdbSymUid uid);
clang::DeclContext *GetOrCreateDeclContextForUid(PdbSymUid uid);
clang::DeclContext *GetParentDeclContext(PdbSymUid uid);
@ -76,7 +77,7 @@ public:
CompilerDecl ToCompilerDecl(clang::Decl &decl);
CompilerType ToCompilerType(clang::QualType qt);
CompilerDeclContext ToCompilerDeclContext(clang::DeclContext &context);
clang::Decl * FromCompilerDecl(CompilerDecl decl);
clang::Decl *FromCompilerDecl(CompilerDecl decl);
clang::DeclContext *FromCompilerDeclContext(CompilerDeclContext context);
ClangASTContext &clang() { return m_clang; }

View File

@ -1506,9 +1506,10 @@ size_t SymbolFileNativePDB::ParseVariablesForContext(const SymbolContext &sc) {
}
CompilerDecl SymbolFileNativePDB::GetDeclForUID(lldb::user_id_t uid) {
clang::Decl *decl = m_ast->GetOrCreateDeclForUid(PdbSymUid(uid));
return m_ast->ToCompilerDecl(*decl);
if (auto decl = m_ast->GetOrCreateDeclForUid(uid))
return decl.getValue();
else
return CompilerDecl();
}
CompilerDeclContext