Improved support for language types as command
options:

- added help ("help language") listing the
  possible options;

- added the possibility of synonyms for language
  names, in this case "ObjC" for "Objective-C";
  and

- made matching against language names case
  insensitive.

This should improve discoverability.

<rdar://problem/12552359>


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166457 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 8d8520d..a234640 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -742,6 +742,33 @@
 }
 
 static const char *
+LanguageTypeHelpTextCallback ()
+{
+    static char* help_text_ptr = NULL;
+    
+    if (help_text_ptr)
+        return help_text_ptr;
+    
+    StreamString sstr;
+    sstr << "One of the following languages:\n";
+    
+    for (LanguageType l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l)
+    {
+        sstr << "  " << LanguageRuntime::GetNameForLanguageType(l) << "\n";
+    }
+    
+    sstr.Flush();
+    
+    std::string data = sstr.GetString();
+    
+    help_text_ptr = new char[data.length()+1];
+    
+    data.copy(help_text_ptr, data.length());
+    
+    return help_text_ptr;
+}
+
+static const char *
 SummaryStringHelpTextCallback()
 {
     return
@@ -935,7 +962,7 @@
     { eArgTypeFunctionOrSymbol, "function-or-symbol", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a function or symbol." },
     { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, NULL },
     { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { NULL, false }, "An index into a list." },
-    { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { NULL, false }, "A source language name." },
+    { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, NULL },
     { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { NULL, false }, "Line number in a source file." },
     { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
     { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },