diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-04-07 18:21:47 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-04-07 18:21:47 +0000 |
commit | b2a7c062aaebc98be4ee315868dee24a17a198d0 (patch) | |
tree | f65eb5a9fca368d66bf5f89532fb7e0547960e9a /clang/lib/Driver/OptTable.cpp | |
parent | 84d573f256342bb509bddea6f04836c469c68831 (diff) | |
download | bcm5719-llvm-b2a7c062aaebc98be4ee315868dee24a17a198d0.tar.gz bcm5719-llvm-b2a7c062aaebc98be4ee315868dee24a17a198d0.zip |
Driver: Fix a parsing bug where some options were matched
incorrectly. I'm blanking on the smartest way to write this search,
but we should just do the right thing when we move to TableGen.
- <rdar://problem/6761194> [driver] -Wextra-tokens isn't parsed
correctly
llvm-svn: 68525
Diffstat (limited to 'clang/lib/Driver/OptTable.cpp')
-rw-r--r-- | clang/lib/Driver/OptTable.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/Driver/OptTable.cpp b/clang/lib/Driver/OptTable.cpp index 15b121c45b1..cbbeea1974c 100644 --- a/clang/lib/Driver/OptTable.cpp +++ b/clang/lib/Driver/OptTable.cpp @@ -230,19 +230,26 @@ Arg *OptTable::ParseOneArg(const InputArgList &Args, unsigned &Index) const { struct Info *Start = OptionInfos + FirstSearchableOption - 1; struct Info *End = OptionInfos + LastOption - 1; - // Find the first option which could be a prefix. + // Search for the first next option which could be a prefix. Start = std::lower_bound(Start, End, Str); - // Scan for first option which is a proper prefix. - for (; Start != End; ++Start) - if (memcmp(Str, Start->Name, strlen(Start->Name)) == 0) - break; - - // Look for a match until we don't have a prefix. + // Options are stored in sorted order, with '\0' at the end of the + // alphabet. Since the only options which can accept a string must + // prefix it, we iteratively search for the next option which could + // be a prefix. + // + // FIXME: This is searching much more than necessary, but I am + // blanking on the simplest way to make it fast. We can solve this + // problem when we move to TableGen. for (; Start != End; ++Start) { - if (memcmp(Start->Name, Str, strlen(Start->Name)) != 0) + // Scan for first option which is a proper prefix. + for (; Start != End; ++Start) + if (memcmp(Str, Start->Name, strlen(Start->Name)) == 0) + break; + if (Start == End) break; + // See if this option matches. options::ID id = (options::ID) (Start - OptionInfos + 1); if (Arg *A = getOption(id)->accept(Args, Index)) return A; |