summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-08-07 01:18:33 +0000
committerEric Christopher <echristo@gmail.com>2013-08-07 01:18:33 +0000
commit8552e22b076fbd2f53793ef57de392f4f42696a5 (patch)
tree23f4aaaf3717ff20e11de213cf231b2d8f6ce13e /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parentaf15f8dd5a4c73acb8fad42e5a5337b4b488f5ab (diff)
downloadbcm5719-llvm-8552e22b076fbd2f53793ef57de392f4f42696a5.tar.gz
bcm5719-llvm-8552e22b076fbd2f53793ef57de392f4f42696a5.zip
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. llvm-svn: 187844
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 859805c8181..9a09bc1b644 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -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();
-
- // 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();
- }
- }
+ DIEValue *V = Die->findAttribute(Attr);
+
+ if (DIEString *S = dyn_cast_or_null<DIEString>(V))
+ return S->getString();
+
return StringRef("");
}
OpenPOWER on IntegriCloud