Change CodeGenModule to rely on the Module's symbol table instead of
shadowing it in the GlobalDeclMap.  Eliminates the string-uniquing
requirement for mangled names, which should help C++ codegen times a little.
Forces us to do string lookups instead of pointer lookups, which might hurt
codegen times a little across the board.  We'll see how it plays out.

Removing the string-uniquing requirement implicitly fixes any bugs like
PR6635 which arose from the fact that we had multiple uniquing tables for
different kinds of identifiers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99012 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h
index 97f94b6..62656b9 100644
--- a/lib/CodeGen/Mangle.h
+++ b/lib/CodeGen/Mangle.h
@@ -21,10 +21,8 @@
 #include "CGCXX.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/DenseMap.h"
-
-namespace llvm {
-  template<typename T> class SmallVectorImpl;
-}
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
 
 namespace clang {
   class ASTContext;
@@ -37,6 +35,33 @@
 namespace CodeGen {
   class CovariantThunkAdjustment;
   class ThunkAdjustment;
+
+/// MangleBuffer - a convenient class for storing a name which is
+/// either the result of a mangling or is a constant string with
+/// external memory ownership.
+class MangleBuffer {
+public:
+  void setString(llvm::StringRef Ref) {
+    String = Ref;
+  }
+
+  llvm::SmallVectorImpl<char> &getBuffer() {
+    return Buffer;
+  }
+
+  llvm::StringRef getString() const {
+    if (!String.empty()) return String;
+    return Buffer.str();
+  }
+
+  operator llvm::StringRef() const {
+    return getString();
+  }
+
+private:
+  llvm::StringRef String;
+  llvm::SmallString<256> Buffer;
+};
    
 /// MangleContext - Context for tracking state which persists across multiple
 /// calls to the C++ name mangler.