[cfe-commits] r94991 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h
Devang Patel
dpatel at apple.com
Mon Feb 1 11:16:33 PST 2010
Author: dpatel
Date: Mon Feb 1 13:16:32 2010
New Revision: 94991
URL: http://llvm.org/viewvc/llvm-project?rev=94991&view=rev
Log:
Emit debug info for namespaces.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=94991&r1=94990&r2=94991&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Feb 1 13:16:32 2010
@@ -57,6 +57,8 @@
I = RegionMap.find(Parent);
if (I != RegionMap.end())
return llvm::DIDescriptor(dyn_cast_or_null<llvm::MDNode>(I->second));
+ if (const NamespaceDecl *NSDecl = dyn_cast<NamespaceDecl>(Parent))
+ return llvm::DIDescriptor(getOrCreateNameSpace(NSDecl, CompileUnit));
}
return CompileUnit;
}
@@ -1802,3 +1804,26 @@
Var->hasInternalLinkage(),
true/*definition*/, Var);
}
+
+/// getOrCreateNamesSpace - Return namespace descriptor for the given
+/// namespace decl.
+llvm::DINameSpace
+CGDebugInfo::getOrCreateNameSpace(const NamespaceDecl *NSDecl,
+ llvm::DIDescriptor Unit) {
+ llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH>::iterator I =
+ NameSpaceCache.find(NSDecl);
+ if (I != NameSpaceCache.end())
+ return llvm::DINameSpace(cast<llvm::MDNode>(I->second));
+
+ SourceManager &SM = CGM.getContext().getSourceManager();
+ PresumedLoc PLoc = SM.getPresumedLoc(NSDecl->getLocation());
+ unsigned LineNo = PLoc.isInvalid() ? 0 : PLoc.getLine();
+
+ llvm::DIDescriptor Context =
+ getContextDescriptor(NSDecl, Unit);
+ llvm::DINameSpace NS =
+ DebugFactory.CreateNameSpace(Context, NSDecl->getName(),
+ llvm::DICompileUnit(Unit.getNode()), LineNo);
+ NameSpaceCache[NSDecl] = llvm::WeakVH(NS.getNode());
+ return NS;
+}
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=94991&r1=94990&r2=94991&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Feb 1 13:16:32 2010
@@ -68,6 +68,7 @@
llvm::BumpPtrAllocator DebugInfoNames;
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;
+ llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;
/// Helper functions for getOrCreateType.
llvm::DIType CreateType(const BuiltinType *Ty, llvm::DICompileUnit U);
@@ -89,7 +90,9 @@
llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DICompileUnit Unit);
llvm::DIType getOrCreateVTablePtrType(llvm::DICompileUnit Unit);
-
+ llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N,
+ llvm::DIDescriptor Unit);
+
llvm::DIType CreatePointerLikeType(unsigned Tag,
const Type *Ty, QualType PointeeTy,
llvm::DICompileUnit U);
More information about the cfe-commits
mailing list