/// dump - print descriptor.
void dump() const;
+
+ bool isDerivedType() const;
+ bool isCompositeType() const;
+ bool isBasicType() const;
+ bool isVariable() const;
+ bool isSubprogram() const;
+ bool isGlobalVariable() const;
};
/// DISubrange - This is used to represent ranges, for array bounds.
DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
public:
- /// isDerivedType - Return true if the specified tag is legal for
- /// DIDerivedType.
- static bool isDerivedType(unsigned TAG);
-
- /// isCompositeType - Return true if the specified tag is legal for
- /// DICompositeType.
- static bool isCompositeType(unsigned TAG);
-
- /// isBasicType - Return true if the specified tag is legal for
- /// DIBasicType.
- static bool isBasicType(unsigned TAG) {
- return TAG == dwarf::DW_TAG_base_type;
- }
/// Verify - Verify that a type descriptor is well formed.
bool Verify() const;
public:
explicit DIDerivedType(MDNode *N = 0)
: DIType(N, true, true) {
- if (DbgNode && !isDerivedType(getTag()))
+ if (DbgNode && !isDerivedType())
DbgNode = 0;
}
public:
explicit DICompositeType(MDNode *N = 0)
: DIDerivedType(N, true, true) {
- if (N && !isCompositeType(getTag()))
+ if (N && !isCompositeType())
DbgNode = 0;
}
explicit DIGlobal(MDNode *N, unsigned RequiredTag)
: DIDescriptor(N, RequiredTag) {}
- /// isSubprogram - Return true if the specified tag is legal for
- /// DISubprogram.
- static bool isSubprogram(unsigned TAG) {
- return TAG == dwarf::DW_TAG_subprogram;
- }
-
- /// isGlobalVariable - Return true if the specified tag is legal for
- /// DIGlobalVariable.
- static bool isGlobalVariable(unsigned TAG) {
- return TAG == dwarf::DW_TAG_variable;
- }
-
public:
virtual ~DIGlobal() {}
public:
explicit DIVariable(MDNode *N = 0)
: DIDescriptor(N) {
- if (DbgNode && !isVariable(getTag()))
+ if (DbgNode && !isVariable())
DbgNode = 0;
}
unsigned getLineNumber() const { return getUnsignedField(4); }
DIType getType() const { return getFieldAs<DIType>(5); }
- /// isVariable - Return true if the specified tag is legal for DIVariable.
- static bool isVariable(unsigned Tag);
/// Verify - Verify that a variable descriptor is well formed.
bool Verify() const;
}
//===----------------------------------------------------------------------===//
-// Simple Descriptor Constructors and other Methods
+// Predicates
//===----------------------------------------------------------------------===//
-// Needed by DIVariable::getType().
-DIType::DIType(MDNode *N) : DIDescriptor(N) {
- if (!N) return;
- unsigned tag = getTag();
- if (tag != dwarf::DW_TAG_base_type && !DIDerivedType::isDerivedType(tag) &&
- !DICompositeType::isCompositeType(tag)) {
- DbgNode = 0;
- }
+/// isBasicType - Return true if the specified tag is legal for
+/// DIBasicType.
+bool DIDescriptor::isBasicType() const {
+ assert (isNull() && "Invalid descriptor!");
+ unsigned Tag = getTag();
+
+ return Tag == dwarf::DW_TAG_base_type;
}
-/// isDerivedType - Return true if the specified tag is legal for
-/// DIDerivedType.
-bool DIType::isDerivedType(unsigned Tag) {
+/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
+bool DIDescriptor::isDerivedType() const {
+ assert (isNull() && "Invalid descriptor!");
+ unsigned Tag = getTag();
+
switch (Tag) {
case dwarf::DW_TAG_typedef:
case dwarf::DW_TAG_pointer_type:
return true;
default:
// CompositeTypes are currently modelled as DerivedTypes.
- return isCompositeType(Tag);
+ return isCompositeType();
}
}
/// isCompositeType - Return true if the specified tag is legal for
/// DICompositeType.
-bool DIType::isCompositeType(unsigned TAG) {
- switch (TAG) {
+bool DIDescriptor::isCompositeType() const {
+ assert (isNull() && "Invalid descriptor!");
+ unsigned Tag = getTag();
+
+ switch (Tag) {
case dwarf::DW_TAG_array_type:
case dwarf::DW_TAG_structure_type:
case dwarf::DW_TAG_union_type:
}
/// isVariable - Return true if the specified tag is legal for DIVariable.
-bool DIVariable::isVariable(unsigned Tag) {
+bool DIDescriptor::isVariable() const {
+ assert (isNull() && "Invalid descriptor!");
+ unsigned Tag = getTag();
+
switch (Tag) {
case dwarf::DW_TAG_auto_variable:
case dwarf::DW_TAG_arg_variable:
}
}
+/// isSubprogram - Return true if the specified tag is legal for
+/// DISubprogram.
+bool DIDescriptor::isSubprogram() const {
+ assert (isNull() && "Invalid descriptor!");
+ unsigned Tag = getTag();
+
+ return Tag == dwarf::DW_TAG_subprogram;
+}
+
+/// isGlobalVariable - Return true if the specified tag is legal for
+/// DIGlobalVariable.
+bool DIDescriptor::isGlobalVariable() const {
+ assert (isNull() && "Invalid descriptor!");
+ unsigned Tag = getTag();
+
+ return Tag == dwarf::DW_TAG_variable;
+}
+
+
+//===----------------------------------------------------------------------===//
+// Simple Descriptor Constructors and other Methods
+//===----------------------------------------------------------------------===//
+
+DIType::DIType(MDNode *N) : DIDescriptor(N) {
+ if (!N) return;
+ if (!isBasicType() && !isDerivedType() && !isCompositeType()) {
+ DbgNode = 0;
+ }
+}
+
unsigned DIArray::getNumElements() const {
assert (DbgNode && "Invalid DIArray");
return DbgNode->getNumElements();
if (isForwardDecl())
errs() << " [fwd] ";
- if (isBasicType(Tag))
+ if (isBasicType())
DIBasicType(DbgNode).dump();
- else if (isDerivedType(Tag))
+ else if (isDerivedType())
DIDerivedType(DbgNode).dump();
- else if (isCompositeType(Tag))
+ else if (isCompositeType())
DICompositeType(DbgNode).dump();
else {
errs() << "Invalid DIType\n";
if (isDefinition())
errs() << " [def] ";
- if (isGlobalVariable(Tag))
+ if (isGlobalVariable())
DIGlobalVariable(DbgNode).dump();
errs() << "\n";
return;
addCompileUnit(DT.getCompileUnit());
- if (DT.isCompositeType(DT.getTag())) {
+ if (DT.isCompositeType()) {
DICompositeType DCT(DT.getNode());
processType(DCT.getTypeDerivedFrom());
DIArray DA = DCT.getTypeArray();
else
processSubprogram(DISubprogram(D.getNode()));
}
- } else if (DT.isDerivedType(DT.getTag())) {
+ } else if (DT.isDerivedType()) {
DIDerivedType DDT(DT.getNode());
if (!DDT.isNull())
processType(DDT.getTypeDerivedFrom());