diff options
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r-- | lldb/source/Interpreter/Args.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Interpreter/Options.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 13 |
5 files changed, 19 insertions, 12 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index 95d9530bc46..337d10035b2 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -1138,7 +1138,7 @@ Args::IsPositionalArgument (const char *arg) return false; bool is_positional = true; - char *cptr = (char *) arg; + const char *cptr = arg; if (cptr[0] == '%') { diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index fe477238313..1c3a86fd756 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2247,7 +2247,7 @@ CommandInterpreter::BuildAliasCommandArgs (CommandObject *alias_cmd_obj, } cmd_args.Clear(); - cmd_args.SetArguments (new_args.GetArgumentCount(), (const char **) new_args.GetArgumentVector()); + cmd_args.SetArguments (new_args.GetArgumentCount(), new_args.GetConstArgumentVector()); } else { @@ -2258,7 +2258,7 @@ CommandInterpreter::BuildAliasCommandArgs (CommandObject *alias_cmd_obj, if (wants_raw_input) { cmd_args.Clear(); - cmd_args.SetArguments (new_args.GetArgumentCount(), (const char **) new_args.GetArgumentVector()); + cmd_args.SetArguments (new_args.GetArgumentCount(), new_args.GetConstArgumentVector()); } return; } @@ -2274,7 +2274,7 @@ CommandInterpreter::GetOptionArgumentPosition (const char *in_string) int position = 0; // Any string that isn't an argument position, i.e. '%' followed by an integer, gets a position // of zero. - char *cptr = (char *) in_string; + const char *cptr = in_string; // Does it start with '%' if (cptr[0] == '%') diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 494a008892b..f6e5bcac3a4 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -506,14 +506,14 @@ CommandObject::GetArgumentEntryAtIndex (int idx) return nullptr; } -CommandObject::ArgumentTableEntry * +const CommandObject::ArgumentTableEntry * CommandObject::FindArgumentDataByType (CommandArgumentType arg_type) { const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); for (int i = 0; i < eArgTypeLastArg; ++i) if (table[i].arg_type == arg_type) - return (ArgumentTableEntry *) &(table[i]); + return &(table[i]); return nullptr; } @@ -522,7 +522,7 @@ void CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter) { const ArgumentTableEntry* table = CommandObject::GetArgumentTable(); - ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]); + const ArgumentTableEntry *entry = &(table[arg_type]); // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... @@ -556,7 +556,7 @@ CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, Comma const char * CommandObject::GetArgumentName (CommandArgumentType arg_type) { - ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]); + const ArgumentTableEntry *entry = &(CommandObject::GetArgumentTable()[arg_type]); // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index a8766f5f861..50db6117108 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -944,7 +944,7 @@ Options::HandleOptionArgumentCompletion lldb::CommandArgumentType option_arg_type = opt_defs[opt_defs_index].argument_type; if (option_arg_type != eArgTypeNone) { - CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type); + const CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type); if (arg_entry) completion_mask = arg_entry->completion_type; } diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 7ecef310b5c..1baf484cc79 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -382,6 +382,13 @@ ScriptInterpreterPython::LeaveSession () m_session_is_active = false; } +static PyObject * +PyFile_FromFile_Const(FILE *fp, const char *name, const char *mode, int (*close)(FILE *)) +{ + // Read through the Python source, doesn't seem to modify these strings + return PyFile_FromFile(fp, const_cast<char*>(name), const_cast<char*>(mode), close); +} + bool ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, FILE *in, @@ -447,7 +454,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, { m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin")); // This call can deadlock your process if the file is locked - PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", nullptr); + PyObject *new_file = PyFile_FromFile_Const (in, "", "r", nullptr); sys_module_dict.SetItemForKey ("stdin", new_file); Py_DECREF (new_file); } @@ -459,7 +466,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, { m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout")); - PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", nullptr); + PyObject *new_file = PyFile_FromFile_Const (out, "", "w", nullptr); sys_module_dict.SetItemForKey ("stdout", new_file); Py_DECREF (new_file); } @@ -472,7 +479,7 @@ ScriptInterpreterPython::EnterSession (uint16_t on_entry_flags, { m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr")); - PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", nullptr); + PyObject *new_file = PyFile_FromFile_Const (err, "", "w", nullptr); sys_module_dict.SetItemForKey ("stderr", new_file); Py_DECREF (new_file); } |