[lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin

ResolveDeclOrigin was just an inconvenience method around GetDeclOrigin.
This commit is contained in:
Raphael Isemann 2019-12-16 09:00:58 +01:00
parent 51707196a0
commit 64678ef9f2
4 changed files with 30 additions and 56 deletions

View File

@ -96,19 +96,6 @@ public:
bool RequireCompleteType(clang::QualType type);
bool ResolveDeclOrigin(const clang::Decl *decl, clang::Decl **original_decl,
clang::ASTContext **original_ctx) {
DeclOrigin origin = GetDeclOrigin(decl);
if (original_decl)
*original_decl = origin.decl;
if (original_ctx)
*original_ctx = origin.ctx;
return origin.Valid();
}
void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl);
ClangASTMetadata *GetDeclMetadata(const clang::Decl *decl);

View File

@ -438,13 +438,11 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
return;
}
Decl *original_decl = nullptr;
ASTContext *original_ctx = nullptr;
ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(interface_decl);
if (m_ast_importer_sp->ResolveDeclOrigin(interface_decl, &original_decl,
&original_ctx)) {
if (original.Valid()) {
if (ObjCInterfaceDecl *original_iface_decl =
dyn_cast<ObjCInterfaceDecl>(original_decl)) {
dyn_cast<ObjCInterfaceDecl>(original.decl)) {
ObjCInterfaceDecl *complete_iface_decl =
GetCompleteObjCInterface(original_iface_decl);
@ -565,40 +563,38 @@ void ClangASTSource::FindExternalLexicalDecls(
current_id, static_cast<const void *>(m_ast_context));
}
Decl *original_decl = nullptr;
ASTContext *original_ctx = nullptr;
ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(context_decl);
if (!m_ast_importer_sp->ResolveDeclOrigin(context_decl, &original_decl,
&original_ctx))
if (!original.Valid())
return;
LLDB_LOG(
log, " FELD[{0}] Original decl (ASTContext*){1:x} (Decl*){2:x}:\n{3}",
current_id, static_cast<void *>(original_ctx),
static_cast<void *>(original_decl), ClangUtil::DumpDecl(original_decl));
current_id, static_cast<void *>(original.ctx),
static_cast<void *>(original.decl), ClangUtil::DumpDecl(original.decl));
if (ObjCInterfaceDecl *original_iface_decl =
dyn_cast<ObjCInterfaceDecl>(original_decl)) {
dyn_cast<ObjCInterfaceDecl>(original.decl)) {
ObjCInterfaceDecl *complete_iface_decl =
GetCompleteObjCInterface(original_iface_decl);
if (complete_iface_decl && (complete_iface_decl != original_iface_decl)) {
original_decl = complete_iface_decl;
original_ctx = &complete_iface_decl->getASTContext();
original.decl = complete_iface_decl;
original.ctx = &complete_iface_decl->getASTContext();
m_ast_importer_sp->SetDeclOrigin(context_decl, complete_iface_decl);
}
}
if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
ExternalASTSource *external_source = original_ctx->getExternalSource();
if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original.decl)) {
ExternalASTSource *external_source = original.ctx->getExternalSource();
if (external_source)
external_source->CompleteType(original_tag_decl);
}
const DeclContext *original_decl_context =
dyn_cast<DeclContext>(original_decl);
dyn_cast<DeclContext>(original.decl);
if (!original_decl_context)
return;
@ -1036,11 +1032,10 @@ public:
template <class D>
DeclFromUser<D> DeclFromParser<D>::GetOrigin(ClangASTSource &source) {
DeclFromUser<> origin_decl;
source.ResolveDeclOrigin(this->decl, &origin_decl.decl, nullptr);
if (origin_decl.IsInvalid())
ClangASTImporter::DeclOrigin origin = source.GetDeclOrigin(this->decl);
if (!origin.Valid())
return DeclFromUser<D>();
return DeclFromUser<D>(dyn_cast<D>(origin_decl.decl));
return DeclFromUser<D>(dyn_cast<D>(origin.decl));
}
template <class D>
@ -1164,17 +1159,13 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
return;
do {
Decl *original_decl = nullptr;
ASTContext *original_ctx = nullptr;
ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(interface_decl);
m_ast_importer_sp->ResolveDeclOrigin(interface_decl, &original_decl,
&original_ctx);
if (!original_decl)
if (!original.Valid())
break;
ObjCInterfaceDecl *original_interface_decl =
dyn_cast<ObjCInterfaceDecl>(original_decl);
dyn_cast<ObjCInterfaceDecl>(original.decl);
if (FindObjCMethodDeclsWithOrigin(current_id, context,
original_interface_decl, "at origin"))
@ -2004,17 +1995,14 @@ clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
}
}
bool ClangASTSource::ResolveDeclOrigin(const clang::Decl *decl,
clang::Decl **original_decl,
clang::ASTContext **original_ctx) {
ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin(const clang::Decl *decl) {
if (m_ast_importer_sp) {
return m_ast_importer_sp->ResolveDeclOrigin(decl, original_decl,
original_ctx);
return m_ast_importer_sp->GetDeclOrigin(decl);
} else if (m_merger_up) {
return false; // Implement this correctly in ExternalASTMerger
return ClangASTImporter::DeclOrigin(); // Implement this correctly in ExternalASTMerger
} else {
// this can happen early enough that no ExternalASTSource is installed.
return false;
return ClangASTImporter::DeclOrigin();
}
}

View File

@ -371,8 +371,7 @@ public:
///
/// \return
/// True if lookup succeeded; false otherwise.
bool ResolveDeclOrigin(const clang::Decl *decl, clang::Decl **original_decl,
clang::ASTContext **original_ctx);
ClangASTImporter::DeclOrigin GetDeclOrigin(const clang::Decl *decl);
/// Returns m_merger_up. Only call this if the target is configured to use
/// modern lookup,

View File

@ -385,7 +385,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
const clang::CXXRecordDecl *cxx_record_decl =
qual_type->getAsCXXRecordDecl();
if (cxx_record_decl) {
if (ResolveDeclOrigin(cxx_record_decl, nullptr, nullptr))
if (GetDeclOrigin(cxx_record_decl).Valid())
return true;
}
} break;
@ -394,7 +394,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
clang::EnumDecl *enum_decl =
llvm::cast<clang::EnumType>(qual_type)->getDecl();
if (enum_decl) {
if (ResolveDeclOrigin(enum_decl, nullptr, nullptr))
if (GetDeclOrigin(enum_decl).Valid())
return true;
}
} break;
@ -409,7 +409,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
// We currently can't complete objective C types through the newly added
// ASTContext because it only supports TagDecl objects right now...
if (class_interface_decl) {
if (ResolveDeclOrigin(class_interface_decl, nullptr, nullptr))
if (GetDeclOrigin(class_interface_decl).Valid())
return true;
}
}
@ -461,7 +461,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
const clang::CXXRecordDecl *cxx_record_decl =
qual_type->getAsCXXRecordDecl();
if (cxx_record_decl) {
if (ResolveDeclOrigin(cxx_record_decl, nullptr, nullptr))
if (GetDeclOrigin(cxx_record_decl).Valid())
return CompleteAndFetchChildren(qual_type);
}
} break;
@ -470,7 +470,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
clang::EnumDecl *enum_decl =
llvm::cast<clang::EnumType>(qual_type)->getDecl();
if (enum_decl) {
if (ResolveDeclOrigin(enum_decl, nullptr, nullptr))
if (GetDeclOrigin(enum_decl).Valid())
return CompleteAndFetchChildren(qual_type);
}
} break;
@ -485,7 +485,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
// We currently can't complete objective C types through the newly added
// ASTContext because it only supports TagDecl objects right now...
if (class_interface_decl) {
if (ResolveDeclOrigin(class_interface_decl, nullptr, nullptr))
if (GetDeclOrigin(class_interface_decl).Valid())
return CompleteAndFetchChildren(qual_type);
}
}