[Lldb-commits] [lldb] 64678ef - [lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Dec 16 00:16:59 PST 2019
Author: Raphael Isemann
Date: 2019-12-16T09:16:33+01:00
New Revision: 64678ef9f289e9c1951fee5dbcacde583f3d6576
URL: https://github.com/llvm/llvm-project/commit/64678ef9f289e9c1951fee5dbcacde583f3d6576
DIFF: https://github.com/llvm/llvm-project/commit/64678ef9f289e9c1951fee5dbcacde583f3d6576.diff
LOG: [lldb][NFC] Remove ClangASTImporter::ResolveDeclOrigin
ResolveDeclOrigin was just an inconvenience method around GetDeclOrigin.
Added:
Modified:
lldb/include/lldb/Symbol/ClangASTImporter.h
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Symbol/ClangASTImporter.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h
index 098091f7167f..cd01bed624cc 100644
--- a/lldb/include/lldb/Symbol/ClangASTImporter.h
+++ b/lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -96,19 +96,6 @@ class ClangASTImporter {
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);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index d05c074991ee..7a23606f57bc 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -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 @@ template <class D> class DeclFromUser : public TaggedASTDecl<D> {
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();
}
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index 83a7ae2893c3..9d9eb49f1cb9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -371,8 +371,7 @@ class ClangASTSource : public ClangExternalASTSourceCommon,
///
/// \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,
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index 80c5c4a6f345..9b5319605150 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -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);
}
}
More information about the lldb-commits
mailing list