[Lldb-commits] [lldb] [lldb][Type] Add TypeQuery::SetLanguages API (PR #75926)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 19 04:32:38 PST 2023


https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/75926

This is required for users of `TypeQuery` that limit the set of languages of the query using APIs such as `GetSupportedLanguagesForTypes` or `GetSupportedLanguagesForExpressions`.

Example usage: https://github.com/apple/llvm-project/pull/7885

>From c322019bda30595d4ac551b519cace24937dccde Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Tue, 19 Dec 2023 12:29:17 +0000
Subject: [PATCH] [lldb][Type] Add TypeQuery::SetLanguages API

This is required for users of `TypeQuery` that limit
the set of languages of the query using APIs such as
`GetSupportedLanguagesForTypes` or
`GetSupportedLanguagesForExpressions`.
---
 lldb/include/lldb/Symbol/Type.h | 4 ++++
 lldb/source/Symbol/Type.cpp     | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 307be6c55e0161..acd1a769f13cd6 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -247,6 +247,10 @@ class TypeQuery {
   /// match.
   void AddLanguage(lldb::LanguageType language);
 
+  /// Set the list of languages that should produce a match to only the ones
+  /// specified in \ref languages.
+  void SetLanguages(LanguageSet languages);
+
   /// Check if the language matches any languages that have been added to this
   /// match object.
   ///
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index 293fe1b78f4a54..6069d066eaf66b 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -145,6 +145,10 @@ void TypeQuery::AddLanguage(LanguageType language) {
   m_languages->Insert(language);
 }
 
+void TypeQuery::SetLanguages(LanguageSet languages) {
+  m_languages = std::move(languages);
+}
+
 bool TypeQuery::ContextMatches(
     llvm::ArrayRef<CompilerContext> context_chain) const {
   if (GetExactMatch() || context_chain.size() == m_context.size())



More information about the lldb-commits mailing list