[llvm-commits] [llvm] r155653 - /llvm/trunk/lib/Support/YAMLParser.cpp

James Molloy james.molloy at arm.com
Fri Apr 27 01:01:46 PDT 2012


Hi Michael,

+          if (UnquotedValue.substr(1, 2).getAsInteger(16,
UnicodeScalarValue))
+            // TODO: Report error.
+            UnicodeScalarValue = 0xFFFD;

I know there's a TODO there, but in the meantime it would be nice to explain
what U+FFFD actually means in the comment - you've mentioned it in the
commit message but not in the code :)

Cheers,

James

-----Original Message-----
From: llvm-commits-bounces at cs.uiuc.edu
[mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Michael J. Spencer
Sent: 26 April 2012 20:27
To: llvm-commits at cs.uiuc.edu
Subject: [llvm-commits] [llvm] r155653 -
/llvm/trunk/lib/Support/YAMLParser.cpp

Author: mspencer
Date: Thu Apr 26 14:27:11 2012
New Revision: 155653

URL: http://llvm.org/viewvc/llvm-project?rev=155653&view=rev
Log:
[Support/YAML] Properly fix unitialized variable warning by inserting a
'REPLACEMENT CHARACTER' (U+FFFD) when getAsInteger fails.

Modified:
    llvm/trunk/lib/Support/YAMLParser.cpp

Modified: llvm/trunk/lib/Support/YAMLParser.cpp
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?re
v=155653&r1=155652&r2=155653&view=diff
============================================================================
==
--- llvm/trunk/lib/Support/YAMLParser.cpp (original)
+++ llvm/trunk/lib/Support/YAMLParser.cpp Thu Apr 26 14:27:11 2012
@@ -1732,8 +1732,10 @@
           if (UnquotedValue.size() < 3)
             // TODO: Report error.
             break;
-          unsigned int UnicodeScalarValue = 0;
-          UnquotedValue.substr(1, 2).getAsInteger(16, UnicodeScalarValue);
+          unsigned int UnicodeScalarValue;
+          if (UnquotedValue.substr(1, 2).getAsInteger(16,
UnicodeScalarValue))
+            // TODO: Report error.
+            UnicodeScalarValue = 0xFFFD;
           encodeUTF8(UnicodeScalarValue, Storage);
           UnquotedValue = UnquotedValue.substr(2);
           break;
@@ -1742,8 +1744,10 @@
           if (UnquotedValue.size() < 5)
             // TODO: Report error.
             break;
-          unsigned int UnicodeScalarValue = 0;
-          UnquotedValue.substr(1, 4).getAsInteger(16, UnicodeScalarValue);
+          unsigned int UnicodeScalarValue;
+          if (UnquotedValue.substr(1, 4).getAsInteger(16,
UnicodeScalarValue))
+            // TODO: Report error.
+            UnicodeScalarValue = 0xFFFD;
           encodeUTF8(UnicodeScalarValue, Storage);
           UnquotedValue = UnquotedValue.substr(4);
           break;
@@ -1752,8 +1756,10 @@
           if (UnquotedValue.size() < 9)
             // TODO: Report error.
             break;
-          unsigned int UnicodeScalarValue = 0;
-          UnquotedValue.substr(1, 8).getAsInteger(16, UnicodeScalarValue);
+          unsigned int UnicodeScalarValue;
+          if (UnquotedValue.substr(1, 8).getAsInteger(16,
UnicodeScalarValue))
+            // TODO: Report error.
+            UnicodeScalarValue = 0xFFFD;
           encodeUTF8(UnicodeScalarValue, Storage);
           UnquotedValue = UnquotedValue.substr(8);
           break;


_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits








More information about the llvm-commits mailing list