forked from OSchip/llvm-project
Debug Info: code cleanup, use getNodeField if possible.
Use getNodeField to access a field as a MDNode. No functionality change. llvm-svn: 186985
This commit is contained in:
parent
3d2ac2e41a
commit
4b0df00016
|
@ -74,10 +74,8 @@ static Value *getField(const MDNode *DbgNode, unsigned Elt) {
|
||||||
return DbgNode->getOperand(Elt);
|
return DbgNode->getOperand(Elt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const MDNode *getNodeField(const MDNode *DbgNode, unsigned Elt) {
|
static MDNode *getNodeField(const MDNode *DbgNode, unsigned Elt) {
|
||||||
if (const MDNode *R = dyn_cast_or_null<MDNode>(getField(DbgNode, Elt)))
|
return dyn_cast_or_null<MDNode>(getField(DbgNode, Elt));
|
||||||
return R;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringRef getStringField(const MDNode *DbgNode, unsigned Elt) {
|
static StringRef getStringField(const MDNode *DbgNode, unsigned Elt) {
|
||||||
|
@ -115,13 +113,8 @@ int64_t DIDescriptor::getInt64Field(unsigned Elt) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
|
DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
|
||||||
if (DbgNode == 0)
|
MDNode *Field = getNodeField(DbgNode, Elt);
|
||||||
return DIDescriptor();
|
return DIDescriptor(Field);
|
||||||
|
|
||||||
if (Elt < DbgNode->getNumOperands())
|
|
||||||
return
|
|
||||||
DIDescriptor(dyn_cast_or_null<const MDNode>(DbgNode->getOperand(Elt)));
|
|
||||||
return DIDescriptor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
|
GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
|
||||||
|
@ -167,7 +160,7 @@ unsigned DIVariable::getNumAddrElements() const {
|
||||||
|
|
||||||
/// getInlinedAt - If this variable is inlined then return inline location.
|
/// getInlinedAt - If this variable is inlined then return inline location.
|
||||||
MDNode *DIVariable::getInlinedAt() const {
|
MDNode *DIVariable::getInlinedAt() const {
|
||||||
return dyn_cast_or_null<MDNode>(DbgNode->getOperand(7));
|
return getNodeField(DbgNode, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -534,7 +527,7 @@ bool DINameSpace::Verify() const {
|
||||||
|
|
||||||
/// \brief Retrieve the MDNode for the directory/file pair.
|
/// \brief Retrieve the MDNode for the directory/file pair.
|
||||||
MDNode *DIFile::getFileNode() const {
|
MDNode *DIFile::getFileNode() const {
|
||||||
return const_cast<MDNode*>(getNodeField(DbgNode, 1));
|
return getNodeField(DbgNode, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Verify that the file descriptor is well formed.
|
/// \brief Verify that the file descriptor is well formed.
|
||||||
|
@ -609,9 +602,7 @@ uint64_t DIDerivedType::getOriginalTypeSize() const {
|
||||||
|
|
||||||
/// getObjCProperty - Return property node, if this ivar is associated with one.
|
/// getObjCProperty - Return property node, if this ivar is associated with one.
|
||||||
MDNode *DIDerivedType::getObjCProperty() const {
|
MDNode *DIDerivedType::getObjCProperty() const {
|
||||||
if (DbgNode->getNumOperands() <= 10)
|
return getNodeField(DbgNode, 10);
|
||||||
return NULL;
|
|
||||||
return dyn_cast_or_null<MDNode>(DbgNode->getOperand(10));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Set the array of member DITypes.
|
/// \brief Set the array of member DITypes.
|
||||||
|
@ -666,15 +657,11 @@ unsigned DISubprogram::isOptimized() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
MDNode *DISubprogram::getVariablesNodes() const {
|
MDNode *DISubprogram::getVariablesNodes() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() <= 18)
|
return getNodeField(DbgNode, 18);
|
||||||
return NULL;
|
|
||||||
return dyn_cast_or_null<MDNode>(DbgNode->getOperand(18));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DIArray DISubprogram::getVariables() const {
|
DIArray DISubprogram::getVariables() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() <= 18)
|
if (MDNode *T = getNodeField(DbgNode, 18))
|
||||||
return DIArray();
|
|
||||||
if (MDNode *T = dyn_cast_or_null<MDNode>(DbgNode->getOperand(18)))
|
|
||||||
return DIArray(T);
|
return DIArray(T);
|
||||||
return DIArray();
|
return DIArray();
|
||||||
}
|
}
|
||||||
|
@ -687,7 +674,7 @@ void DIScope::setFilename(StringRef Name, LLVMContext &Context) {
|
||||||
if (!DbgNode)
|
if (!DbgNode)
|
||||||
return;
|
return;
|
||||||
MDString *MDName(MDString::get(Context, Name));
|
MDString *MDName(MDString::get(Context, Name));
|
||||||
const_cast<MDNode*>(getNodeField(DbgNode, 1))->replaceOperandWith(0, MDName);
|
getNodeField(DbgNode, 1)->replaceOperandWith(0, MDName);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef DIScope::getFilename() const {
|
StringRef DIScope::getFilename() const {
|
||||||
|
@ -706,7 +693,7 @@ DIArray DICompileUnit::getEnumTypes() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
||||||
return DIArray();
|
return DIArray();
|
||||||
|
|
||||||
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(7)))
|
if (MDNode *N = getNodeField(DbgNode, 7))
|
||||||
return DIArray(N);
|
return DIArray(N);
|
||||||
return DIArray();
|
return DIArray();
|
||||||
}
|
}
|
||||||
|
@ -715,7 +702,7 @@ DIArray DICompileUnit::getRetainedTypes() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
||||||
return DIArray();
|
return DIArray();
|
||||||
|
|
||||||
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(8)))
|
if (MDNode *N = getNodeField(DbgNode, 8))
|
||||||
return DIArray(N);
|
return DIArray(N);
|
||||||
return DIArray();
|
return DIArray();
|
||||||
}
|
}
|
||||||
|
@ -724,7 +711,7 @@ DIArray DICompileUnit::getSubprograms() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
||||||
return DIArray();
|
return DIArray();
|
||||||
|
|
||||||
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(9)))
|
if (MDNode *N = getNodeField(DbgNode, 9))
|
||||||
return DIArray(N);
|
return DIArray(N);
|
||||||
return DIArray();
|
return DIArray();
|
||||||
}
|
}
|
||||||
|
@ -734,7 +721,7 @@ DIArray DICompileUnit::getGlobalVariables() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
||||||
return DIArray();
|
return DIArray();
|
||||||
|
|
||||||
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(10)))
|
if (MDNode *N = getNodeField(DbgNode, 10))
|
||||||
return DIArray(N);
|
return DIArray(N);
|
||||||
return DIArray();
|
return DIArray();
|
||||||
}
|
}
|
||||||
|
@ -743,7 +730,7 @@ DIArray DICompileUnit::getImportedEntities() const {
|
||||||
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
if (!DbgNode || DbgNode->getNumOperands() < 13)
|
||||||
return DIArray();
|
return DIArray();
|
||||||
|
|
||||||
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(11)))
|
if (MDNode *N = getNodeField(DbgNode, 11))
|
||||||
return DIArray(N);
|
return DIArray(N);
|
||||||
return DIArray();
|
return DIArray();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue