OSDN Git Service

DbgVariable: Add an accessor for the common case of a single expression
authorAdrian Prantl <aprantl@apple.com>
Wed, 17 Feb 2016 22:19:59 +0000 (22:19 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 17 Feb 2016 22:19:59 +0000 (22:19 +0000)
belonging to a single DBG_VALUE instruction.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261167 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h

index 9dd5040..5febd9f 100644 (file)
@@ -771,8 +771,7 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
                                          const MachineLocation &Location) {
   DIELoc *Loc = new (DIEValueAllocator) DIELoc;
   DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
-  assert(DV.getExpression().size() == 1);
-  const DIExpression *Expr = DV.getExpression().back();
+  const DIExpression *Expr = DV.getSingleExpression();
   bool ValidReg;
   if (Location.getOffset()) {
     ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(),
index 31303e4..f0859ec 100644 (file)
@@ -111,6 +111,10 @@ public:
   const DILocalVariable *getVariable() const { return Var; }
   const DILocation *getInlinedAt() const { return IA; }
   ArrayRef<const DIExpression *> getExpression() const { return Expr; }
+  const DIExpression *getSingleExpression() const {
+    assert(MInsn && Expr.size() <= 1);
+    return Expr.size() ? Expr[0] : nullptr;
+  }
   void setDIE(DIE &D) { TheDIE = &D; }
   DIE *getDIE() const { return TheDIE; }
   void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }