[PATCH] Option parsing: support case-insensitive option matching.

Hans Wennborg hans at chromium.org
Mon Aug 26 14:00:08 PDT 2013


  Looks good to me, just a few comments.

  > This is a modified patch. With this patch, all options are ordered in a case-insensitive manner in the tablegen-generated file, and the binary search in OptTable.cpp is done in a case-insensitive manner too.

  Yeah, that should work.

  > This may slightly decrease the performance of the option matching, but I think it is negligible because it's not in a hot path or anything.

  Sure, I don't think that's any problem. Also, now we can support /help being case-insensitive in clang-cl :)


================
Comment at: lib/Option/OptTable.cpp:16
@@ -15,2 +15,3 @@
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Debug.h"
 #include <algorithm>
----------------
I don't think this is used?

================
Comment at: lib/Option/OptTable.cpp:19
@@ -17,2 +18,3 @@
 #include <map>
+#include <cctype>
 
----------------
sort order

================
Comment at: lib/Option/OptTable.cpp:174
@@ -172,1 +173,3 @@
 
+// Returns true if X starts with Y, ignoreing case.
+static bool startsWithIgnoreCase(StringRef X, StringRef Y) {
----------------
s/ignoreing/ignoring/

================
Comment at: utils/TableGen/OptParserEmitter.cpp:24
@@ -20,1 +23,3 @@
+// lib/Option/OptTable.cpp.
 static int StrCmpOptionName(const char *A, const char *B) {
+  const char *X = A, *Y = B;
----------------
should we extract this function and put it in OptionTable.h so it can be defined only once?


http://llvm-reviews.chandlerc.com/D1485



More information about the llvm-commits mailing list