[PATCH] Fix uninitialized warning in llvm/lib/IR/DataLayout.cpp

Cameron McInally cameron.mcinally at nyu.edu
Mon Jan 13 10:20:26 PST 2014


Hey Rafael,

In what directory should such a test be placed?

I looked around and thought that tests/Bitcode would be a good place
(patch attached), but I am not that familiar with LLVM's test suite.

Tia,
Cameron

On Wed, Jan 8, 2014 at 11:45 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> On 8 January 2014 10:48, Cameron McInally <cameron.mcinally at nyu.edu> wrote:
>> Rafael,
>>
>> Is this patch what you had in mind?
>
> Yes. LGTM with a test :-)
>
> Thanks,
> Rafael
-------------- next part --------------
Index: test/Bitcode/getInt.ll
===================================================================
--- test/Bitcode/getInt.ll	(revision 0)
+++ test/Bitcode/getInt.ll	(revision 0)
@@ -0,0 +1,4 @@
+; RUN: opt < %s 
+; XFAIL: * 
+
+target datalayout = "p:4294967296:64:64"
Index: lib/IR/DataLayout.cpp
===================================================================
--- lib/IR/DataLayout.cpp	(revision 199118)
+++ lib/IR/DataLayout.cpp	(working copy)
@@ -207,9 +207,10 @@
 
 /// Get an unsigned integer, including error checks.
 static unsigned getInt(StringRef R) {
-  unsigned Result = 0;
+  unsigned Result;
   bool error = R.getAsInteger(10, Result); (void)error;
-  assert(!error && "not a number, or does not fit in an unsigned int");
+  if (error)
+    report_fatal_error("not a number, or does not fit in an unsigned int");
   return Result;
 }
 


More information about the llvm-commits mailing list