Mangle anonymous structs/unions correctly. Fixes PR5139.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83448 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h
index 8ab5d5e..f05220c 100644
--- a/lib/CodeGen/Mangle.h
+++ b/lib/CodeGen/Mangle.h
@@ -20,6 +20,7 @@
 
 #include "CGCXX.h"
 #include "clang/AST/Type.h"
+#include "llvm/ADT/DenseMap.h"
 
 namespace llvm {
   class raw_ostream;
@@ -35,11 +36,21 @@
 
   class MangleContext {
     ASTContext &Context;
+    
+    llvm::DenseMap<const TagDecl *, uint64_t> AnonStructIds;
+
   public:
     explicit MangleContext(ASTContext &Context)
     : Context(Context) { }
     
     ASTContext &getASTContext() const { return Context; }
+    
+    uint64_t getAnonymousStructId(const TagDecl *TD) {
+      std::pair<llvm::DenseMap<const TagDecl *, 
+                               uint64_t>::iterator, bool> Result =
+      AnonStructIds.insert(std::make_pair(TD, AnonStructIds.size()));
+      return Result.first->second;
+    }
   };
 
   bool mangleName(MangleContext &Context, const NamedDecl *D,