[Lldb-commits] [PATCH] D17719: Track expression language from one place in ClangExpressionParser

Luke Drummond via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 21 11:50:25 PST 2016


ldrumm added a subscriber: LLDB.
ldrumm removed rL LLVM as the repository for this revision.
ldrumm updated this revision to Diff 82251.
ldrumm added a comment.

This patch was committed back in March https://reviews.llvm.org/rL263099 and then reverted 2 hours later in https://reviews.llvm.org/rL263107 due to a  testing failure on greendragon related to ObjC. Unfortunately, I no longer have access to Apple hardware (and at the time the testsuite passed on my local mac), so I'm unable to find out exactly what went wrong.

This patch is still needed for RenderScript to handle JIT expressions correctly, so I'd really appreciate it if someone more familiar with OS X would be able to take a look at this, and point out what I'm doing wrong that causes the Objective C tests to blow up.

Any help is - as always - very-much appreciated!


https://reviews.llvm.org/D17719

Files:
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -158,8 +158,10 @@
 
   class LLDBPreprocessorCallbacks;
   LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor
-                                             ///encounters module imports
+                                             /// encounters module imports
   std::unique_ptr<ClangASTContext> m_ast_context;
+  lldb::LanguageType m_language; ///< The source language of the expression
+                                 /// which may be explicitly set or inferred.
 };
 }
 
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -253,8 +253,7 @@
 
   // 1. Create a new compiler instance.
   m_compiler.reset(new CompilerInstance());
-  lldb::LanguageType frame_lang =
-      expr.Language(); // defaults to lldb::eLanguageTypeUnknown
+  m_language = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
   bool overridden_target_opts = false;
   lldb_private::LanguageRuntime *lang_rt = nullptr;
 
@@ -272,14 +271,14 @@
 
   // Make sure the user hasn't provided a preferred execution language
   // with `expression --language X -- ...`
-  if (frame_sp && frame_lang == lldb::eLanguageTypeUnknown)
-    frame_lang = frame_sp->GetLanguage();
+  if (frame_sp && m_language == lldb::eLanguageTypeUnknown)
+    m_language = frame_sp->GetLanguage();
 
-  if (process_sp && frame_lang != lldb::eLanguageTypeUnknown) {
-    lang_rt = process_sp->GetLanguageRuntime(frame_lang);
+  if (process_sp && m_language != lldb::eLanguageTypeUnknown) {
+    lang_rt = process_sp->GetLanguageRuntime(m_language);
     if (log)
       log->Printf("Frame has language of type %s",
-                  Language::GetNameForLanguageType(frame_lang));
+                  Language::GetNameForLanguageType(m_language));
   }
 
   // 2. Configure the compiler with a set of default options that are
@@ -372,9 +371,7 @@
   assert(m_compiler->hasTarget());
 
   // 5. Set language options.
-  lldb::LanguageType language = expr.Language();
-
-  switch (language) {
+  switch (m_language) {
   case lldb::eLanguageTypeC:
   case lldb::eLanguageTypeC89:
   case lldb::eLanguageTypeC99:
@@ -804,13 +801,12 @@
 
   LLVMUserExpression::IRPasses custom_passes;
   {
-    auto lang = m_expr.Language();
     if (log)
       log->Printf("%s - Currrent expression language is %s\n", __FUNCTION__,
-                  Language::GetNameForLanguageType(lang));
+                  Language::GetNameForLanguageType(m_language));
     lldb::ProcessSP process_sp = exe_ctx.GetProcessSP();
-    if (process_sp && lang != lldb::eLanguageTypeUnknown) {
-      auto runtime = process_sp->GetLanguageRuntime(lang);
+    if (process_sp && m_language != lldb::eLanguageTypeUnknown) {
+      auto runtime = process_sp->GetLanguageRuntime(m_language);
       if (runtime)
         runtime->GetIRPasses(custom_passes);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17719.82251.patch
Type: text/x-patch
Size: 3301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161221/824f0a9d/attachment.bin>


More information about the lldb-commits mailing list