-
Notifications
You must be signed in to change notification settings - Fork 15k
[lldb][DeclVendor] Remove ClangDeclVendor #164380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][DeclVendor] Remove ClangDeclVendor #164380
Conversation
The `ClangDeclVendor` used to contain more Clang-specific code than it does nowadays. But at this point, all it does is wrap the `DeclVendor::FindDecls` call and copy the resulting decls into `std::vector<clang::NamedDecl*>`. I.e., it converts the generic `CompilerDecl`s to `clang::NamedDecl*`s. In my opinion at this point it doesn't do enough to justify making it part of the `DeclVendor` hierarchy. This patch removes the `ClangDeclVendor` and instead does the conversion at callsite.
|
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesThe In my opinion at this point it doesn't do enough to justify making it part of the This patch removes the Full diff: https://github.com/llvm/llvm-project/pull/164380.diff 11 Files Affected:
diff --git a/lldb/include/lldb/Symbol/DeclVendor.h b/lldb/include/lldb/Symbol/DeclVendor.h
index 19ab2bb66e2cc..5b0cbf9a15357 100644
--- a/lldb/include/lldb/Symbol/DeclVendor.h
+++ b/lldb/include/lldb/Symbol/DeclVendor.h
@@ -20,7 +20,6 @@ namespace lldb_private {
class DeclVendor {
public:
enum DeclVendorKind {
- eClangDeclVendor,
eClangModuleDeclVendor,
eAppleObjCDeclVendor,
eLastClangDeclVendor,
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
index 2aae7d13449d1..01d588ff6a78b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -5,7 +5,6 @@ add_lldb_library(lldbPluginExpressionParserClang
ClangASTImporter.cpp
ClangASTMetadata.cpp
ClangASTSource.cpp
- ClangDeclVendor.cpp
ClangExpressionDeclMap.cpp
ClangExpressionHelper.cpp
ClangExpressionParser.cpp
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index ebe7be43e5dd7..0efeb2e68decb 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -8,7 +8,6 @@
#include "ClangASTSource.h"
-#include "ClangDeclVendor.h"
#include "ClangModulesDeclVendor.h"
#include "lldb/Core/Module.h"
@@ -799,7 +798,7 @@ void ClangASTSource::FindDeclInModules(NameSearchContext &context,
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
return;
@@ -807,7 +806,8 @@ void ClangASTSource::FindDeclInModules(NameSearchContext &context,
LLDB_LOG(log, " CAS::FEVD Matching entity found for \"{0}\" in the modules",
name);
- clang::NamedDecl *const decl_from_modules = decls[0];
+ auto *const decl_from_modules =
+ llvm::cast<NamedDecl>(ClangUtil::GetDecl(decls[0]));
if (llvm::isa<clang::TypeDecl>(decl_from_modules) ||
llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) ||
@@ -849,16 +849,16 @@ void ClangASTSource::FindDeclInObjCRuntime(NameSearchContext &context,
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
- auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor);
+ auto *clang_decl_vendor = llvm::cast<DeclVendor>(decl_vendor);
if (!clang_decl_vendor->FindDecls(name, append, max_matches, decls))
return;
LLDB_LOG(log, " CAS::FEVD Matching type found for \"{0}\" in the runtime",
name);
- clang::Decl *copied_decl = CopyDecl(decls[0]);
+ clang::Decl *copied_decl = CopyDecl(ClangUtil::GetDecl(decls[0]));
clang::NamedDecl *copied_named_decl =
copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
@@ -1081,14 +1081,14 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ConstString interface_name(interface_decl->getNameAsString().c_str());
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
if (!modules_decl_vendor->FindDecls(interface_name, append, max_matches,
decls))
break;
ObjCInterfaceDecl *interface_decl_from_modules =
- dyn_cast<ObjCInterfaceDecl>(decls[0]);
+ dyn_cast<ObjCInterfaceDecl>(ClangUtil::GetDecl(decls[0]));
if (!interface_decl_from_modules)
break;
@@ -1121,15 +1121,15 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ConstString interface_name(interface_decl->getNameAsString().c_str());
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
- auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor);
+ auto *clang_decl_vendor = llvm::cast<DeclVendor>(decl_vendor);
if (!clang_decl_vendor->FindDecls(interface_name, append, max_matches,
decls))
break;
ObjCInterfaceDecl *runtime_interface_decl =
- dyn_cast<ObjCInterfaceDecl>(decls[0]);
+ dyn_cast<ObjCInterfaceDecl>(ClangUtil::GetDecl(decls[0]));
if (!runtime_interface_decl)
break;
@@ -1254,13 +1254,13 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
if (!modules_decl_vendor->FindDecls(class_name, append, max_matches, decls))
break;
DeclFromUser<const ObjCInterfaceDecl> interface_decl_from_modules(
- dyn_cast<ObjCInterfaceDecl>(decls[0]));
+ dyn_cast<ObjCInterfaceDecl>(ClangUtil::GetDecl(decls[0])));
if (!interface_decl_from_modules.IsValid())
break;
@@ -1297,14 +1297,14 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
- auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor);
+ auto *clang_decl_vendor = llvm::cast<DeclVendor>(decl_vendor);
if (!clang_decl_vendor->FindDecls(class_name, append, max_matches, decls))
break;
DeclFromUser<const ObjCInterfaceDecl> interface_decl_from_runtime(
- dyn_cast<ObjCInterfaceDecl>(decls[0]));
+ dyn_cast<ObjCInterfaceDecl>(ClangUtil::GetDecl(decls[0])));
if (!interface_decl_from_runtime.IsValid())
break;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
deleted file mode 100644
index 867d4ff0a9077..0000000000000
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===-- ClangDeclVendor.cpp -----------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
-#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
-#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-
-#include "lldb/Utility/ConstString.h"
-
-using namespace lldb_private;
-
-uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
- uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls) {
- if (!append)
- decls.clear();
-
- std::vector<CompilerDecl> compiler_decls;
- uint32_t ret = FindDecls(name, /*append*/ false, max_matches, compiler_decls);
- for (CompilerDecl compiler_decl : compiler_decls) {
- clang::Decl *d = ClangUtil::GetDecl(compiler_decl);
- clang::NamedDecl *nd = llvm::cast<clang::NamedDecl>(d);
- decls.push_back(nd);
- }
- return ret;
-}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
deleted file mode 100644
index a9b2d4110ab2f..0000000000000
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- ClangDeclVendor.h ---------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDECLVENDOR_H
-#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDECLVENDOR_H
-
-#include "lldb/Symbol/DeclVendor.h"
-
-namespace clang {
-class NamedDecl;
-}
-
-namespace lldb_private {
-
-// A clang specialized extension to DeclVendor.
-class ClangDeclVendor : public DeclVendor {
-public:
- ClangDeclVendor(DeclVendorKind kind) : DeclVendor(kind) {}
-
- ~ClangDeclVendor() override = default;
-
- using DeclVendor::FindDecls;
-
- uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
- std::vector<clang::NamedDecl *> &decls);
-
- static bool classof(const DeclVendor *vendor) {
- return vendor->GetKind() >= eClangDeclVendor &&
- vendor->GetKind() < eLastClangDeclVendor;
- }
-
-private:
- ClangDeclVendor(const ClangDeclVendor &) = delete;
- const ClangDeclVendor &operator=(const ClangDeclVendor &) = delete;
-};
-} // namespace lldb_private
-
-#endif
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 833bc3b7fc251..9cb8f7a44de61 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1023,13 +1023,14 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
bool append = false;
uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
return;
assert(!decls.empty() && "FindDecls returned true but no decls?");
- clang::NamedDecl *const decl_from_modules = decls[0];
+ auto *const decl_from_modules =
+ llvm::cast<NamedDecl>(ClangUtil::GetDecl(decls[0]));
LLDB_LOG(log,
" CAS::FEVD Matching decl found for "
@@ -1223,7 +1224,7 @@ bool ClangExpressionDeclMap::LookupFunction(
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
- std::vector<clang::NamedDecl *> decls_from_modules;
+ std::vector<CompilerDecl> decls_from_modules;
if (target) {
if (std::shared_ptr<ClangModulesDeclVendor> decl_vendor =
@@ -1314,7 +1315,8 @@ bool ClangExpressionDeclMap::LookupFunction(
}
if (!found_function_with_type_info) {
- for (clang::NamedDecl *decl : decls_from_modules) {
+ for (const CompilerDecl &compiler_decl : decls_from_modules) {
+ clang::Decl *decl = ClangUtil::GetDecl(compiler_decl);
if (llvm::isa<clang::FunctionDecl>(decl)) {
clang::NamedDecl *copied_decl =
llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 67984c5f44bf0..b77e2690deb06 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -226,7 +226,7 @@ void StoringDiagnosticConsumer::SetCurrentModuleProgress(
}
ClangModulesDeclVendor::ClangModulesDeclVendor()
- : ClangDeclVendor(eClangModuleDeclVendor) {}
+ : DeclVendor(eClangModuleDeclVendor) {}
ClangModulesDeclVendor::~ClangModulesDeclVendor() = default;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
index d820552a29129..ad4d060319e31 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
@@ -9,17 +9,16 @@
#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
+#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/SourceModule.h"
#include "lldb/Target/Platform.h"
-#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
-
#include <set>
#include <vector>
namespace lldb_private {
-class ClangModulesDeclVendor : public ClangDeclVendor {
+class ClangModulesDeclVendor : public DeclVendor {
public:
// Constructors and Destructors
ClangModulesDeclVendor();
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index d6d2df27c5e74..762a791262254 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -131,7 +131,7 @@ class lldb_private::AppleObjCExternalASTSource
};
AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime)
- : ClangDeclVendor(eAppleObjCDeclVendor), m_runtime(runtime),
+ : DeclVendor(eAppleObjCDeclVendor), m_runtime(runtime),
m_type_realizer_sp(m_runtime.GetEncodingToType()) {
m_ast_ctx = std::make_shared<TypeSystemClang>(
"AppleObjCDeclVendor AST",
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
index 3bb0f77f6bde4..2cfa86dad74b1 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
@@ -11,15 +11,15 @@
#include "lldb/lldb-private.h"
-#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Symbol/DeclVendor.h"
namespace lldb_private {
class AppleObjCExternalASTSource;
-class AppleObjCDeclVendor : public ClangDeclVendor {
+class AppleObjCDeclVendor : public DeclVendor {
public:
AppleObjCDeclVendor(ObjCLanguageRuntime &runtime);
diff --git a/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn
index 5efc1531857b8..51911d7fca2ee 100644
--- a/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/source/Plugins/ExpressionParser/Clang/BUILD.gn
@@ -47,7 +47,6 @@ static_library("Clang") {
"ClangASTImporter.cpp",
"ClangASTMetadata.cpp",
"ClangASTSource.cpp",
- "ClangDeclVendor.cpp",
"ClangExpressionDeclMap.cpp",
"ClangExpressionHelper.cpp",
"ClangExpressionParser.cpp",
|
|
Thanks! |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/13267 Here is the relevant piece of the build log for the reference |
The
ClangDeclVendorused to contain more Clang-specific code than it does nowadays. But at this point, all it does is wrap theDeclVendor::FindDeclscall and copy the resulting decls intostd::vector<clang::NamedDecl*>. I.e., it converts the genericCompilerDecls toclang::NamedDecl*s.In my opinion at this point it doesn't do enough to justify making it part of the
DeclVendorhierarchy.This patch removes the
ClangDeclVendorand instead does the conversion at callsite.