diff options
| author | Devang Patel <dpatel@apple.com> | 2010-12-08 20:18:20 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2010-12-08 20:18:20 +0000 |
| commit | 81c3c877170d87931dbaa07b62b33595b468c5c6 (patch) | |
| tree | 0764134038a87d9ec92ca254c80b4ca1d23f3c52 /llvm/lib/Analysis | |
| parent | 9625d08cec707d87fe7332b9e7344f70c2965699 (diff) | |
| download | bcm5719-llvm-81c3c877170d87931dbaa07b62b33595b468c5c6.tar.gz bcm5719-llvm-81c3c877170d87931dbaa07b62b33595b468c5c6.zip | |
Add support to create class type.
llvm-svn: 121279
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/DIBuilder.cpp | 26 | ||||
| -rw-r--r-- | llvm/lib/Analysis/DebugInfo.cpp | 20 |
2 files changed, 46 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DIBuilder.cpp b/llvm/lib/Analysis/DIBuilder.cpp index c9a4229db4a..658b3774af8 100644 --- a/llvm/lib/Analysis/DIBuilder.cpp +++ b/llvm/lib/Analysis/DIBuilder.cpp @@ -236,6 +236,32 @@ DIType DIBuilder::CreateMemberType(StringRef Name, return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); } +/// CreateClassType - Create debugging information entry for a class. +DIType DIBuilder::CreateClassType(DIDescriptor Context, StringRef Name, + DIFile File, unsigned LineNumber, + uint64_t SizeInBits, uint64_t AlignInBits, + uint64_t OffsetInBits, unsigned Flags, + DIType DerivedFrom, DIArray Elements, + MDNode *VTableHoder) { + // TAG_class_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_class_type), + Context, + MDString::get(VMContext, Name), + File, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), OffsetInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + DerivedFrom, + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + VTableHoder + }; + return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + /// CreateStructType - Create debugging information entry for a struct. DIType DIBuilder::CreateStructType(DIDescriptor Context, StringRef Name, DIFile File, unsigned LineNumber, diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index f968d061951..9e802c64b0e 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -288,6 +288,26 @@ void DIType::replaceAllUsesWith(DIDescriptor &D) { } } +/// replaceAllUsesWith - Replace all uses of debug info referenced by +/// this descriptor. +void DIType::replaceAllUsesWith(MDNode *D) { + if (!DbgNode) + return; + + // Since we use a TrackingVH for the node, its easy for clients to manufacture + // legitimate situations where they want to replaceAllUsesWith() on something + // which, due to uniquing, has merged with the source. We shield clients from + // this detail by allowing a value to be replaced with replaceAllUsesWith() + // itself. + if (DbgNode != D) { + MDNode *Node = const_cast<MDNode*>(DbgNode); + const MDNode *DN = D; + const Value *V = cast_or_null<Value>(DN); + Node->replaceAllUsesWith(const_cast<Value*>(V)); + MDNode::deleteTemporary(Node); + } +} + /// Verify - Verify that a compile unit is well formed. bool DICompileUnit::Verify() const { if (!DbgNode) |

