aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-08-31 18:49:10 +0000
committerDevang Patel <dpatel@apple.com>2009-08-31 18:49:10 +0000
commit6ceea33c5e5c00069453e48740aaef5fe1c0953b (patch)
tree66dbad38919af9011cc13cfbcd034312a27f4d97 /lib
parent049e98d641f90e90e8312d76cbf4c68908fb9d1d (diff)
Simplify isDerivedType() and other predicate interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/DebugInfo.cpp81
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp6
-rw-r--r--lib/Target/PIC16/PIC16DebugInfo.cpp6
3 files changed, 65 insertions, 28 deletions
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 0d4b213e80..69018894c6 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -124,22 +124,23 @@ GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) 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:
@@ -152,14 +153,17 @@ bool DIType::isDerivedType(unsigned Tag) {
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:
@@ -174,7 +178,10 @@ bool DIType::isCompositeType(unsigned TAG) {
}
/// 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:
@@ -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 {
assert (DbgNode && "Invalid DIArray");
return DbgNode->getNumElements();
@@ -366,11 +403,11 @@ void DIType::dump() const {
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";
@@ -417,7 +454,7 @@ void DIGlobal::dump() const {
if (isDefinition())
errs() << " [def] ";
- if (isGlobalVariable(Tag))
+ if (isGlobalVariable())
DIGlobalVariable(DbgNode).dump();
errs() << "\n";
@@ -818,7 +855,7 @@ void DebugInfoFinder::processType(DIType DT) {
return;
addCompileUnit(DT.getCompileUnit());
- if (DT.isCompositeType(DT.getTag())) {
+ if (DT.isCompositeType()) {
DICompositeType DCT(DT.getNode());
processType(DCT.getTypeDerivedFrom());
DIArray DA = DCT.getTypeArray();
@@ -831,7 +868,7 @@ void DebugInfoFinder::processType(DIType DT) {
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());
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index efa7577c62..0e8521e83e 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -547,12 +547,12 @@ void DwarfDebug::AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty) {
// Construct type.
DIE Buffer(dwarf::DW_TAG_base_type);
- if (Ty.isBasicType(Ty.getTag()))
+ if (Ty.isBasicType())
ConstructTypeDIE(DW_Unit, Buffer, DIBasicType(Ty.getNode()));
- else if (Ty.isCompositeType(Ty.getTag()))
+ else if (Ty.isCompositeType())
ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getNode()));
else {
- assert(Ty.isDerivedType(Ty.getTag()) && "Unknown kind of DIType");
+ assert(Ty.isDerivedType() && "Unknown kind of DIType");
ConstructTypeDIE(DW_Unit, Buffer, DIDerivedType(Ty.getNode()));
}
diff --git a/lib/Target/PIC16/PIC16DebugInfo.cpp b/lib/Target/PIC16/PIC16DebugInfo.cpp
index 4dcd84dc57..3499e5c356 100644
--- a/lib/Target/PIC16/PIC16DebugInfo.cpp
+++ b/lib/Target/PIC16/PIC16DebugInfo.cpp
@@ -28,11 +28,11 @@ using namespace llvm;
void PIC16DbgInfo::PopulateDebugInfo (DIType Ty, unsigned short &TypeNo,
bool &HasAux, int Aux[],
std::string &TagName) {
- if (Ty.isBasicType(Ty.getTag()))
+ if (Ty.isBasicType())
PopulateBasicTypeInfo (Ty, TypeNo);
- else if (Ty.isDerivedType(Ty.getTag()))
+ else if (Ty.isDerivedType())
PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
- else if (Ty.isCompositeType(Ty.getTag()))
+ else if (Ty.isCompositeType())
PopulateCompositeTypeInfo (Ty, TypeNo, HasAux, Aux, TagName);
else {
TypeNo = PIC16Dbg::T_NULL;