[llvm] r220926 - llvm-cov: Very basic top level help

Eric Christopher echristo at gmail.com
Thu Oct 30 13:52:12 PDT 2014


>
>
> +/// \brief Top level help.
> +int help_main(int argc, const char **argv) {
>

Naming convention...

Though I've just noticed the entire file doesn't follow it so... feel free
to rename? :)

-eric


> +  errs() << "OVERVIEW: LLVM code coverage tool\n\n"
> +         << "USAGE: llvm-cov {gcov|report|show}\n";
> +  return 0;
>


> +}
> +
>  int main(int argc, const char **argv) {
>    // If argv[0] is or ends with 'gcov', always be gcov compatible
>    if (sys::path::stem(argv[0]).endswith_lower("gcov"))
> @@ -37,17 +45,15 @@ int main(int argc, const char **argv) {
>
>    // Check if we are invoking a specific tool command.
>    if (argc > 1) {
> -    int (*func)(int, const char **) = nullptr;
> -
> -    StringRef command = argv[1];
> -    if (command.equals_lower("show"))
> -      func = show_main;
> -    else if (command.equals_lower("report"))
> -      func = report_main;
> -    else if (command.equals_lower("convert-for-testing"))
> -      func = convert_for_testing_main;
> -    else if (command.equals_lower("gcov"))
> -      func = gcov_main;
> +    typedef int (*MainFunction)(int, const char **);
> +    MainFunction func =
> +        StringSwitch<MainFunction>(argv[1])
> +            .Case("convert-for-testing", convert_for_testing_main)
> +            .Case("gcov", gcov_main)
> +            .Case("report", report_main)
> +            .Case("show", show_main)
> +            .Cases("-h", "-help", "--help", help_main)
> +            .Default(nullptr);
>
>      if (func) {
>        std::string Invocation = std::string(argv[0]) + " " + argv[1];
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141030/42036cc5/attachment.html>


More information about the llvm-commits mailing list