This is an archive of the discontinued LLVM Phabricator instance.

Remove all variants of DWARFDie::getAttributeValueAs...() that had parameters that specified default values.
ClosedPublic

Authored by clayborg on Jan 11 2017, 9:41 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

clayborg updated this revision to Diff 83994.Jan 11 2017, 9:41 AM
clayborg retitled this revision from to Remove all variants of DWARFDie::getAttributeValueAs...() that had parameters that specified default values..
clayborg updated this object.
dblaikie accepted this revision.Jan 11 2017, 9:49 AM
dblaikie edited edge metadata.
dblaikie added inline comments.
unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
276–278 ↗(On Diff #83994)

Looks like all of these could use op* instead:

EXPECT_EQ(Data1, *DieDG.getAttributeValueAsUnsignedConstant(Attr_DW_Form_data1));

Since they'll fail if the value isn't present anyway - granted, using getValueOr means they fail elegantly (with an EXPECT fail, which also allows the test to continue on to the other EXPECTS rather than assert-failing and halting immediately) & to fail in a well defined way even in non-asserts builds. But I don't think that's too important relative to the likelyhood of those failure modes.

(also, switching the arguments around probably produces better failures - the expected value is the first parameter, the value under test should be the second parameter (if I recall correctly, at least - you may want to double check the documentation for EXPECT_*))

This revision is now accepted and ready to land.Jan 11 2017, 9:49 AM

I will leave the tests using getValueOr() for now as I would like it to fail nicely so we can get a complete snapshot of what is failing instead of crashing on any failure and not knowing how many others tests would fail. I will read up on EXPECT_* and make a separate change for switching arg order if needed.

This revision was automatically updated to reflect the committed changes.