Index: source/Commands/CommandObjectExpression.cpp =================================================================== --- source/Commands/CommandObjectExpression.cpp +++ source/Commands/CommandObjectExpression.cpp @@ -296,6 +296,20 @@ options.SetTryAllThreads(m_command_options.try_all_threads); options.SetDebug(m_command_options.debug); + // If the language is unknown, set it to the langage of the + // frame's CU. + if (options.GetLanguage() == lldb::eLanguageTypeUnknown && + exe_ctx.HasFrameScope()) + { + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) + { + CompileUnit *cu = frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit; + if (cu) + options.SetLanguage(cu->GetLanguage()); + } + } + // If there is any chance we are going to stop and want to see // what went wrong with our expression, we should generate debug info if (!m_command_options.ignore_breakpoints || Index: source/Expression/ClangExpressionParser.cpp =================================================================== --- source/Expression/ClangExpressionParser.cpp +++ source/Expression/ClangExpressionParser.cpp @@ -214,6 +214,9 @@ case lldb::eLanguageTypeObjC: m_compiler->getLangOpts().ObjC1 = true; m_compiler->getLangOpts().ObjC2 = true; + // ObjC++ syntax is allowed when debugging ObjC code, so we + // set it here as well. + m_compiler->getLangOpts().CPlusPlus = true; break; case lldb::eLanguageTypeC_plus_plus: m_compiler->getLangOpts().CPlusPlus = true;