[llvm] r243152 - DI: Remove DIDerivedTypeBase
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Jul 24 13:16:36 PDT 2015
Author: dexonsmith
Date: Fri Jul 24 15:16:36 2015
New Revision: 243152
URL: http://llvm.org/viewvc/llvm-project?rev=243152&view=rev
Log:
DI: Remove DIDerivedTypeBase
Remove an unnecessary (and confusing) common subclass for
`DIDerivedType` and `DICompositeType`. These classes aren't really
related, and even in the old debug info hierarchy, there was a
long-standing FIXME to separate them.
Modified:
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/include/llvm/IR/Metadata.def
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=243152&r1=243151&r2=243152&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Fri Jul 24 15:16:36 2015
@@ -647,45 +647,21 @@ public:
}
};
-/// \brief Base class for DIDerivedType and DICompositeType.
-///
-/// TODO: Delete; they're not really related.
-class DIDerivedTypeBase : public DIType {
-protected:
- DIDerivedTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
- unsigned Tag, unsigned Line, uint64_t SizeInBits,
- uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
- ArrayRef<Metadata *> Ops)
- : DIType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
- Flags, Ops) {}
- ~DIDerivedTypeBase() = default;
-
-public:
- DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
- Metadata *getRawBaseType() const { return getOperand(3); }
-
- static bool classof(const Metadata *MD) {
- return MD->getMetadataID() == DIDerivedTypeKind ||
- MD->getMetadataID() == DICompositeTypeKind ||
- MD->getMetadataID() == DISubroutineTypeKind;
- }
-};
-
/// \brief Derived types.
///
/// This includes qualified types, pointers, references, friends, typedefs, and
/// class members.
///
/// TODO: Split out members (inheritance, fields, methods, etc.).
-class DIDerivedType : public DIDerivedTypeBase {
+class DIDerivedType : public DIType {
friend class LLVMContextImpl;
friend class MDNode;
DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
- : DIDerivedTypeBase(C, DIDerivedTypeKind, Storage, Tag, Line, SizeInBits,
- AlignInBits, OffsetInBits, Flags, Ops) {}
+ : DIType(C, DIDerivedTypeKind, Storage, Tag, Line, SizeInBits,
+ AlignInBits, OffsetInBits, Flags, Ops) {}
~DIDerivedType() = default;
static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
@@ -733,6 +709,10 @@ public:
TempDIDerivedType clone() const { return cloneImpl(); }
+ //// Get the base type this is derived from.
+ DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
+ Metadata *getRawBaseType() const { return getOperand(3); }
+
/// \brief Get extra data associated with this derived type.
///
/// Class type for pointer-to-members, objective-c property node for ivars,
@@ -768,7 +748,7 @@ public:
/// \brief Base class for DICompositeType and DISubroutineType.
///
/// TODO: Delete; they're not really related.
-class DICompositeTypeBase : public DIDerivedTypeBase {
+class DICompositeTypeBase : public DIType {
unsigned RuntimeLang;
protected:
@@ -777,12 +757,15 @@ protected:
uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags,
ArrayRef<Metadata *> Ops)
- : DIDerivedTypeBase(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits,
- OffsetInBits, Flags, Ops),
+ : DIType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
+ Flags, Ops),
RuntimeLang(RuntimeLang) {}
~DICompositeTypeBase() = default;
public:
+ //// Get the base type this is derived from, if any.
+ DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
+
/// \brief Get the elements of the composite type.
///
/// \note Calling this is only valid for \a DICompositeType. This assertion
@@ -799,6 +782,7 @@ public:
StringRef getIdentifier() const { return getStringOperand(7); }
unsigned getRuntimeLang() const { return RuntimeLang; }
+ Metadata *getRawBaseType() const { return getOperand(3); }
Metadata *getRawElements() const { return getOperand(4); }
Metadata *getRawVTableHolder() const { return getOperand(5); }
Metadata *getRawTemplateParams() const { return getOperand(6); }
Modified: llvm/trunk/include/llvm/IR/Metadata.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.def?rev=243152&r1=243151&r2=243152&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.def (original)
+++ llvm/trunk/include/llvm/IR/Metadata.def Fri Jul 24 15:16:36 2015
@@ -69,7 +69,6 @@ HANDLE_SPECIALIZED_MDNODE_LEAF(DIEnumera
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIScope)
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIType)
HANDLE_SPECIALIZED_MDNODE_LEAF(DIBasicType)
-HANDLE_SPECIALIZED_MDNODE_BRANCH(DIDerivedTypeBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(DIDerivedType)
HANDLE_SPECIALIZED_MDNODE_BRANCH(DICompositeTypeBase)
HANDLE_SPECIALIZED_MDNODE_LEAF(DICompositeType)
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=243152&r1=243151&r2=243152&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri Jul 24 15:16:36 2015
@@ -302,7 +302,6 @@ private:
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N);
#include "llvm/IR/Metadata.def"
void visitDIScope(const DIScope &N);
- void visitDIDerivedTypeBase(const DIDerivedTypeBase &N);
void visitDIVariable(const DIVariable &N);
void visitDILexicalBlockBase(const DILexicalBlockBase &N);
void visitDITemplateParameter(const DITemplateParameter &N);
@@ -779,19 +778,10 @@ void Verifier::visitDIBasicType(const DI
"invalid tag", &N);
}
-void Verifier::visitDIDerivedTypeBase(const DIDerivedTypeBase &N) {
+void Verifier::visitDIDerivedType(const DIDerivedType &N) {
// Common scope checks.
visitDIScope(N);
- Assert(isScopeRef(N, N.getScope()), "invalid scope", &N, N.getScope());
- Assert(isTypeRef(N, N.getBaseType()), "invalid base type", &N,
- N.getBaseType());
-}
-
-void Verifier::visitDIDerivedType(const DIDerivedType &N) {
- // Common derived type checks.
- visitDIDerivedTypeBase(N);
-
Assert(N.getTag() == dwarf::DW_TAG_typedef ||
N.getTag() == dwarf::DW_TAG_pointer_type ||
N.getTag() == dwarf::DW_TAG_ptr_to_member_type ||
@@ -808,6 +798,10 @@ void Verifier::visitDIDerivedType(const
Assert(isTypeRef(N, N.getExtraData()), "invalid pointer to member type", &N,
N.getExtraData());
}
+
+ Assert(isScopeRef(N, N.getScope()), "invalid scope", &N, N.getScope());
+ Assert(isTypeRef(N, N.getBaseType()), "invalid base type", &N,
+ N.getBaseType());
}
static bool hasConflictingReferenceFlags(unsigned Flags) {
@@ -825,8 +819,8 @@ void Verifier::visitTemplateParams(const
}
void Verifier::visitDICompositeType(const DICompositeType &N) {
- // Common derived type checks.
- visitDIDerivedTypeBase(N);
+ // Common scope checks.
+ visitDIScope(N);
Assert(N.getTag() == dwarf::DW_TAG_array_type ||
N.getTag() == dwarf::DW_TAG_structure_type ||
@@ -835,6 +829,10 @@ void Verifier::visitDICompositeType(cons
N.getTag() == dwarf::DW_TAG_class_type,
"invalid tag", &N);
+ Assert(isScopeRef(N, N.getScope()), "invalid scope", &N, N.getScope());
+ Assert(isTypeRef(N, N.getBaseType()), "invalid base type", &N,
+ N.getBaseType());
+
Assert(!N.getRawElements() || isa<MDTuple>(N.getRawElements()),
"invalid composite elements", &N, N.getRawElements());
Assert(isTypeRef(N, N.getRawVTableHolder()), "invalid vtable holder", &N,
More information about the llvm-commits
mailing list