[cfe-commits] r128893 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h
Devang Patel
dpatel at apple.com
Tue Apr 5 10:30:54 PDT 2011
Author: dpatel
Date: Tue Apr 5 12:30:54 2011
New Revision: 128893
URL: http://llvm.org/viewvc/llvm-project?rev=128893&view=rev
Log:
Refactor.
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=128893&r1=128892&r2=128893&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr 5 12:30:54 2011
@@ -835,6 +835,32 @@
}
}
+/// CollectCXXTemplateParams - A helper function to collect debug info for
+/// template parameters.
+llvm::DIArray CGDebugInfo::
+CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TSpecial,
+ llvm::DIFile Unit) {
+ llvm::SmallVector<llvm::Value *, 16> TemplateParams;
+ const TemplateArgumentList &TAL = TSpecial->getTemplateArgs();
+ for (unsigned i = 0, e = TAL.size(); i != e; ++i) {
+ const TemplateArgument &TA = TAL[i];
+ if (TA.getKind() == TemplateArgument::Type) {
+ llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit);
+ llvm::DITemplateTypeParameter TTP =
+ DBuilder.createTemplateTypeParameter(TheCU, TTy.getName(), TTy);
+ TemplateParams.push_back(TTP);
+ } else if (TA.getKind() == TemplateArgument::Integral) {
+ llvm::DIType TTy = getOrCreateType(TA.getIntegralType(), Unit);
+ // FIXME: Get parameter name, instead of parameter type name.
+ llvm::DITemplateValueParameter TVP =
+ DBuilder.createTemplateValueParameter(TheCU, TTy.getName(), TTy,
+ TA.getAsIntegral()->getZExtValue());
+ TemplateParams.push_back(TVP);
+ }
+ }
+ return DBuilder.getOrCreateArray(TemplateParams.data(), TemplateParams.size());
+}
+
/// getOrCreateVTablePtrType - Return debug info descriptor for vtable.
llvm::DIType CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile Unit) {
if (VTablePtrType.isValid())
@@ -971,30 +997,13 @@
}
CollectRecordFields(RD, Unit, EltTys);
- llvm::SmallVector<llvm::Value *, 16> TemplateParams;
+ llvm::DIArray TParamsArray;
if (CXXDecl) {
CollectCXXMemberFunctions(CXXDecl, Unit, EltTys, FwdDecl);
CollectCXXFriends(CXXDecl, Unit, EltTys, FwdDecl);
- if (ClassTemplateSpecializationDecl *TSpecial
- = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
- const TemplateArgumentList &TAL = TSpecial->getTemplateArgs();
- for (unsigned i = 0, e = TAL.size(); i != e; ++i) {
- const TemplateArgument &TA = TAL[i];
- if (TA.getKind() == TemplateArgument::Type) {
- llvm::DIType TTy = getOrCreateType(TA.getAsType(), Unit);
- llvm::DITemplateTypeParameter TTP =
- DBuilder.createTemplateTypeParameter(TheCU, TTy.getName(), TTy);
- TemplateParams.push_back(TTP);
- } else if (TA.getKind() == TemplateArgument::Integral) {
- llvm::DIType TTy = getOrCreateType(TA.getIntegralType(), Unit);
- // FIXME: Get parameter name, instead of parameter type name.
- llvm::DITemplateValueParameter TVP =
- DBuilder.createTemplateValueParameter(TheCU, TTy.getName(), TTy,
- TA.getAsIntegral()->getZExtValue());
- TemplateParams.push_back(TVP);
- }
- }
- }
+ if (const ClassTemplateSpecializationDecl *TSpecial
+ = dyn_cast<ClassTemplateSpecializationDecl>(RD))
+ TParamsArray = CollectCXXTemplateParams(TSpecial, Unit);
}
RegionStack.pop_back();
@@ -1035,8 +1044,7 @@
}
else if (CXXDecl->isDynamicClass())
ContainingType = FwdDecl;
- llvm::DIArray TParamsArray =
- DBuilder.getOrCreateArray(TemplateParams.data(), TemplateParams.size());
+
RealDecl = DBuilder.createClassType(RDContext, RDName, DefUnit, Line,
Size, Align, 0, 0, llvm::DIType(),
Elements, ContainingType,
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=128893&r1=128892&r2=128893&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Apr 5 12:30:54 2011
@@ -32,6 +32,7 @@
namespace clang {
class VarDecl;
class ObjCInterfaceDecl;
+ class ClassTemplateSpecializationDecl;
namespace CodeGen {
class CodeGenModule;
@@ -123,6 +124,10 @@
llvm::SmallVectorImpl<llvm::Value *> &EltTys,
llvm::DIType RecordTy);
+ llvm::DIArray
+ CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS,
+ llvm::DIFile F);
+
llvm::DIType createFieldType(llvm::StringRef name, QualType type,
Expr *bitWidth, SourceLocation loc,
AccessSpecifier AS, uint64_t offsetInBits,
More information about the cfe-commits
mailing list