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

llvm-svn: 261167

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

index 9dd5040ce81e4faf01639c28f05eca193e93f53d..5febd9fb380652ba9fe47ae7d0c14db5b7ef43ef 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 31303e4ba38307ee381994810d189fae1ca2f310..f0859ec1a8fe0e087b07728d2ad4a3cc4607adb6 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; }