<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 5, 2015, at 6:17 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com" class="">aaron@aaronballman.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Wed, Mar 4, 2015 at 5:07 PM, Frederic Riss <</span><a href="mailto:friss@apple.com" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">friss@apple.com</a><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> wrote:</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Author: friss<br class="">Date: Wed Mar  4 16:07:41 2015<br class="">New Revision: 231299<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=231299&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=231299&view=rev</a><br class="">Log:<br class="">DWARFFormValue: Add getAsSignedConstant method.<br class=""><br class="">The implementation accepts explicitely signed forms (DW_FORM_sdata),<br class="">but also unsigned forms as long as they fit in an int64_t.<br class=""><br class="">Modified:<br class="">   llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h<br class="">   llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp<br class="">   llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp<br class=""><br class="">Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=231299&r1=231298&r2=231299&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h?rev=231299&r1=231298&r2=231299&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h (original)<br class="">+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFFormValue.h Wed Mar  4 16:07:41 2015<br class="">@@ -74,6 +74,7 @@ public:<br class="">  /// DWARFFormValue has form class is suitable for representing Foo.<br class="">  Optional<uint64_t> getAsReference(const DWARFUnit *U) const;<br class="">  Optional<uint64_t> getAsUnsignedConstant() const;<br class="">+  Optional<int64_t> getAsSignedConstant() const;<br class="">  Optional<const char *> getAsCString(const DWARFUnit *U) const;<br class="">  Optional<uint64_t> getAsAddress(const DWARFUnit *U) const;<br class="">  Optional<uint64_t> getAsSectionOffset() const;<br class=""><br class="">Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=231299&r1=231298&r2=231299&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=231299&r1=231298&r2=231299&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)<br class="">+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Wed Mar  4 16:07:41 2015<br class="">@@ -18,6 +18,7 @@<br class="">#include "llvm/Support/Format.h"<br class="">#include "llvm/Support/raw_ostream.h"<br class="">#include <cassert><br class="">+#include <climits><br class="">using namespace llvm;<br class="">using namespace dwarf;<br class="">using namespace syntax;<br class="">@@ -557,6 +558,24 @@ Optional<uint64_t> DWARFFormValue::getAs<br class="">  return Value.uval;<br class="">}<br class=""><br class="">+Optional<int64_t> DWARFFormValue::getAsSignedConstant() const {<br class="">+  if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) ||<br class="">+      (Form == DW_FORM_udata && uint64_t(LLONG_MAX) < Value.uval))<br class="">+    return None;<br class="">+  switch (Form) {<br class="">+  case DW_FORM_data4:<br class="">+    return int32_t(Value.uval);<br class="">+  case DW_FORM_data2:<br class="">+    return int16_t(Value.uval);<br class="">+  case DW_FORM_data1:<br class="">+    return int8_t(Value.uval);<br class="">+  case DW_FORM_sdata:<br class="">+  case DW_FORM_data8:<br class="">+  default:<br class="">+    return Value.sval;<br class="">+  }<br class="">+}<br class="">+<br class="">Optional<ArrayRef<uint8_t>> DWARFFormValue::getAsBlock() const {<br class="">  if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc))<br class="">    return None;<br class=""><br class="">Modified: llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp?rev=231299&r1=231298&r2=231299&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp?rev=231299&r1=231298&r2=231299&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp (original)<br class="">+++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp Wed Mar  4 16:07:41 2015<br class="">@@ -8,7 +8,10 @@<br class="">//===----------------------------------------------------------------------===//<br class=""><br class="">#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"<br class="">+#include "llvm/ADT/SmallString.h"<br class="">#include "llvm/Support/Dwarf.h"<br class="">+#include "llvm/Support/LEB128.h"<br class="">+#include "llvm/Support/Host.h"<br class="">#include "gtest/gtest.h"<br class="">using namespace llvm;<br class="">using namespace dwarf;<br class="">@@ -46,4 +49,75 @@ TEST(DWARFFormValue, FormClass) {<br class="">  EXPECT_TRUE(isFormClass(DW_FORM_ref_sig8, DWARFFormValue::FC_Reference));<br class="">}<br class=""><br class="">+template<typename RawTypeT><br class="">+DWARFFormValue createDataXFormValue(uint16_t Form, RawTypeT Value) {<br class="">+  char Raw[sizeof(RawTypeT)];<br class="">+  memcpy(Raw, &Value, sizeof(RawTypeT));<br class="">+  uint32_t Offset = 0;<br class="">+  DWARFFormValue Result(Form);<br class="">+  DataExtractor Data(StringRef(Raw, sizeof(RawTypeT)),<br class="">+                     sys::IsLittleEndianHost, sizeof(void*));<br class="">+  Result.extractValue(Data, &Offset, nullptr);<br class="">+  return Result;<br class="">+}<br class="">+<br class="">+DWARFFormValue createULEBFormValue(uint64_t Value) {<br class="">+  SmallString<10> RawData;<br class="">+  raw_svector_ostream OS(RawData);<br class="">+  encodeULEB128(Value, OS);<br class="">+  uint32_t Offset = 0;<br class="">+  DWARFFormValue Result(DW_FORM_udata);<br class="">+  DataExtractor Data(OS.str(), sys::IsLittleEndianHost, sizeof(void*));<br class="">+  Result.extractValue(Data, &Offset, nullptr);<br class="">+  return Result;<br class="">+}<br class="">+<br class="">+DWARFFormValue createSLEBFormValue(int64_t Value) {<br class="">+  SmallString<10> RawData;<br class="">+  raw_svector_ostream OS(RawData);<br class="">+  encodeSLEB128(Value, OS);<br class="">+  uint32_t Offset = 0;<br class="">+  DWARFFormValue Result(DW_FORM_sdata);<br class="">+  DataExtractor Data(OS.str(), sys::IsLittleEndianHost, sizeof(void*));<br class="">+  Result.extractValue(Data, &Offset, nullptr);<br class="">+  return Result;<br class="">+}<br class="">+<br class="">+TEST(DWARFFormValue, SignedConstantForms) {<br class="">+  // Check that we correctly sign extend fixed size forms.<br class="">+  auto Sign1 = createDataXFormValue<uint8_t>(DW_FORM_data1, -123);<br class="">+  auto Sign2 = createDataXFormValue<uint16_t>(DW_FORM_data2, -12345);<br class="">+  auto Sign4 = createDataXFormValue<uint32_t>(DW_FORM_data4, -123456789);<br class="">+  auto Sign8 = createDataXFormValue<uint64_t>(DW_FORM_data8, -1);<br class="">+  EXPECT_EQ(Sign1.getAsSignedConstant().getValue(), -123);<br class="">+  EXPECT_EQ(Sign2.getAsSignedConstant().getValue(), -12345);<br class="">+  EXPECT_EQ(Sign4.getAsSignedConstant().getValue(), -123456789);<br class="">+  EXPECT_EQ(Sign8.getAsSignedConstant().getValue(), -1);<br class="">+<br class="">+  // Check that we can handle big positive values, but that we return<br class="">+  // an error just over the limit.<br class="">+  auto UMax = createULEBFormValue(LLONG_MAX);<br class="">+  auto TooBig = createULEBFormValue(LLONG_MAX + 1);<br class=""></blockquote><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">This test is now triggering:</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">DWARFFormValueTest.cpp: In member function ‘virtual void</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">{anonymous}::DWARFFormValue_SignedConstantForms_Test::TestBody()’:</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">DWARFFormValueTest.cpp:100:49: warning: integer overflow in expression</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">[-Woverflow]</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">We can silence this with casts, but I'm not certain if that alters</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">your test case to no longer test what you require.</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Thanks for the heads up. Should be fixed by r231368.</div><div>How come I didn’t see this, isn’t -Woverflow enabled by default?</div><div><br class=""></div><div>Fred</div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">~Aaron</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+  EXPECT_EQ(UMax.getAsSignedConstant().getValue(), LLONG_MAX);<br class="">+  EXPECT_EQ(TooBig.getAsSignedConstant().hasValue(), false);<br class="">+<br class="">+  // Sanity check some other forms.<br class="">+  auto Data1 = createDataXFormValue<uint8_t>(DW_FORM_data1, 120);<br class="">+  auto Data2 = createDataXFormValue<uint16_t>(DW_FORM_data2, 32000);<br class="">+  auto Data4 = createDataXFormValue<uint32_t>(DW_FORM_data4, 2000000000);<br class="">+  auto Data8 = createDataXFormValue<uint64_t>(DW_FORM_data8, 0x1234567812345678LL);<br class="">+  auto LEBMin = createSLEBFormValue(LLONG_MIN);<br class="">+  auto LEBMax = createSLEBFormValue(LLONG_MAX);<br class="">+  auto LEB1 = createSLEBFormValue(-42);<br class="">+  auto LEB2 = createSLEBFormValue(42);<br class="">+  EXPECT_EQ(Data1.getAsSignedConstant().getValue(), 120);<br class="">+  EXPECT_EQ(Data2.getAsSignedConstant().getValue(), 32000);<br class="">+  EXPECT_EQ(Data4.getAsSignedConstant().getValue(), 2000000000);<br class="">+  EXPECT_EQ(Data8.getAsSignedConstant().getValue(), 0x1234567812345678LL);<br class="">+  EXPECT_EQ(LEBMin.getAsSignedConstant().getValue(), LLONG_MIN);<br class="">+  EXPECT_EQ(LEBMax.getAsSignedConstant().getValue(), LLONG_MAX);<br class="">+  EXPECT_EQ(LEB1.getAsSignedConstant().getValue(), -42);<br class="">+  EXPECT_EQ(LEB2.getAsSignedConstant().getValue(), 42);<br class="">+}<br class="">+<br class="">} // end anonymous namespace<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</blockquote></div></blockquote></div><br class=""></body></html>