Explicitly initialize dwarf::FormParams in DIEInteger::SizeOf
authorPavel Labath <labath@google.com>
Wed, 14 Mar 2018 11:14:43 +0000 (11:14 +0000)
committerPavel Labath <labath@google.com>
Wed, 14 Mar 2018 11:14:43 +0000 (11:14 +0000)
commit0dd81bab92f678ed16f80e4e0c2f55246b13c8b2
treea40c1789f2ca569bbe5eb488df7eb3480cf52e60
parenta511dddced88ccf9e42b39de1d1538e864728640
Explicitly initialize dwarf::FormParams in DIEInteger::SizeOf

This could end up inititialized if someone called the function with a
null AsmPrinter. Right now this only happens in DIEHash unit tests,
presumably because it was hard to create an AsmPrinter in the context of
unit tests. This only worked before r327486 because those tests did not
use any dwarf forms whose size actually depended on the dwarf version
(otherwise, they would have crashed due to null dereference).

I fix the uninitialized error, by explicitly initializing FormParams to
an invalid value, which will cause getFixedFormByteSize to return None
if called with a form with version-dependent size. A more principled
solution might be to fix the DIEHash tests to always pass in a valid
AsmPrinter.

llvm-svn: 327498
llvm/lib/CodeGen/AsmPrinter/DIE.cpp