Fix DIExpression::ExprOperand::appendToVector
authorVedant Kumar <vsk@apple.com>
Fri, 6 Jul 2018 21:06:21 +0000 (21:06 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 6 Jul 2018 21:06:21 +0000 (21:06 +0000)
appendToVector used the wrong overload of SmallVector::append, resulting
in it appending the same element to a vector `getSize()` times. This did
not cause a problem when initially committed because appendToVector was
only used to append 1-element operands.

This changes appendToVector to use the correct overload of append().

Testing: ./unittests/IR/IRTests --gtest_filter='*DIExpressionTest*'
llvm-svn: 336466

llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/IR/DebugInfoMetadata.cpp

index 3167e7a..d4815cf 100644 (file)
@@ -2329,7 +2329,7 @@ public:
 
     /// Append the elements of this operand to \p V.
     void appendToVector(SmallVectorImpl<uint64_t> &V) const {
-      V.append(getSize(), *get());
+      V.append(get(), get() + getSize());
     }
   };
 
index 54062e2..db28d9a 100644 (file)
@@ -834,9 +834,7 @@ DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
         StackValue = false;
       }
     }
-    Ops.push_back(Op.getOp());
-    for (unsigned I = 0; I < Op.getNumArgs(); ++I)
-      Ops.push_back(Op.getArg(I));
+    Op.appendToVector(Ops);
   }
   if (StackValue)
     Ops.push_back(dwarf::DW_OP_stack_value);
@@ -906,9 +904,7 @@ Optional<DIExpression *> DIExpression::createFragmentExpression(
         continue;
       }
       }
-      Ops.push_back(Op.getOp());
-      for (unsigned I = 0; I < Op.getNumArgs(); ++I)
-        Ops.push_back(Op.getArg(I));
+      Op.appendToVector(Ops);
     }
   }
   Ops.push_back(dwarf::DW_OP_LLVM_fragment);