From 1c5ad713e7b86e90105dfac6c7726c167c7a58cd Mon Sep 17 00:00:00 2001
From: Dinesh Dwivedi <dinesh.d@samsung.com>
Date: Wed, 21 Aug 2013 10:07:47 +0530
Subject: [PATCH] PR14569_Fix

---
 lib/CodeGen/CGDebugInfo.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 472d35a..1b75203 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -2448,8 +2448,21 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
   llvm::DIDescriptor FDContext(Unit);
   llvm::DIArray TParamsArray;
   if (!HasDecl) {
+    // Fix for PR14569
+    // For clang generated functions, some names are mangled. If we use them
+    // for name attribute, gdb will not de-mangle them while printing.
+    // There are two solution to this problem,
+    //   1. We can avoid setting Name/ LinkageName value.
+    //   2. Set LinkageName too with Name, gdb de-mangles LinkageName and use
+    //      it for printing.
+
+    // First approach causes 2 CodeGenCXX clang test failures, expeting mangled
+    // names in metadata. [debug-info-global-ctor-dtor.cpp and debug-info-thunk.cpp] 
+    
     // Use llvm function name.
     Name = Fn->getName();
+    if (DebugKind == CodeGenOptions::FullDebugInfo)
+      LinkageName = Name;
   } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     // If there is a DISubprogram for this function available then use it.
     llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
-- 
1.8.3.GIT

