Add support for mangling guard variables.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68969 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index dac9a7c..049353f 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -34,6 +34,7 @@
       : Context(C), Out(os) { }
 
     bool mangle(const NamedDecl *D);
+    void mangleGuardVariable(const VarDecl *D);
     
   private:
     bool mangleFunctionDecl(const FunctionDecl *FD);
@@ -124,6 +125,15 @@
   return false;
 }
 
+void CXXNameMangler::mangleGuardVariable(const VarDecl *D)
+{
+  //  <special-name> ::= GV <object name>	# Guard variable for one-time 
+  //                                      # initialization
+
+  Out << "_ZGV";
+  mangleName(D);
+}
+
 void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
   // <encoding> ::= <function name> <bare-function-type>
   mangleName(FD);
@@ -586,5 +596,14 @@
     os.flush();
     return true;
   }
+  
+  /// mangleGuardVariable - Mangles the m
+  void mangleGuardVariable(const VarDecl *D, ASTContext &Context,
+                           llvm::raw_ostream &os) {
+    CXXNameMangler Mangler(Context, os);
+    Mangler.mangleGuardVariable(D);
+
+    os.flush();
+  }
 }
 
diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h
index 627c16a..b3f88b0 100644
--- a/lib/CodeGen/Mangle.h
+++ b/lib/CodeGen/Mangle.h
@@ -25,9 +25,12 @@
 namespace clang {
   class ASTContext;
   class NamedDecl;
-
+  class VarDecl;
+  
   bool mangleName(const NamedDecl *D, ASTContext &Context, 
                   llvm::raw_ostream &os);
+  void mangleGuardVariable(const VarDecl *D, ASTContext &Context,
+                           llvm::raw_ostream &os);
 }
 
 #endif