mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
Avoid using DIDescriptor.isNull().
This is a first step towards eliminating checks in Descriptor constructors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97975 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ccb4f2d813
commit
3c91b05d2b
@ -68,6 +68,7 @@ namespace llvm {
|
||||
explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
|
||||
|
||||
bool isNull() const { return DbgNode == 0; }
|
||||
bool Verify() const { return DbgNode != 0; }
|
||||
|
||||
MDNode *getNode() const { return DbgNode; }
|
||||
|
||||
@ -246,7 +247,9 @@ namespace llvm {
|
||||
bool isArtificial() const {
|
||||
return (getFlags() & FlagArtificial) != 0;
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
|
||||
}
|
||||
/// dump - print type.
|
||||
void dump() const;
|
||||
};
|
||||
@ -360,7 +363,7 @@ namespace llvm {
|
||||
/// DIType or as DICompositeType.
|
||||
StringRef getReturnTypeName() const {
|
||||
DICompositeType DCT(getFieldAs<DICompositeType>(8));
|
||||
if (!DCT.isNull()) {
|
||||
if (DCT.Verify()) {
|
||||
DIArray A = DCT.getTypeArray();
|
||||
DIType T(A.getElement(0).getNode());
|
||||
return T.getName();
|
||||
@ -494,6 +497,7 @@ namespace llvm {
|
||||
DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
|
||||
StringRef getFilename() const { return getScope().getFilename(); }
|
||||
StringRef getDirectory() const { return getScope().getDirectory(); }
|
||||
bool Verify() const;
|
||||
};
|
||||
|
||||
/// DIFactory - This object assists with the construction of the various
|
||||
|
@ -132,13 +132,12 @@ unsigned DIVariable::getNumAddrElements() const {
|
||||
/// isBasicType - Return true if the specified tag is legal for
|
||||
/// DIBasicType.
|
||||
bool DIDescriptor::isBasicType() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_base_type;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_base_type;
|
||||
}
|
||||
|
||||
/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
|
||||
bool DIDescriptor::isDerivedType() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
if (!DbgNode) return false;
|
||||
switch (getTag()) {
|
||||
case dwarf::DW_TAG_typedef:
|
||||
case dwarf::DW_TAG_pointer_type:
|
||||
@ -158,7 +157,7 @@ bool DIDescriptor::isDerivedType() const {
|
||||
/// isCompositeType - Return true if the specified tag is legal for
|
||||
/// DICompositeType.
|
||||
bool DIDescriptor::isCompositeType() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
if (!DbgNode) return false;
|
||||
switch (getTag()) {
|
||||
case dwarf::DW_TAG_array_type:
|
||||
case dwarf::DW_TAG_structure_type:
|
||||
@ -175,7 +174,7 @@ bool DIDescriptor::isCompositeType() const {
|
||||
|
||||
/// isVariable - Return true if the specified tag is legal for DIVariable.
|
||||
bool DIDescriptor::isVariable() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
if (!DbgNode) return false;
|
||||
switch (getTag()) {
|
||||
case dwarf::DW_TAG_auto_variable:
|
||||
case dwarf::DW_TAG_arg_variable:
|
||||
@ -194,15 +193,13 @@ bool DIDescriptor::isType() const {
|
||||
/// isSubprogram - Return true if the specified tag is legal for
|
||||
/// DISubprogram.
|
||||
bool DIDescriptor::isSubprogram() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_subprogram;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_subprogram;
|
||||
}
|
||||
|
||||
/// isGlobalVariable - Return true if the specified tag is legal for
|
||||
/// DIGlobalVariable.
|
||||
bool DIDescriptor::isGlobalVariable() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_variable;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_variable;
|
||||
}
|
||||
|
||||
/// isGlobal - Return true if the specified tag is legal for DIGlobal.
|
||||
@ -213,7 +210,7 @@ bool DIDescriptor::isGlobal() const {
|
||||
/// isScope - Return true if the specified tag is one of the scope
|
||||
/// related tag.
|
||||
bool DIDescriptor::isScope() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
if (!DbgNode) return false;
|
||||
switch (getTag()) {
|
||||
case dwarf::DW_TAG_compile_unit:
|
||||
case dwarf::DW_TAG_lexical_block:
|
||||
@ -228,32 +225,27 @@ bool DIDescriptor::isScope() const {
|
||||
|
||||
/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
|
||||
bool DIDescriptor::isCompileUnit() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_compile_unit;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_compile_unit;
|
||||
}
|
||||
|
||||
/// isNameSpace - Return true if the specified tag is DW_TAG_namespace.
|
||||
bool DIDescriptor::isNameSpace() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_namespace;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_namespace;
|
||||
}
|
||||
|
||||
/// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block.
|
||||
bool DIDescriptor::isLexicalBlock() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_lexical_block;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_lexical_block;
|
||||
}
|
||||
|
||||
/// isSubrange - Return true if the specified tag is DW_TAG_subrange_type.
|
||||
bool DIDescriptor::isSubrange() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_subrange_type;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_subrange_type;
|
||||
}
|
||||
|
||||
/// isEnumerator - Return true if the specified tag is DW_TAG_enumerator.
|
||||
bool DIDescriptor::isEnumerator() const {
|
||||
assert(!isNull() && "Invalid descriptor!");
|
||||
return getTag() == dwarf::DW_TAG_enumerator;
|
||||
return DbgNode && getTag() == dwarf::DW_TAG_enumerator;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -268,7 +260,8 @@ DIType::DIType(MDNode *N) : DIDescriptor(N) {
|
||||
}
|
||||
|
||||
unsigned DIArray::getNumElements() const {
|
||||
assert(DbgNode && "Invalid DIArray");
|
||||
if (!DbgNode)
|
||||
return 0;
|
||||
return DbgNode->getNumOperands();
|
||||
}
|
||||
|
||||
@ -276,11 +269,9 @@ unsigned DIArray::getNumElements() const {
|
||||
/// this descriptor. After this completes, the current debug info value
|
||||
/// is erased.
|
||||
void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return;
|
||||
|
||||
assert(!D.isNull() && "Can not replace with null");
|
||||
|
||||
// Since we use a TrackingVH for the node, its easy for clients to manufacture
|
||||
// legitimate situations where they want to replaceAllUsesWith() on something
|
||||
// which, due to uniquing, has merged with the source. We shield clients from
|
||||
@ -295,7 +286,7 @@ void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) {
|
||||
|
||||
/// Verify - Verify that a compile unit is well formed.
|
||||
bool DICompileUnit::Verify() const {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
StringRef N = getFilename();
|
||||
if (N.empty())
|
||||
@ -306,36 +297,36 @@ bool DICompileUnit::Verify() const {
|
||||
|
||||
/// Verify - Verify that a type descriptor is well formed.
|
||||
bool DIType::Verify() const {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
if (getContext().isNull())
|
||||
if (!getContext().Verify())
|
||||
return false;
|
||||
|
||||
DICompileUnit CU = getCompileUnit();
|
||||
if (!CU.isNull() && !CU.Verify())
|
||||
if (!CU.Verify())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Verify - Verify that a composite type descriptor is well formed.
|
||||
bool DICompositeType::Verify() const {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
if (getContext().isNull())
|
||||
if (!getContext().Verify())
|
||||
return false;
|
||||
|
||||
DICompileUnit CU = getCompileUnit();
|
||||
if (!CU.isNull() && !CU.Verify())
|
||||
if (!CU.Verify())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Verify - Verify that a subprogram descriptor is well formed.
|
||||
bool DISubprogram::Verify() const {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
|
||||
if (getContext().isNull())
|
||||
if (!getContext().Verify())
|
||||
return false;
|
||||
|
||||
DICompileUnit CU = getCompileUnit();
|
||||
@ -343,24 +334,24 @@ bool DISubprogram::Verify() const {
|
||||
return false;
|
||||
|
||||
DICompositeType Ty = getType();
|
||||
if (!Ty.isNull() && !Ty.Verify())
|
||||
if (!Ty.Verify())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Verify - Verify that a global variable descriptor is well formed.
|
||||
bool DIGlobalVariable::Verify() const {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
|
||||
if (getDisplayName().empty())
|
||||
return false;
|
||||
|
||||
if (getContext().isNull())
|
||||
if (!getContext().Verify())
|
||||
return false;
|
||||
|
||||
DICompileUnit CU = getCompileUnit();
|
||||
if (!CU.isNull() && !CU.Verify())
|
||||
if (!CU.Verify())
|
||||
return false;
|
||||
|
||||
DIType Ty = getType();
|
||||
@ -375,10 +366,10 @@ bool DIGlobalVariable::Verify() const {
|
||||
|
||||
/// Verify - Verify that a variable descriptor is well formed.
|
||||
bool DIVariable::Verify() const {
|
||||
if (isNull())
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
|
||||
if (getContext().isNull())
|
||||
if (!getContext().Verify())
|
||||
return false;
|
||||
|
||||
DIType Ty = getType();
|
||||
@ -388,6 +379,14 @@ bool DIVariable::Verify() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Verify - Verify that a location descriptor is well formed.
|
||||
bool DILocation::Verify() const {
|
||||
if (!DbgNode)
|
||||
return false;
|
||||
|
||||
return DbgNode->getNumOperands() == 4;
|
||||
}
|
||||
|
||||
/// getOriginalTypeSize - If this type is derived from a base type then
|
||||
/// return base type size.
|
||||
uint64_t DIDerivedType::getOriginalTypeSize() const {
|
||||
@ -398,7 +397,7 @@ uint64_t DIDerivedType::getOriginalTypeSize() const {
|
||||
DIType BaseType = getTypeDerivedFrom();
|
||||
// If this type is not derived from any type then take conservative
|
||||
// approach.
|
||||
if (BaseType.isNull())
|
||||
if (!BaseType.isValid())
|
||||
return getSizeInBits();
|
||||
if (BaseType.isDerivedType())
|
||||
return DIDerivedType(BaseType.getNode()).getOriginalTypeSize();
|
||||
@ -468,7 +467,7 @@ void DICompileUnit::dump() const {
|
||||
|
||||
/// dump - Print type.
|
||||
void DIType::dump() const {
|
||||
if (isNull()) return;
|
||||
if (!DbgNode) return;
|
||||
|
||||
StringRef Res = getName();
|
||||
if (!Res.empty())
|
||||
@ -521,8 +520,6 @@ void DIDerivedType::dump() const {
|
||||
/// dump - Print composite type.
|
||||
void DICompositeType::dump() const {
|
||||
DIArray A = getTypeArray();
|
||||
if (A.isNull())
|
||||
return;
|
||||
dbgs() << " [" << A.getNumElements() << " elements]";
|
||||
}
|
||||
|
||||
@ -1155,9 +1152,8 @@ void DebugInfoFinder::processModule(Module &M) {
|
||||
|
||||
/// processLocation - Process DILocation.
|
||||
void DebugInfoFinder::processLocation(DILocation Loc) {
|
||||
if (Loc.isNull()) return;
|
||||
DIScope S(Loc.getScope().getNode());
|
||||
if (S.isNull()) return;
|
||||
if (!Loc.Verify()) return;
|
||||
DIDescriptor S(Loc.getScope().getNode());
|
||||
if (S.isCompileUnit())
|
||||
addCompileUnit(DICompileUnit(S.getNode()));
|
||||
else if (S.isSubprogram())
|
||||
@ -1177,26 +1173,21 @@ void DebugInfoFinder::processType(DIType DT) {
|
||||
DICompositeType DCT(DT.getNode());
|
||||
processType(DCT.getTypeDerivedFrom());
|
||||
DIArray DA = DCT.getTypeArray();
|
||||
if (!DA.isNull())
|
||||
for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
|
||||
DIDescriptor D = DA.getElement(i);
|
||||
DIType TyE = DIType(D.getNode());
|
||||
if (!TyE.isNull())
|
||||
processType(TyE);
|
||||
else
|
||||
processSubprogram(DISubprogram(D.getNode()));
|
||||
}
|
||||
for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
|
||||
DIDescriptor D = DA.getElement(i);
|
||||
if (D.isType())
|
||||
processType(DIType(D.getNode()));
|
||||
else if (D.isSubprogram())
|
||||
processSubprogram(DISubprogram(D.getNode()));
|
||||
}
|
||||
} else if (DT.isDerivedType()) {
|
||||
DIDerivedType DDT(DT.getNode());
|
||||
if (!DDT.isNull())
|
||||
processType(DDT.getTypeDerivedFrom());
|
||||
processType(DDT.getTypeDerivedFrom());
|
||||
}
|
||||
}
|
||||
|
||||
/// processLexicalBlock
|
||||
void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
|
||||
if (LB.isNull())
|
||||
return;
|
||||
DIScope Context = LB.getContext();
|
||||
if (Context.isLexicalBlock())
|
||||
return processLexicalBlock(DILexicalBlock(Context.getNode()));
|
||||
@ -1206,8 +1197,6 @@ void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
|
||||
|
||||
/// processSubprogram - Process DISubprogram.
|
||||
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
|
||||
if (SP.isNull())
|
||||
return;
|
||||
if (!addSubprogram(SP))
|
||||
return;
|
||||
addCompileUnit(SP.getCompileUnit());
|
||||
@ -1216,20 +1205,23 @@ void DebugInfoFinder::processSubprogram(DISubprogram SP) {
|
||||
|
||||
/// processDeclare - Process DbgDeclareInst.
|
||||
void DebugInfoFinder::processDeclare(DbgDeclareInst *DDI) {
|
||||
DIVariable DV(cast<MDNode>(DDI->getVariable()));
|
||||
if (DV.isNull())
|
||||
MDNode *N = dyn_cast<MDNode>(DDI->getVariable());
|
||||
if (!N) return;
|
||||
|
||||
DIDescriptor DV(N);
|
||||
if (!DV.isVariable())
|
||||
return;
|
||||
|
||||
if (!NodesSeen.insert(DV.getNode()))
|
||||
return;
|
||||
|
||||
addCompileUnit(DV.getCompileUnit());
|
||||
processType(DV.getType());
|
||||
addCompileUnit(DIVariable(N).getCompileUnit());
|
||||
processType(DIVariable(N).getType());
|
||||
}
|
||||
|
||||
/// addType - Add type into Tys.
|
||||
bool DebugInfoFinder::addType(DIType DT) {
|
||||
if (DT.isNull())
|
||||
if (!DT.isValid())
|
||||
return false;
|
||||
|
||||
if (!NodesSeen.insert(DT.getNode()))
|
||||
@ -1241,7 +1233,7 @@ bool DebugInfoFinder::addType(DIType DT) {
|
||||
|
||||
/// addCompileUnit - Add compile unit into CUs.
|
||||
bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) {
|
||||
if (CU.isNull())
|
||||
if (!CU.Verify())
|
||||
return false;
|
||||
|
||||
if (!NodesSeen.insert(CU.getNode()))
|
||||
@ -1253,7 +1245,7 @@ bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) {
|
||||
|
||||
/// addGlobalVariable - Add global variable into GVs.
|
||||
bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) {
|
||||
if (DIG.isNull())
|
||||
if (!DIDescriptor(DIG.getNode()).isGlobalVariable())
|
||||
return false;
|
||||
|
||||
if (!NodesSeen.insert(DIG.getNode()))
|
||||
@ -1265,7 +1257,7 @@ bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) {
|
||||
|
||||
// addSubprogram - Add subprgoram into SPs.
|
||||
bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
|
||||
if (SP.isNull())
|
||||
if (!DIDescriptor(SP.getNode()).isSubprogram())
|
||||
return false;
|
||||
|
||||
if (!NodesSeen.insert(SP.getNode()))
|
||||
@ -1283,10 +1275,10 @@ static Value *findDbgGlobalDeclare(GlobalVariable *V) {
|
||||
return 0;
|
||||
|
||||
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||
DIGlobalVariable DIG(cast_or_null<MDNode>(NMD->getOperand(i)));
|
||||
if (DIG.isNull())
|
||||
DIDescriptor DIG(cast_or_null<MDNode>(NMD->getOperand(i)));
|
||||
if (!DIG.isGlobalVariable())
|
||||
continue;
|
||||
if (DIG.getGlobal() == V)
|
||||
if (DIGlobalVariable(DIG.getNode()).getGlobal() == V)
|
||||
return DIG.getNode();
|
||||
}
|
||||
return 0;
|
||||
@ -1378,12 +1370,6 @@ DebugLoc llvm::ExtractDebugLocation(DILocation &Loc,
|
||||
/// getDISubprogram - Find subprogram that is enclosing this scope.
|
||||
DISubprogram llvm::getDISubprogram(MDNode *Scope) {
|
||||
DIDescriptor D(Scope);
|
||||
if (D.isNull())
|
||||
return DISubprogram();
|
||||
|
||||
if (D.isCompileUnit())
|
||||
return DISubprogram();
|
||||
|
||||
if (D.isSubprogram())
|
||||
return DISubprogram(Scope);
|
||||
|
||||
@ -1395,9 +1381,6 @@ DISubprogram llvm::getDISubprogram(MDNode *Scope) {
|
||||
|
||||
/// getDICompositeType - Find underlying composite type.
|
||||
DICompositeType llvm::getDICompositeType(DIType T) {
|
||||
if (T.isNull())
|
||||
return DICompositeType();
|
||||
|
||||
if (T.isCompositeType())
|
||||
return DICompositeType(T.getNode());
|
||||
|
||||
|
@ -335,7 +335,7 @@ static void EmitComments(const MachineInstr &MI, raw_ostream &CommentOS) {
|
||||
// Print source line info.
|
||||
DIScope Scope = DLT.getScope();
|
||||
// Omit the directory, because it's likely to be long and uninteresting.
|
||||
if (!Scope.isNull())
|
||||
if (Scope.Verify())
|
||||
CommentOS << Scope.getFilename();
|
||||
else
|
||||
CommentOS << "<unknown>";
|
||||
@ -1287,7 +1287,7 @@ void AsmPrinter::processDebugLoc(const MachineInstr *MI,
|
||||
if (DL.isUnknown())
|
||||
return;
|
||||
DILocation CurDLT = MF->getDILocation(DL);
|
||||
if (CurDLT.getScope().isNull())
|
||||
if (!CurDLT.getScope().Verify())
|
||||
return;
|
||||
|
||||
if (!BeforePrintingInsn) {
|
||||
|
@ -413,7 +413,7 @@ void DwarfDebug::addBlock(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
/// entry.
|
||||
void DwarfDebug::addSourceLine(DIE *Die, const DIVariable *V) {
|
||||
// If there is no compile unit specified, don't add a line #.
|
||||
if (V->getCompileUnit().isNull())
|
||||
if (!V->getCompileUnit().Verify())
|
||||
return;
|
||||
|
||||
unsigned Line = V->getLineNumber();
|
||||
@ -427,7 +427,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DIVariable *V) {
|
||||
/// entry.
|
||||
void DwarfDebug::addSourceLine(DIE *Die, const DIGlobal *G) {
|
||||
// If there is no compile unit specified, don't add a line #.
|
||||
if (G->getCompileUnit().isNull())
|
||||
if (!G->getCompileUnit().Verify())
|
||||
return;
|
||||
|
||||
unsigned Line = G->getLineNumber();
|
||||
@ -441,7 +441,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DIGlobal *G) {
|
||||
/// entry.
|
||||
void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram *SP) {
|
||||
// If there is no compile unit specified, don't add a line #.
|
||||
if (SP->getCompileUnit().isNull())
|
||||
if (!SP->getCompileUnit().Verify())
|
||||
return;
|
||||
// If the line number is 0, don't add it.
|
||||
if (SP->getLineNumber() == 0)
|
||||
@ -460,7 +460,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram *SP) {
|
||||
void DwarfDebug::addSourceLine(DIE *Die, const DIType *Ty) {
|
||||
// If there is no compile unit specified, don't add a line #.
|
||||
DICompileUnit CU = Ty->getCompileUnit();
|
||||
if (CU.isNull())
|
||||
if (!CU.Verify())
|
||||
return;
|
||||
|
||||
unsigned Line = Ty->getLineNumber();
|
||||
@ -474,7 +474,7 @@ void DwarfDebug::addSourceLine(DIE *Die, const DIType *Ty) {
|
||||
/// entry.
|
||||
void DwarfDebug::addSourceLine(DIE *Die, const DINameSpace *NS) {
|
||||
// If there is no compile unit specified, don't add a line #.
|
||||
if (NS->getCompileUnit().isNull())
|
||||
if (!NS->getCompileUnit().Verify())
|
||||
return;
|
||||
|
||||
unsigned Line = NS->getLineNumber();
|
||||
@ -526,12 +526,8 @@ DIType DwarfDebug::getBlockByrefType(DIType Ty, std::string Name) {
|
||||
}
|
||||
|
||||
DICompositeType blockStruct = DICompositeType(subType.getNode());
|
||||
|
||||
DIArray Elements = blockStruct.getTypeArray();
|
||||
|
||||
if (Elements.isNull())
|
||||
return Ty;
|
||||
|
||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
||||
DIDescriptor Element = Elements.getElement(i);
|
||||
DIDerivedType DT = DIDerivedType(Element.getNode());
|
||||
@ -677,7 +673,6 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die,
|
||||
DIDescriptor varField = DIDescriptor();
|
||||
DIDescriptor forwardingField = DIDescriptor();
|
||||
|
||||
|
||||
for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) {
|
||||
DIDescriptor Element = Fields.getElement(i);
|
||||
DIDerivedType DT = DIDerivedType(Element.getNode());
|
||||
@ -688,10 +683,6 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die,
|
||||
varField = Element;
|
||||
}
|
||||
|
||||
assert(!varField.isNull() && "Can't find byref variable in Block struct");
|
||||
assert(!forwardingField.isNull()
|
||||
&& "Can't find forwarding field in Block struct");
|
||||
|
||||
// Get the offsets for the forwarding field and the variable field.
|
||||
unsigned int forwardingFieldOffset =
|
||||
DIDerivedType(forwardingField.getNode()).getOffsetInBits() >> 3;
|
||||
@ -781,9 +772,7 @@ void DwarfDebug::addAddress(DIE *Die, unsigned Attribute,
|
||||
|
||||
/// addToContextOwner - Add Die into the list of its context owner's children.
|
||||
void DwarfDebug::addToContextOwner(DIE *Die, DIDescriptor Context) {
|
||||
if (Context.isNull())
|
||||
ModuleCU->addDie(Die);
|
||||
else if (Context.isType()) {
|
||||
if (Context.isType()) {
|
||||
DIE *ContextDIE = getOrCreateTypeDIE(DIType(Context.getNode()));
|
||||
ContextDIE->addChild(Die);
|
||||
} else if (Context.isNameSpace()) {
|
||||
@ -820,7 +809,7 @@ DIE *DwarfDebug::getOrCreateTypeDIE(DIType Ty) {
|
||||
|
||||
/// addType - Add a new type attribute to the specified entity.
|
||||
void DwarfDebug::addType(DIE *Entity, DIType Ty) {
|
||||
if (Ty.isNull())
|
||||
if (!Ty.isValid())
|
||||
return;
|
||||
|
||||
// Check for pre-existence.
|
||||
@ -906,9 +895,9 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||
// Add enumerators to enumeration type.
|
||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
||||
DIE *ElemDie = NULL;
|
||||
DIEnumerator Enum(Elements.getElement(i).getNode());
|
||||
if (!Enum.isNull()) {
|
||||
ElemDie = constructEnumTypeDIE(&Enum);
|
||||
DIDescriptor Enum(Elements.getElement(i).getNode());
|
||||
if (Enum.isEnumerator()) {
|
||||
ElemDie = constructEnumTypeDIE(DIEnumerator(Enum.getNode()));
|
||||
Buffer.addChild(ElemDie);
|
||||
}
|
||||
}
|
||||
@ -939,18 +928,17 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||
DIArray Elements = CTy.getTypeArray();
|
||||
|
||||
// A forward struct declared type may not have elements available.
|
||||
if (Elements.isNull())
|
||||
unsigned N = Elements.getNumElements();
|
||||
if (N == 0)
|
||||
break;
|
||||
|
||||
// Add elements to structure type.
|
||||
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
DIDescriptor Element = Elements.getElement(i);
|
||||
if (Element.isNull())
|
||||
continue;
|
||||
DIE *ElemDie = NULL;
|
||||
if (Element.getTag() == dwarf::DW_TAG_subprogram)
|
||||
if (Element.isSubprogram())
|
||||
ElemDie = createSubprogramDIE(DISubprogram(Element.getNode()));
|
||||
else if (Element.getTag() == dwarf::DW_TAG_auto_variable) {
|
||||
else if (Element.isVariable()) {
|
||||
DIVariable DV(Element.getNode());
|
||||
ElemDie = new DIE(dwarf::DW_TAG_variable);
|
||||
addString(ElemDie, dwarf::DW_AT_name, dwarf::DW_FORM_string,
|
||||
@ -959,8 +947,10 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||
addUInt(ElemDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
|
||||
addUInt(ElemDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
|
||||
addSourceLine(ElemDie, &DV);
|
||||
} else
|
||||
} else if (Element.isDerivedType())
|
||||
ElemDie = createMemberDIE(DIDerivedType(Element.getNode()));
|
||||
else
|
||||
continue;
|
||||
Buffer.addChild(ElemDie);
|
||||
}
|
||||
|
||||
@ -973,7 +963,7 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
|
||||
dwarf::DW_FORM_data1, RLang);
|
||||
|
||||
DICompositeType ContainingType = CTy.getContainingType();
|
||||
if (!ContainingType.isNull())
|
||||
if (DIDescriptor(ContainingType.getNode()).isCompositeType())
|
||||
addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
||||
getOrCreateTypeDIE(DIType(ContainingType.getNode())));
|
||||
break;
|
||||
@ -1051,11 +1041,11 @@ void DwarfDebug::constructArrayTypeDIE(DIE &Buffer,
|
||||
}
|
||||
|
||||
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
|
||||
DIE *DwarfDebug::constructEnumTypeDIE(DIEnumerator *ETy) {
|
||||
DIE *DwarfDebug::constructEnumTypeDIE(DIEnumerator ETy) {
|
||||
DIE *Enumerator = new DIE(dwarf::DW_TAG_enumerator);
|
||||
StringRef Name = ETy->getName();
|
||||
StringRef Name = ETy.getName();
|
||||
addString(Enumerator, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name);
|
||||
int64_t Value = ETy->getEnumValue();
|
||||
int64_t Value = ETy.getEnumValue();
|
||||
addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value);
|
||||
return Enumerator;
|
||||
}
|
||||
@ -1199,7 +1189,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
|
||||
DIArray Args = SPTy.getTypeArray();
|
||||
unsigned SPTag = SPTy.getTag();
|
||||
|
||||
if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type)
|
||||
if (Args.getNumElements() == 0 || SPTag != dwarf::DW_TAG_subroutine_type)
|
||||
addType(SPDie, SPTy);
|
||||
else
|
||||
addType(SPDie, DIType(Args.getElement(0).getNode()));
|
||||
@ -1282,11 +1272,9 @@ DbgScope *DwarfDebug::getUpdatedDbgScope(MDNode *N, const MachineInstr *MI,
|
||||
Parent->addScope(NScope);
|
||||
} else if (DIDescriptor(N).isLexicalBlock()) {
|
||||
DILexicalBlock DB(N);
|
||||
if (!DB.getContext().isNull()) {
|
||||
Parent = getUpdatedDbgScope(DB.getContext().getNode(), MI, InlinedAt);
|
||||
NScope->setParent(Parent);
|
||||
Parent->addScope(NScope);
|
||||
}
|
||||
Parent = getUpdatedDbgScope(DB.getContext().getNode(), MI, InlinedAt);
|
||||
NScope->setParent(Parent);
|
||||
Parent->addScope(NScope);
|
||||
}
|
||||
|
||||
NScope->setFirstInsn(MI);
|
||||
@ -1318,8 +1306,7 @@ DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) {
|
||||
if (Scope.isLexicalBlock()) {
|
||||
DILexicalBlock DB(N);
|
||||
DIDescriptor ParentDesc = DB.getContext();
|
||||
if (!ParentDesc.isNull())
|
||||
Parent = getOrCreateAbstractScope(ParentDesc.getNode());
|
||||
Parent = getOrCreateAbstractScope(ParentDesc.getNode());
|
||||
}
|
||||
|
||||
AScope = new DbgScope(Parent, DIDescriptor(N), NULL);
|
||||
@ -1422,10 +1409,9 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
|
||||
// Ignore empty scopes.
|
||||
if (StartID == EndID && StartID != 0)
|
||||
return NULL;
|
||||
|
||||
DIScope DS(Scope->getScopeNode());
|
||||
if (DS.isNull())
|
||||
if (!Scope->getScopeNode())
|
||||
return NULL;
|
||||
DIScope DS(Scope->getScopeNode());
|
||||
DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine);
|
||||
|
||||
DISubprogram InlinedSP = getDISubprogram(DS.getNode());
|
||||
@ -1547,15 +1533,12 @@ void DwarfDebug::addPubTypes(DISubprogram SP) {
|
||||
return;
|
||||
|
||||
DIArray Args = SPTy.getTypeArray();
|
||||
if (Args.isNull())
|
||||
return;
|
||||
|
||||
for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) {
|
||||
DIType ATy(Args.getElement(i).getNode());
|
||||
if (ATy.isNull())
|
||||
if (!ATy.isValid())
|
||||
continue;
|
||||
DICompositeType CATy = getDICompositeType(ATy);
|
||||
if (!CATy.isNull() && !CATy.getName().empty()) {
|
||||
if (DIDescriptor(CATy.getNode()).Verify() && !CATy.getName().empty()) {
|
||||
if (DIEEntry *Entry = ModuleCU->getDIEEntry(CATy.getNode()))
|
||||
ModuleCU->addGlobalType(CATy.getName(), Entry->getEntry());
|
||||
}
|
||||
@ -1564,26 +1547,24 @@ void DwarfDebug::addPubTypes(DISubprogram SP) {
|
||||
|
||||
/// constructScopeDIE - Construct a DIE for this scope.
|
||||
DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
|
||||
if (!Scope)
|
||||
return NULL;
|
||||
DIScope DS(Scope->getScopeNode());
|
||||
if (DS.isNull())
|
||||
return NULL;
|
||||
|
||||
DIE *ScopeDIE = NULL;
|
||||
if (Scope->getInlinedAt())
|
||||
ScopeDIE = constructInlinedScopeDIE(Scope);
|
||||
else if (DS.isSubprogram()) {
|
||||
if (Scope->isAbstractScope())
|
||||
ScopeDIE = ModuleCU->getDIE(DS.getNode());
|
||||
else
|
||||
ScopeDIE = updateSubprogramScopeDIE(DS.getNode());
|
||||
}
|
||||
else {
|
||||
ScopeDIE = constructLexicalScopeDIE(Scope);
|
||||
if (!ScopeDIE) return NULL;
|
||||
}
|
||||
|
||||
if (!Scope || !Scope->getScopeNode())
|
||||
return NULL;
|
||||
|
||||
DIScope DS(Scope->getScopeNode());
|
||||
DIE *ScopeDIE = NULL;
|
||||
if (Scope->getInlinedAt())
|
||||
ScopeDIE = constructInlinedScopeDIE(Scope);
|
||||
else if (DS.isSubprogram()) {
|
||||
if (Scope->isAbstractScope())
|
||||
ScopeDIE = ModuleCU->getDIE(DS.getNode());
|
||||
else
|
||||
ScopeDIE = updateSubprogramScopeDIE(DS.getNode());
|
||||
}
|
||||
else {
|
||||
ScopeDIE = constructLexicalScopeDIE(Scope);
|
||||
if (!ScopeDIE) return NULL;
|
||||
}
|
||||
|
||||
// Add variables to scope.
|
||||
SmallVector<DbgVariable *, 8> &Variables = Scope->getVariables();
|
||||
for (unsigned i = 0, N = Variables.size(); i < N; ++i) {
|
||||
@ -2069,7 +2050,6 @@ bool DwarfDebug::extractScopeInformation() {
|
||||
if (DL.isUnknown()) continue;
|
||||
DILocation DLT = MF->getDILocation(DL);
|
||||
DIScope DLTScope = DLT.getScope();
|
||||
if (DLTScope.isNull()) continue;
|
||||
// There is no need to create another DIE for compile unit. For all
|
||||
// other scopes, create one DbgScope now. This will be translated
|
||||
// into a scope DIE at the end.
|
||||
@ -2089,7 +2069,6 @@ bool DwarfDebug::extractScopeInformation() {
|
||||
if (DL.isUnknown()) continue;
|
||||
DILocation DLT = MF->getDILocation(DL);
|
||||
DIScope DLTScope = DLT.getScope();
|
||||
if (DLTScope.isNull()) continue;
|
||||
// There is no need to create another DIE for compile unit. For all
|
||||
// other scopes, create one DbgScope now. This will be translated
|
||||
// into a scope DIE at the end.
|
||||
@ -2168,7 +2147,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
|
||||
DILocation DLT = MF->getDILocation(FDL);
|
||||
unsigned LabelID = 0;
|
||||
DISubprogram SP = getDISubprogram(DLT.getScope().getNode());
|
||||
if (!SP.isNull())
|
||||
if (SP.Verify())
|
||||
LabelID = recordSourceLine(SP.getLineNumber(), 0,
|
||||
DLT.getScope().getNode());
|
||||
else
|
||||
|
@ -346,7 +346,7 @@ class DwarfDebug : public DwarfPrinter {
|
||||
DICompositeType *CTy);
|
||||
|
||||
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
|
||||
DIE *constructEnumTypeDIE(DIEnumerator *ETy);
|
||||
DIE *constructEnumTypeDIE(DIEnumerator ETy);
|
||||
|
||||
/// createGlobalVariableDIE - Create new DIE using GV.
|
||||
DIE *createGlobalVariableDIE(const DIGlobalVariable &GV);
|
||||
|
@ -1219,7 +1219,7 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||
DIScope Scope = DLT.getScope();
|
||||
OS << " dbg:";
|
||||
// Omit the directory, since it's usually long and uninteresting.
|
||||
if (!Scope.isNull())
|
||||
if (Scope.Verify())
|
||||
OS << Scope.getFilename();
|
||||
else
|
||||
OS << "<unknown>";
|
||||
|
@ -333,7 +333,7 @@ void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) {
|
||||
for (DebugInfoFinder::iterator I = DbgFinder.type_begin(),
|
||||
E = DbgFinder.type_end(); I != E; ++I) {
|
||||
DICompositeType CTy(*I);
|
||||
if (CTy.isNull())
|
||||
if (!CTy.Verify())
|
||||
continue;
|
||||
if (CTy.getTag() == dwarf::DW_TAG_union_type ||
|
||||
CTy.getTag() == dwarf::DW_TAG_structure_type ) {
|
||||
|
@ -336,14 +336,14 @@ ConstantFoldMappedInstruction(const Instruction *I) {
|
||||
|
||||
static MDNode *UpdateInlinedAtInfo(MDNode *InsnMD, MDNode *TheCallMD) {
|
||||
DILocation ILoc(InsnMD);
|
||||
if (ILoc.isNull()) return InsnMD;
|
||||
if (!ILoc.Verify()) return InsnMD;
|
||||
|
||||
DILocation CallLoc(TheCallMD);
|
||||
if (CallLoc.isNull()) return InsnMD;
|
||||
if (!CallLoc.Verify()) return InsnMD;
|
||||
|
||||
DILocation OrigLocation = ILoc.getOrigLocation();
|
||||
MDNode *NewLoc = TheCallMD;
|
||||
if (!OrigLocation.isNull())
|
||||
if (OrigLocation.Verify())
|
||||
NewLoc = UpdateInlinedAtInfo(OrigLocation.getNode(), TheCallMD);
|
||||
|
||||
Value *MDVs[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user