[Lldb-commits] [PATCH] D87076: [lldb/Interpreter] Fix language detection for the REPL InitFile

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 3 01:31:34 PDT 2020

mib created this revision.
mib added a reviewer: teemperor.
mib added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.
mib requested review of this revision.

Previously, before loading the REPL language-specific init file, lldb
checked the selected target language in which case it returned an unknown
language type with the REPL target.

Instead, the patch calls `Language::GetLanguagesSupportingREPLs` and
look for the first element of that set. In case lldb was not configured
with a REPL language, then, it will just stop sourcing the REPL init
file and fallback to the original logic (continuing with the default
init file).


Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>

  rG LLVM Github Monorepo



Index: lldb/source/Interpreter/CommandInterpreter.cpp
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2091,8 +2091,12 @@
-static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file,
-                                LanguageType language) {
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file) {
+  LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
+  LanguageType language = {};
+  if (auto main_repl_language = repl_languages.GetSingularLanguage())
+    language = *main_repl_language;
   if (language == LanguageType::eLanguageTypeUnknown)
@@ -2191,13 +2195,8 @@
   llvm::SmallString<128> init_file;
-  if (is_repl) {
-    LanguageType language = {};
-    TargetSP target_sp = GetDebugger().GetSelectedTarget();
-    if (target_sp)
-      language = target_sp->GetLanguage();
-    GetHomeREPLInitFile(init_file, language);
-  }
+  if (is_repl)
+    GetHomeREPLInitFile(init_file);
   if (init_file.empty())

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87076.289656.patch
Type: text/x-patch
Size: 1194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200903/aa59fb77/attachment.bin>

More information about the lldb-commits mailing list