[llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Jun 28 10:48:01 PDT 2003


Changes in directory llvm/lib/Support:

CommandLine.cpp updated: 1.29 -> 1.30

---
Log message:

Add support for 'unsigned' command line arguments



---
Diffs of the changes:

Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.29 llvm/lib/Support/CommandLine.cpp:1.30
--- llvm/lib/Support/CommandLine.cpp:1.29	Thu May 22 15:26:17 2003
+++ llvm/lib/Support/CommandLine.cpp	Sat Jun 28 10:47:20 2003
@@ -575,11 +575,22 @@
 //
 bool parser<int>::parse(Option &O, const char *ArgName,
                         const std::string &Arg, int &Value) {
-  const char *ArgStart = Arg.c_str();
   char *End;
-  Value = (int)strtol(ArgStart, &End, 0);
+  Value = (int)strtol(Arg.c_str(), &End, 0);
   if (*End != 0) 
     return O.error(": '" + Arg + "' value invalid for integer argument!");
+  return false;
+}
+
+// parser<unsigned> implementation
+//
+bool parser<unsigned>::parse(Option &O, const char *ArgName,
+                             const std::string &Arg, unsigned &Value) {
+  char *End;
+  long long int V = strtoll(Arg.c_str(), &End, 0);
+  Value = (unsigned)V;
+  if (*End != 0 || V < 0 || Value != V) 
+    return O.error(": '" + Arg + "' value invalid for uint argument!");
   return false;
 }
 





More information about the llvm-commits mailing list