Added the ability for clients to grab a set of symbol table indexes and then
add them to a fast lookup map. lldb_private::Symtab now export the following
public typedefs:

namespace lldb_private {

	class Symtab {
		typedef std::vector<uint32_t> IndexCollection;
		typedef UniqueCStringMap<uint32_t> NameToIndexMap;
	};
}

Clients can then find symbols by name and or type and end up with a 
Symtab::IndexCollection that is filled with indexes. These indexes can then
be put into a name to index lookup map and control if the mangled and 
demangled names get added to the map:

bool add_demangled = true;
bool add_mangled = true;
Symtab::NameToIndexMap name_to_index;
symtab->AppendSymbolNamesToMap (indexes, add_demangled, add_mangled, name_to_index).

This can be repeated as many times as needed to get a lookup table that
you are happy with, and then this can be sorted:

name_to_index.Sort();

Now name lookups can be done using a subset of the symbols you extracted from
the symbol table. This is currently being used to extract objective C types
from object files when there is no debug info in SymbolFileSymtab.

Cleaned up how the objective C types were being vended to be more efficient
and fixed some errors in the regular expression that was being used.

llvm-svn: 145777
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 9ce0df9..bd3b17c 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -262,9 +262,6 @@
         Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
         // Create the name index vector to be able to quickly search by name
         const size_t count = m_symbols.size();
-        assert(m_objfile != NULL);
-        assert(m_objfile->GetModule() != NULL);
-
 #if 1
         m_name_to_index.Reserve (count);
 #else
@@ -287,7 +284,7 @@
         m_name_to_index.Reserve (actual_count);
 #endif
 
-        UniqueCStringMap<uint32_t>::Entry entry;
+        NameToIndexMap::Entry entry;
 
         for (entry.value = 0; entry.value < count; ++entry.value)
         {
@@ -328,6 +325,44 @@
     }
 }
 
+void
+Symtab::AppendSymbolNamesToMap (const IndexCollection &indexes, 
+                                bool add_demangled,
+                                bool add_mangled,
+                                NameToIndexMap &name_to_index_map) const
+{
+    if (add_demangled || add_mangled)
+    {
+        Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
+        Mutex::Locker locker (m_mutex);
+
+        // Create the name index vector to be able to quickly search by name
+        NameToIndexMap::Entry entry;
+        const size_t num_indexes = indexes.size();
+        for (size_t i=0; i<num_indexes; ++i)
+        {
+            entry.value = indexes[i];
+            assert (i < m_symbols.size());
+            const Symbol *symbol = &m_symbols[entry.value];
+
+            const Mangled &mangled = symbol->GetMangled();
+            if (add_demangled)
+            {
+                entry.cstring = mangled.GetDemangledName().GetCString();
+                if (entry.cstring && entry.cstring[0])
+                    name_to_index_map.Append (entry);
+            }
+                
+            if (add_mangled)
+            {
+                entry.cstring = mangled.GetMangledName().GetCString();
+                if (entry.cstring && entry.cstring[0])
+                    name_to_index_map.Append (entry);
+            }
+        }
+    }
+}
+
 uint32_t
 Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
 {