[Lldb-commits] [lldb] bf8f6e8 - [lldb/Interpreter] Fix language detection for the REPL InitFile

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 3 02:00:29 PDT 2020


Author: Med Ismail Bennani
Date: 2020-09-03T10:57:56+02:00
New Revision: bf8f6e89c8d6fbac3e91ab37de7431d8e7c8aab4

URL: https://github.com/llvm/llvm-project/commit/bf8f6e89c8d6fbac3e91ab37de7431d8e7c8aab4
DIFF: https://github.com/llvm/llvm-project/commit/bf8f6e89c8d6fbac3e91ab37de7431d8e7c8aab4.diff

LOG: [lldb/Interpreter] Fix language detection for the REPL InitFile

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).

rdar://65836048

Differential Revision: https://reviews.llvm.org/D87076

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

Added: 
    

Modified: 
    lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 8c77227d01f2..1f6746800097 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2091,9 +2091,12 @@ static void GetHomeInitFile(llvm::SmallVectorImpl<char> &init_file,
   FileSystem::Instance().Resolve(init_file);
 }
 
-static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file,
-                                LanguageType language) {
-  if (language == LanguageType::eLanguageTypeUnknown)
+static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file) {
+  LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
+  LanguageType language = eLanguageTypeUnknown;
+  if (auto main_repl_language = repl_languages.GetSingularLanguage())
+    language = *main_repl_language;
+  else
     return;
 
   std::string init_file_name =
@@ -2191,13 +2194,8 @@ void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
 
   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())
     GetHomeInitFile(init_file);


        


More information about the lldb-commits mailing list