this patch addresses several issues with "command script" subcommands:
 a) adds a new --synchronicity (-s) setting for "command script add" that allows the user to decide if scripted commands should run synchronously or asynchronously (which can make a difference in how events are handled)
 b) clears up several error messages
 c) adds a new --allow-reload (-r) setting for "command script import" that allows the user to reload a module even if it has already been imported before
 d) allows filename completion for "command script import" (much like what happens for "target create")
 e) prevents "command script add" from replacing built-in commands with scripted commands
 f) changes AddUserCommand() to take an std::string instead of a const char* (for performance reasons)
plus, it fixes an issue in "type summary add" command handling which caused several test suite errors


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144035 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index b94c409..73a7085 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -516,19 +516,23 @@
 }
 
 bool
-CommandInterpreter::AddUserCommand (const char *name, 
+CommandInterpreter::AddUserCommand (std::string name, 
                                     const lldb::CommandObjectSP &cmd_sp,
                                     bool can_replace)
 {
-    if (name && name[0])
+    if (!name.empty())
     {
-        std::string name_sstr(name);
-        if (!can_replace)
-        {
-            if (m_user_dict.find (name_sstr) != m_user_dict.end())
-                return false;
-        }
-        m_user_dict[name_sstr] = cmd_sp;
+        
+        const char* name_cstr = name.c_str();
+        
+        // do not allow replacement of internal commands
+        if (CommandExists(name_cstr))
+            return false;
+        
+        if (can_replace == false && UserCommandExists(name_cstr))
+            return false;
+
+        m_user_dict[name] = cmd_sp;
         return true;
     }
     return false;