mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Add a way to grab a particular attribute out of a DIE.
Use it when we're looking for a string in particular. Update comments as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -966,21 +966,13 @@ void DwarfDebug::collectDeadVariables() {
|
||||
typedef ArrayRef<uint8_t> HashValue;
|
||||
|
||||
/// \brief Grabs the string in whichever attribute is passed in and returns
|
||||
/// a reference to it.
|
||||
/// a reference to it. Returns "" if the attribute doesn't exist.
|
||||
static StringRef getDIEStringAttr(DIE *Die, unsigned Attr) {
|
||||
const SmallVectorImpl<DIEValue *> &Values = Die->getValues();
|
||||
const DIEAbbrev &Abbrevs = Die->getAbbrev();
|
||||
DIEValue *V = Die->findAttribute(Attr);
|
||||
|
||||
if (DIEString *S = dyn_cast_or_null<DIEString>(V))
|
||||
return S->getString();
|
||||
|
||||
// Iterate through all the attributes until we find the one we're
|
||||
// looking for, if we can't find it return an empty string.
|
||||
for (size_t i = 0; i < Values.size(); ++i) {
|
||||
if (Abbrevs.getData()[i].getAttribute() == Attr) {
|
||||
DIEValue *V = Values[i];
|
||||
assert(isa<DIEString>(V) && "String requested. Not a string.");
|
||||
DIEString *S = cast<DIEString>(V);
|
||||
return S->getString();
|
||||
}
|
||||
}
|
||||
return StringRef("");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user