From 8552e22b076fbd2f53793ef57de392f4f42696a5 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 7 Aug 2013 01:18:33 +0000 Subject: 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 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp') 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 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 &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(V) && "String requested. Not a string."); - DIEString *S = cast(V); - return S->getString(); - } - } + DIEValue *V = Die->findAttribute(Attr); + + if (DIEString *S = dyn_cast_or_null(V)) + return S->getString(); + return StringRef(""); } -- cgit v1.2.3