| 150 | } |
| 151 | |
| 152 | static bool ParseOneFlag(const char *Param) { |
| 153 | if (Param[0] != '-') return false; |
| 154 | if (Param[1] == '-') { |
| 155 | static bool PrintedWarning = false; |
| 156 | if (!PrintedWarning) { |
| 157 | PrintedWarning = true; |
| 158 | Printf("INFO: libFuzzer ignores flags that start with '--'\n"); |
| 159 | } |
| 160 | for (size_t F = 0; F < kNumFlags; F++) |
| 161 | if (FlagValue(Param + 1, FlagDescriptions[F].Name)) |
| 162 | Printf("WARNING: did you mean '%s' (single dash)?\n", Param + 1); |
| 163 | return true; |
| 164 | } |
| 165 | for (size_t F = 0; F < kNumFlags; F++) { |
| 166 | const char *Name = FlagDescriptions[F].Name; |
| 167 | const char *Str = FlagValue(Param, Name); |
| 168 | if (Str) { |
| 169 | if (FlagDescriptions[F].IntFlag) { |
| 170 | auto Val = MyStol(Str); |
| 171 | *FlagDescriptions[F].IntFlag = static_cast<int>(Val); |
| 172 | if (Flags.verbosity >= 2) |
| 173 | Printf("Flag: %s %d\n", Name, Val); |
| 174 | return true; |
| 175 | } else if (FlagDescriptions[F].UIntFlag) { |
| 176 | auto Val = std::stoul(Str); |
| 177 | *FlagDescriptions[F].UIntFlag = static_cast<unsigned int>(Val); |
| 178 | if (Flags.verbosity >= 2) |
| 179 | Printf("Flag: %s %u\n", Name, Val); |
| 180 | return true; |
| 181 | } else if (FlagDescriptions[F].StrFlag) { |
| 182 | *FlagDescriptions[F].StrFlag = Str; |
| 183 | if (Flags.verbosity >= 2) |
| 184 | Printf("Flag: %s %s\n", Name, Str); |
| 185 | return true; |
| 186 | } else { // Deprecated flag. |
| 187 | Printf("Flag: %s: deprecated, don't use\n", Name); |
| 188 | return true; |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | Printf("\n\nWARNING: unrecognized flag '%s'; " |
| 193 | "use -help=1 to list all flags\n\n", Param); |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | // We don't use any library to minimize dependencies. |
| 198 | static void ParseFlags(const std::vector<std::string> &Args, |
no test coverage detected