diff options
author | Devang Patel <dpatel@apple.com> | 2010-10-22 17:11:50 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-10-22 17:11:50 +0000 |
commit | 58faf20b459f33c33f752d6d9ee910e59e0ea1bb (patch) | |
tree | 2ea74a10a2413cdc5e37271441ec86cf2fc7a461 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 79ba2a6379f87fa137377c3f55ff993b9e5cc144 (diff) |
Tidy up MIPS_linkage name. Provide it only if it does not match regular name, otherwise it confuses debugger.
This is tested by local.C in llvmgcc testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index e8c1ae754d..88e3e0fd7d 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -691,6 +691,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, llvm::DIType(), EltTypeArray); } +/// isFunctionLocalClass - Return true if CXXRecordDecl is defined +/// inside a function. +static bool isFunctionLocalClass(const CXXRecordDecl *RD) { + if (const CXXRecordDecl *NRD = + dyn_cast<CXXRecordDecl>(RD->getDeclContext())) + return isFunctionLocalClass(NRD); + else if (isa<FunctionDecl>(RD->getDeclContext())) + return true; + return false; + +} /// CreateCXXMemberFunction - A helper function to create a DISubprogram for /// a single member function GlobalDecl. llvm::DISubprogram @@ -706,7 +717,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, // Since a single ctor/dtor corresponds to multiple functions, it doesn't // make sense to give a single ctor/dtor a linkage name. llvm::StringRef MethodLinkageName; - if (!IsCtorOrDtor) + if (!IsCtorOrDtor && !isFunctionLocalClass(Method->getParent())) MethodLinkageName = CGM.getMangledName(Method); // Get the location for the method. @@ -755,7 +766,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, MethodLinkageName, MethodDefUnit, MethodLine, MethodTy, /*isLocalToUnit=*/false, - /* isDefintion=*/ false, + Method->hasInlineBody(), Virtuality, VIndex, ContainingType, Flags, CGM.getLangOptions().Optimize); @@ -1558,6 +1569,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, Name = getFunctionName(FD); // Use mangled name as linkage name for c/c++ functions. LinkageName = CGM.getMangledName(GD); + if (LinkageName == Name) + LinkageName = llvm::StringRef(); if (FD->hasPrototype()) Flags |= llvm::DIDescriptor::FlagPrototyped; if (const NamespaceDecl *NSDecl = @@ -1565,12 +1578,10 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, FDContext = getOrCreateNameSpace(NSDecl, Unit); } else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)) { Name = getObjCMethodName(OMD); - LinkageName = Name; Flags |= llvm::DIDescriptor::FlagPrototyped; } else { - // Use llvm function name as linkage name. + // Use llvm function name. Name = Fn->getName(); - LinkageName = Name; Flags |= llvm::DIDescriptor::FlagPrototyped; } if (!Name.empty() && Name[0] == '\01') @@ -1952,6 +1963,8 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, llvm::StringRef LinkageName; if (D->getDeclContext() && !isa<FunctionDecl>(D->getDeclContext())) LinkageName = Var->getName(); + if (LinkageName == DeclName) + LinkageName = llvm::StringRef(); llvm::DIDescriptor DContext = getContextDescriptor(dyn_cast<Decl>(D->getDeclContext()), Unit); DebugFactory.CreateGlobalVariable(DContext, DeclName, DeclName, LinkageName, |