/// through debug info anchors.
void retainType(DIType T);
- /// createUnspecifiedParameter - Create unspecified type descriptor
+ /// createUnspecifiedParameter - Create unspecified parameter type
/// for a subroutine type.
- DIDescriptor createUnspecifiedParameter();
+ DITrivialType createUnspecifiedParameter();
/// getOrCreateArray - Get a DIArray, create one if required.
DIArray getOrCreateArray(ArrayRef<Value *> Elements);
bool isDerivedType() const;
bool isCompositeType() const;
bool isBasicType() const;
+ bool isTrivialType() const;
bool isVariable() const;
bool isSubprogram() const;
bool isGlobalVariable() const;
/// Verify - Verify that a type descriptor is well formed.
bool Verify() const;
- DIScopeRef getContext() const { return getFieldAs<DIScopeRef>(2); }
- StringRef getName() const { return getStringField(3); }
- unsigned getLineNumber() const { return getUnsignedField(4); }
- uint64_t getSizeInBits() const { return getUInt64Field(5); }
- uint64_t getAlignInBits() const { return getUInt64Field(6); }
+ DIScopeRef getContext() const {
+ assert(!isTrivialType() && "no context for DITrivialType");
+ return getFieldAs<DIScopeRef>(2);
+ }
+ StringRef getName() const {
+ assert(!isTrivialType() && "no name for DITrivialType");
+ return getStringField(3);
+ }
+ unsigned getLineNumber() const {
+ assert(!isTrivialType() && "no line number for DITrivialType");
+ return getUnsignedField(4);
+ }
+ uint64_t getSizeInBits() const {
+ assert(!isTrivialType() && "no SizeInBits for DITrivialType");
+ return getUInt64Field(5);
+ }
+ uint64_t getAlignInBits() const {
+ assert(!isTrivialType() && "no AlignInBits for DITrivialType");
+ return getUInt64Field(6);
+ }
// FIXME: Offset is only used for DW_TAG_member nodes. Making every type
// carry this is just plain insane.
- uint64_t getOffsetInBits() const { return getUInt64Field(7); }
- unsigned getFlags() const { return getUnsignedField(8); }
+ uint64_t getOffsetInBits() const {
+ assert(!isTrivialType() && "no OffsetInBits for DITrivialType");
+ return getUInt64Field(7);
+ }
+ unsigned getFlags() const {
+ assert(!isTrivialType() && "no flag for DITrivialType");
+ return getUnsignedField(8);
+ }
bool isPrivate() const { return (getFlags() & FlagPrivate) != 0; }
bool isProtected() const { return (getFlags() & FlagProtected) != 0; }
bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; }
void replaceAllUsesWith(MDNode *D);
};
+class DITrivialType : public DIType {
+public:
+ explicit DITrivialType(const MDNode *N = nullptr) : DIType(N) {}
+ bool Verify() const;
+};
+
/// DIBasicType - A basic type, like 'int' or 'float'.
class DIBasicType : public DIType {
public:
bool Verify() const;
};
-/// DIUnspecifiedParameter - This is a wrapper for unspecified parameters.
-class DIUnspecifiedParameter : public DIDescriptor {
-public:
- explicit DIUnspecifiedParameter(const MDNode *N = nullptr)
- : DIDescriptor(N) {}
- bool Verify() const;
-};
-
/// DITemplateTypeParameter - This is a wrapper for template type parameter.
class DITemplateTypeParameter : public DIDescriptor {
public:
/// createUnspecifiedParameter - Create unspeicified type descriptor
/// for the subroutine type.
-DIDescriptor DIBuilder::createUnspecifiedParameter() {
+DITrivialType DIBuilder::createUnspecifiedParameter() {
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters)
};
- return DIDescriptor(MDNode::get(VMContext, Elts));
+ return DITrivialType(MDNode::get(VMContext, Elts));
}
/// createForwardDecl - Create a temporary forward-declared type that
return DbgNode &&
(DIDerivedType(DbgNode).Verify() ||
DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() ||
+ DITrivialType(DbgNode).Verify() ||
DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() ||
DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() ||
DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() ||
DILexicalBlockFile(DbgNode).Verify() ||
DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() ||
DIObjCProperty(DbgNode).Verify() ||
- DIUnspecifiedParameter(DbgNode).Verify() ||
DITemplateTypeParameter(DbgNode).Verify() ||
DITemplateValueParameter(DbgNode).Verify() ||
DIImportedEntity(DbgNode).Verify());
// Predicates
//===----------------------------------------------------------------------===//
+bool DIDescriptor::isTrivialType() const {
+ return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters;
+}
+
/// isBasicType - Return true if the specified tag is legal for
/// DIBasicType.
bool DIDescriptor::isBasicType() const {
/// isType - Return true if the specified tag is legal for DIType.
bool DIDescriptor::isType() const {
- return isBasicType() || isCompositeType() || isDerivedType();
+ return isBasicType() || isCompositeType() || isDerivedType() ||
+ isTrivialType();
}
/// isSubprogram - Return true if the specified tag is legal for
// FIXME: Sink this into the various subclass verifies.
uint16_t Tag = getTag();
- if (!isBasicType() && Tag != dwarf::DW_TAG_const_type &&
+ if (!isBasicType() && !isTrivialType() && Tag != dwarf::DW_TAG_const_type &&
Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type &&
Tag != dwarf::DW_TAG_ptr_to_member_type &&
Tag != dwarf::DW_TAG_reference_type &&
// a CompositeType.
if (isBasicType())
return DIBasicType(DbgNode).Verify();
+ else if (isTrivialType())
+ return DITrivialType(DbgNode).Verify();
else if (isCompositeType())
return DICompositeType(DbgNode).Verify();
else if (isDerivedType())
return isBasicType() && DbgNode->getNumOperands() == 10;
}
+bool DITrivialType::Verify() const {
+ return isTrivialType() && DbgNode->getNumOperands() == 1;
+}
+
/// Verify - Verify that a derived type descriptor is well formed.
bool DIDerivedType::Verify() const {
// Make sure DerivedFrom @ field 9 is TypeRef.
return isLexicalBlockFile() && DbgNode->getNumOperands() == 3;
}
-/// \brief Verify that an unspecified parameter descriptor is well formed.
-bool DIUnspecifiedParameter::Verify() const {
- return isUnspecifiedParameter() && DbgNode->getNumOperands() == 1;
-}
-
/// \brief Verify that the template type parameter descriptor is well formed.
bool DITemplateTypeParameter::Verify() const {
return isTemplateTypeParameter() && DbgNode->getNumOperands() == 7;
}
void DIType::printInternal(raw_ostream &OS) const {
- if (!DbgNode)
+ if (!DbgNode || isTrivialType())
return;
StringRef Res = getName();