[Lldb-commits] [lldb] r366293 - [NativePDB] Make GetTranslationUnitDecl return an lldb CompilerDeclCtx
Nathan Lanza via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 17 00:05:49 PDT 2019
Author: lanza
Date: Wed Jul 17 00:05:49 2019
New Revision: 366293
URL: http://llvm.org/viewvc/llvm-project?rev=366293&view=rev
Log:
[NativePDB] Make GetTranslationUnitDecl return an lldb CompilerDeclCtx
Summary:
We intend to make PdbAstBuilder abstract and implement
PdbAstBuilderClang along with any other languages that wish to use
PDBs. This is the first step.
Differential Revision: https://reviews.llvm.org/D64852
Modified:
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp?rev=366293&r1=366292&r2=366293&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp Wed Jul 17 00:05:49 2019
@@ -214,8 +214,8 @@ PdbAstBuilder::PdbAstBuilder(ObjectFile
BuildParentMap();
}
-clang::DeclContext &PdbAstBuilder::GetTranslationUnitDecl() {
- return *m_clang.GetTranslationUnitDecl();
+lldb_private::CompilerDeclContext PdbAstBuilder::GetTranslationUnitDecl() {
+ return ToCompilerDeclContext(*m_clang.GetTranslationUnitDecl());
}
std::pair<clang::DeclContext *, std::string>
@@ -492,7 +492,7 @@ clang::Decl *PdbAstBuilder::GetOrCreateD
clang::DeclContext *PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) {
if (uid.kind() == PdbSymUidKind::CompilandSym) {
if (uid.asCompilandSym().offset == 0)
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
}
clang::Decl *decl = GetOrCreateDeclForUid(uid);
@@ -507,7 +507,7 @@ PdbAstBuilder::CreateDeclInfoForUndecora
MSVCUndecoratedNameParser parser(name);
llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
- clang::DeclContext *context = &GetTranslationUnitDecl();
+ auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
llvm::StringRef uname = specs.back().GetBaseName();
specs = specs.drop_back();
@@ -548,7 +548,7 @@ PdbAstBuilder::GetParentDeclContextForSy
StringView name{pub->Name.begin(), pub->Name.size()};
llvm::ms_demangle::SymbolNode *node = demangler.parse(name);
if (!node)
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
llvm::ArrayRef<llvm::ms_demangle::Node *> name_components{
node->Name->Components->Nodes, node->Name->Components->Count - 1};
@@ -569,7 +569,7 @@ PdbAstBuilder::GetParentDeclContextForSy
}
// It's not a type. It must be a series of namespaces.
- clang::DeclContext *context = &GetTranslationUnitDecl();
+ auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
while (!name_components.empty()) {
std::string ns = name_components.front()->toString();
context = GetOrCreateNamespaceDecl(ns.c_str(), *context);
@@ -597,7 +597,7 @@ clang::DeclContext *PdbAstBuilder::GetPa
PdbTypeSymId type_id = uid.asTypeSym();
auto iter = m_parent_types.find(type_id.index);
if (iter == m_parent_types.end())
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
return GetOrCreateDeclContextForUid(PdbTypeSymId(iter->second));
}
case PdbSymUidKind::FieldListMember:
@@ -635,7 +635,7 @@ clang::DeclContext *PdbAstBuilder::GetPa
default:
break;
}
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
}
bool PdbAstBuilder::CompleteType(clang::QualType qt) {
@@ -866,7 +866,8 @@ clang::VarDecl *PdbAstBuilder::GetOrCrea
return llvm::dyn_cast<clang::VarDecl>(decl);
CVSymbol sym = m_index.ReadSymbolRecord(var_id);
- return CreateVariableDecl(PdbSymUid(var_id), sym, GetTranslationUnitDecl());
+ auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
+ return CreateVariableDecl(PdbSymUid(var_id), sym, *context);
}
clang::TypedefNameDecl *
Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h?rev=366293&r1=366292&r2=366293&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h Wed Jul 17 00:05:49 2019
@@ -53,7 +53,7 @@ public:
// Constructors and Destructors
PdbAstBuilder(ObjectFile &obj, PdbIndex &index);
- clang::DeclContext &GetTranslationUnitDecl();
+ lldb_private::CompilerDeclContext GetTranslationUnitDecl();
clang::Decl *GetOrCreateDeclForUid(PdbSymUid uid);
clang::DeclContext *GetOrCreateDeclContextForUid(PdbSymUid uid);
More information about the lldb-commits
mailing list