Index: include/lldb/Expression/ClangExpressionParser.h =================================================================== --- include/lldb/Expression/ClangExpressionParser.h +++ include/lldb/Expression/ClangExpressionParser.h @@ -52,6 +52,7 @@ //------------------------------------------------------------------ ClangExpressionParser (ExecutionContextScope *exe_scope, ClangExpression &expr, + Args &expr_parser_compiler_args, bool generate_debug_info); //------------------------------------------------------------------ Index: include/lldb/Target/Target.h =================================================================== --- include/lldb/Target/Target.h +++ include/lldb/Target/Target.h @@ -113,6 +113,12 @@ void SetRunArguments (const Args &args); + + bool + GetExprParserCompilerArguments (Args &args) const; + + void + SetExprParserCompilerArguments (const Args &args); size_t GetEnvironmentAsArgs (Args &env) const; Index: source/Expression/ClangExpressionParser.cpp =================================================================== --- source/Expression/ClangExpressionParser.cpp +++ source/Expression/ClangExpressionParser.cpp @@ -98,6 +98,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, ClangExpression &expr, + Args &expr_parser_compiler_args, bool generate_debug_info) : m_expr (expr), m_compiler (), @@ -152,6 +153,11 @@ // 3. Set options. + clang::CompilerInvocation::CreateFromArgs(m_compiler->getInvocation(), + expr_parser_compiler_args.GetConstArgumentVector(), + expr_parser_compiler_args.GetConstArgumentVector() + expr_parser_compiler_args.GetArgumentCount(), + m_compiler->getDiagnostics()); + lldb::LanguageType language = expr.Language(); switch (language) Index: source/Expression/ClangFunction.cpp =================================================================== --- source/Expression/ClangFunction.cpp +++ source/Expression/ClangFunction.cpp @@ -238,7 +238,9 @@ if (jit_process_sp) { const bool generate_debug_info = true; - m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this, generate_debug_info)); + Args expr_parser_compiler_args; + jit_process_sp->GetTarget().GetExprParserCompilerArguments (expr_parser_compiler_args); + m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this, expr_parser_compiler_args, generate_debug_info)); num_errors = m_parser->Parse (errors); } Index: source/Expression/ClangUserExpression.cpp =================================================================== --- source/Expression/ClangUserExpression.cpp +++ source/Expression/ClangUserExpression.cpp @@ -527,7 +527,9 @@ if (!exe_scope) exe_scope = exe_ctx.GetTargetPtr(); - ClangExpressionParser parser(exe_scope, *this, generate_debug_info); + Args expr_parser_compiler_args; + target->GetExprParserCompilerArguments (expr_parser_compiler_args); + ClangExpressionParser parser(exe_scope, *this, expr_parser_compiler_args, generate_debug_info); unsigned num_errors = parser.Parse (error_stream); Index: source/Expression/ClangUtilityFunction.cpp =================================================================== --- source/Expression/ClangUtilityFunction.cpp +++ source/Expression/ClangUtilityFunction.cpp @@ -122,7 +122,9 @@ } const bool generate_debug_info = true; - ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this, generate_debug_info); + Args expr_parser_compiler_args; + target->GetExprParserCompilerArguments (expr_parser_compiler_args); + ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this, expr_parser_compiler_args, generate_debug_info); unsigned num_errors = parser.Parse (error_stream); Index: source/Interpreter/Args.cpp =================================================================== --- source/Interpreter/Args.cpp +++ source/Interpreter/Args.cpp @@ -650,8 +650,15 @@ while (1) { int long_options_index = -1; - val = OptionParser::Parse(GetArgumentCount(), - GetArgumentVector(), + + // When parsing options, skip arguments with quote chars ['"`]. + // By doing this, we can specify argument starting with - and not mistake it as command option. + arg_cstr_collection actual_options; + for (size_t i = 0; i < GetArgumentCount(); i++) + if (GetArgumentQuoteCharAtIndex(i) == '\0') + actual_options.push_back(GetArgumentAtIndex(i)); + val = OptionParser::Parse(actual_options.size(), + (char**)&actual_options[0], sstr.GetData(), long_options, &long_options_index); Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -2653,6 +2653,7 @@ { "breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean , false, true , NULL, NULL, "Consult the platform module avoid list when setting non-module specific breakpoints." }, { "arg0" , OptionValue::eTypeString , false, 0 , NULL, NULL, "The first argument passed to the program in the argument array which can be different from the executable itself." }, { "run-args" , OptionValue::eTypeArgs , false, 0 , NULL, NULL, "A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0." }, + { "expr-parser-compiler-args" , OptionValue::eTypeArgs , false, 0 , NULL, NULL, "A list containing all the arguments to be passed to the expression parser compiler." }, { "env-vars" , OptionValue::eTypeDictionary, false, OptionValue::eTypeString , NULL, NULL, "A list of all the environment variables to be passed to the executable's environment, and their values." }, { "inherit-env" , OptionValue::eTypeBoolean , false, true , NULL, NULL, "Inherit the environment from the process that is running LLDB." }, { "input-path" , OptionValue::eTypeFileSpec , false, 0 , NULL, NULL, "The file/path to be used by the executable program for reading its standard input." }, @@ -2701,6 +2702,7 @@ ePropertyBreakpointUseAvoidList, ePropertyArg0, ePropertyRunArgs, + ePropertyExprParserCompilerArgs, ePropertyEnvVars, ePropertyInheritEnv, ePropertyInputPath, @@ -2957,6 +2959,20 @@ } void +TargetProperties::SetExprParserCompilerArguments (const Args &args) +{ + const uint32_t idx = ePropertyExprParserCompilerArgs; + m_collection_sp->SetPropertyAtIndexFromArgs (NULL, idx, args); +} + +bool +TargetProperties::GetExprParserCompilerArguments (Args &args) const +{ + const uint32_t idx = ePropertyExprParserCompilerArgs; + return m_collection_sp->GetPropertyAtIndexAsArgs (NULL, idx, args); +} + +void TargetProperties::SetRunArguments (const Args &args) { const uint32_t idx = ePropertyRunArgs;