forked from OSchip/llvm-project
Simplify isDerivedType() and other predicate interface.
llvm-svn: 80602
This commit is contained in:
parent
6627c4ec82
commit
9fda4bd998
|
@ -87,6 +87,13 @@ namespace llvm {
|
||||||
|
|
||||||
/// dump - print descriptor.
|
/// dump - print descriptor.
|
||||||
void dump() const;
|
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.
|
/// DISubrange - This is used to represent ranges, for array bounds.
|
||||||
|
@ -185,19 +192,6 @@ namespace llvm {
|
||||||
DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
|
DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
|
||||||
|
|
||||||
public:
|
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.
|
/// Verify - Verify that a type descriptor is well formed.
|
||||||
bool Verify() const;
|
bool Verify() const;
|
||||||
|
@ -257,7 +251,7 @@ namespace llvm {
|
||||||
public:
|
public:
|
||||||
explicit DIDerivedType(MDNode *N = 0)
|
explicit DIDerivedType(MDNode *N = 0)
|
||||||
: DIType(N, true, true) {
|
: DIType(N, true, true) {
|
||||||
if (DbgNode && !isDerivedType(getTag()))
|
if (DbgNode && !isDerivedType())
|
||||||
DbgNode = 0;
|
DbgNode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +276,7 @@ namespace llvm {
|
||||||
public:
|
public:
|
||||||
explicit DICompositeType(MDNode *N = 0)
|
explicit DICompositeType(MDNode *N = 0)
|
||||||
: DIDerivedType(N, true, true) {
|
: DIDerivedType(N, true, true) {
|
||||||
if (N && !isCompositeType(getTag()))
|
if (N && !isCompositeType())
|
||||||
DbgNode = 0;
|
DbgNode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,18 +296,6 @@ namespace llvm {
|
||||||
explicit DIGlobal(MDNode *N, unsigned RequiredTag)
|
explicit DIGlobal(MDNode *N, unsigned RequiredTag)
|
||||||
: DIDescriptor(N, 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:
|
public:
|
||||||
virtual ~DIGlobal() {}
|
virtual ~DIGlobal() {}
|
||||||
|
|
||||||
|
@ -393,7 +375,7 @@ namespace llvm {
|
||||||
public:
|
public:
|
||||||
explicit DIVariable(MDNode *N = 0)
|
explicit DIVariable(MDNode *N = 0)
|
||||||
: DIDescriptor(N) {
|
: DIDescriptor(N) {
|
||||||
if (DbgNode && !isVariable(getTag()))
|
if (DbgNode && !isVariable())
|
||||||
DbgNode = 0;
|
DbgNode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,8 +387,6 @@ namespace llvm {
|
||||||
unsigned getLineNumber() const { return getUnsignedField(4); }
|
unsigned getLineNumber() const { return getUnsignedField(4); }
|
||||||
DIType getType() const { return getFieldAs<DIType>(5); }
|
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.
|
/// Verify - Verify that a variable descriptor is well formed.
|
||||||
bool Verify() const;
|
bool Verify() const;
|
||||||
|
|
|
@ -124,22 +124,23 @@ GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Simple Descriptor Constructors and other Methods
|
// Predicates
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// Needed by DIVariable::getType().
|
/// isBasicType - Return true if the specified tag is legal for
|
||||||
DIType::DIType(MDNode *N) : DIDescriptor(N) {
|
/// DIBasicType.
|
||||||
if (!N) return;
|
bool DIDescriptor::isBasicType() const {
|
||||||
unsigned tag = getTag();
|
assert (isNull() && "Invalid descriptor!");
|
||||||
if (tag != dwarf::DW_TAG_base_type && !DIDerivedType::isDerivedType(tag) &&
|
unsigned Tag = getTag();
|
||||||
!DICompositeType::isCompositeType(tag)) {
|
|
||||||
DbgNode = 0;
|
return Tag == dwarf::DW_TAG_base_type;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isDerivedType - Return true if the specified tag is legal for
|
/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
|
||||||
/// DIDerivedType.
|
bool DIDescriptor::isDerivedType() const {
|
||||||
bool DIType::isDerivedType(unsigned Tag) {
|
assert (isNull() && "Invalid descriptor!");
|
||||||
|
unsigned Tag = getTag();
|
||||||
|
|
||||||
switch (Tag) {
|
switch (Tag) {
|
||||||
case dwarf::DW_TAG_typedef:
|
case dwarf::DW_TAG_typedef:
|
||||||
case dwarf::DW_TAG_pointer_type:
|
case dwarf::DW_TAG_pointer_type:
|
||||||
|
@ -152,14 +153,17 @@ bool DIType::isDerivedType(unsigned Tag) {
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
// CompositeTypes are currently modelled as DerivedTypes.
|
// CompositeTypes are currently modelled as DerivedTypes.
|
||||||
return isCompositeType(Tag);
|
return isCompositeType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isCompositeType - Return true if the specified tag is legal for
|
/// isCompositeType - Return true if the specified tag is legal for
|
||||||
/// DICompositeType.
|
/// DICompositeType.
|
||||||
bool DIType::isCompositeType(unsigned TAG) {
|
bool DIDescriptor::isCompositeType() const {
|
||||||
switch (TAG) {
|
assert (isNull() && "Invalid descriptor!");
|
||||||
|
unsigned Tag = getTag();
|
||||||
|
|
||||||
|
switch (Tag) {
|
||||||
case dwarf::DW_TAG_array_type:
|
case dwarf::DW_TAG_array_type:
|
||||||
case dwarf::DW_TAG_structure_type:
|
case dwarf::DW_TAG_structure_type:
|
||||||
case dwarf::DW_TAG_union_type:
|
case dwarf::DW_TAG_union_type:
|
||||||
|
@ -174,7 +178,10 @@ bool DIType::isCompositeType(unsigned TAG) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isVariable - Return true if the specified tag is legal for DIVariable.
|
/// 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) {
|
switch (Tag) {
|
||||||
case dwarf::DW_TAG_auto_variable:
|
case dwarf::DW_TAG_auto_variable:
|
||||||
case dwarf::DW_TAG_arg_variable:
|
case dwarf::DW_TAG_arg_variable:
|
||||||
|
@ -185,6 +192,36 @@ bool DIVariable::isVariable(unsigned Tag) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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 {
|
unsigned DIArray::getNumElements() const {
|
||||||
assert (DbgNode && "Invalid DIArray");
|
assert (DbgNode && "Invalid DIArray");
|
||||||
return DbgNode->getNumElements();
|
return DbgNode->getNumElements();
|
||||||
|
@ -366,11 +403,11 @@ void DIType::dump() const {
|
||||||
if (isForwardDecl())
|
if (isForwardDecl())
|
||||||
errs() << " [fwd] ";
|
errs() << " [fwd] ";
|
||||||
|
|
||||||
if (isBasicType(Tag))
|
if (isBasicType())
|
||||||
DIBasicType(DbgNode).dump();
|
DIBasicType(DbgNode).dump();
|
||||||
else if (isDerivedType(Tag))
|
else if (isDerivedType())
|
||||||
DIDerivedType(DbgNode).dump();
|
DIDerivedType(DbgNode).dump();
|
||||||
else if (isCompositeType(Tag))
|
else if (isCompositeType())
|
||||||
DICompositeType(DbgNode).dump();
|
DICompositeType(DbgNode).dump();
|
||||||
else {
|
else {
|
||||||
errs() << "Invalid DIType\n";
|
errs() << "Invalid DIType\n";
|
||||||
|
@ -417,7 +454,7 @@ void DIGlobal::dump() const {
|
||||||
if (isDefinition())
|
if (isDefinition())
|
||||||
errs() << " [def] ";
|
errs() << " [def] ";
|
||||||
|
|
||||||
if (isGlobalVariable(Tag))
|
if (isGlobalVariable())
|
||||||
DIGlobalVariable(DbgNode).dump();
|
DIGlobalVariable(DbgNode).dump();
|
||||||
|
|
||||||
errs() << "\n";
|
errs() << "\n";
|
||||||
|
@ -818,7 +855,7 @@ void DebugInfoFinder::processType(DIType DT) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
addCompileUnit(DT.getCompileUnit());
|
addCompileUnit(DT.getCompileUnit());
|
||||||
if (DT.isCompositeType(DT.getTag())) {
|
if (DT.isCompositeType()) {
|
||||||
DICompositeType DCT(DT.getNode());
|
DICompositeType DCT(DT.getNode());
|
||||||
processType(DCT.getTypeDerivedFrom());
|
processType(DCT.getTypeDerivedFrom());
|
||||||
DIArray DA = DCT.getTypeArray();
|
DIArray DA = DCT.getTypeArray();
|
||||||
|
@ -831,7 +868,7 @@ void DebugInfoFinder::processType(DIType DT) {
|
||||||
else
|
else
|
||||||
processSubprogram(DISubprogram(D.getNode()));
|
processSubprogram(DISubprogram(D.getNode()));
|
||||||
}
|
}
|
||||||
} else if (DT.isDerivedType(DT.getTag())) {
|
} else if (DT.isDerivedType()) {
|
||||||
DIDerivedType DDT(DT.getNode());
|
DIDerivedType DDT(DT.getNode());
|
||||||
if (!DDT.isNull())
|
if (!DDT.isNull())
|
||||||
processType(DDT.getTypeDerivedFrom());
|
processType(DDT.getTypeDerivedFrom());
|
||||||
|
|
|
@ -547,12 +547,12 @@ void DwarfDebug::AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty) {
|
||||||
|
|
||||||
// Construct type.
|
// Construct type.
|
||||||
DIE Buffer(dwarf::DW_TAG_base_type);
|
DIE Buffer(dwarf::DW_TAG_base_type);
|
||||||
if (Ty.isBasicType(Ty.getTag()))
|
if (Ty.isBasicType())
|
||||||
ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getNode()));
|
ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getNode()));
|
||||||
else if (Ty.isCompositeType(Ty.getTag()))
|
else if (Ty.isCompositeType())
|
||||||
ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getNode()));
|
ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getNode()));
|
||||||
else {
|
else {
|
||||||
assert(Ty.isDerivedType(Ty.getTag()) && "Unknown kind of DIType");
|
assert(Ty.isDerivedType() && "Unknown kind of DIType");
|
||||||
ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getNode()));
|
ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getNode()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ using namespace llvm;
|
||||||
void PIC16DbgInfo::PopulateDebugInfo (DIType Ty, unsigned short &TypeNo,
|
void PIC16DbgInfo::PopulateDebugInfo (DIType Ty, unsigned short &TypeNo,
|
||||||
bool &HasAux, int Aux[],
|
bool &HasAux, int Aux[],
|
||||||
std::string &TagName) {
|
std::string &TagName) {
|
||||||
if (Ty.isBasicType(Ty.getTag()))
|
if (Ty.isBasicType())
|
||||||
PopulateBasicTypeInfo (Ty, TypeNo);
|
PopulateBasicTypeInfo (Ty, TypeNo);
|
||||||
else if (Ty.isDerivedType(Ty.getTag()))
|
else if (Ty.isDerivedType())
|
||||||
PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
|
PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
|
||||||
else if (Ty.isCompositeType(Ty.getTag()))
|
else if (Ty.isCompositeType())
|
||||||
PopulateCompositeTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
|
PopulateCompositeTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
|
||||||
else {
|
else {
|
||||||
TypeNo = PIC16Dbg::T_NULL;
|
TypeNo = PIC16Dbg::T_NULL;
|
||||||
|
|
Loading…
Reference in New Issue