}
}
-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()) {
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) {
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;
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);
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; }
}
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