[PATCH] Option parsing: support case-insensitive option matching.
Hans Wennborg
hans at chromium.org
Fri Aug 23 08:49:30 PDT 2013
================
Comment at: lib/Option/OptTable.cpp:213
@@ -211,3 +212,3 @@
// Search for the first next option which could be a prefix.
Start = std::lower_bound(Start, End, Name.data());
----------------
I'm worried about how the sort order of the table interacts with case-insensitive options.
The option parser will do a binary search into the option table to find a matching option. If the option in the table is spelled in uppercase (e.g. Foo), but the user supplies a lower-case argument (e.g. foo), the binary search will go too far into the table, since f comes after F, and the option will not be found.
Maybe this can be fixed by making the sort order of the table based on case-insensitive comparison, and use a case-insensitive comparator for the binary search.
Or, if all options in a table are to be matched case-insensitively, maybe it would be easier to add that as a flag to the whole option table, assert that all options in the table are spelled in lower-case if that flag is true, and just transform arguments to lowercase when trying to match them?
http://llvm-reviews.chandlerc.com/D1485
More information about the llvm-commits
mailing list