[llvm-commits] [llvm] r67892 - in /llvm/trunk: include/llvm/Support/CommandLine.h lib/Support/CommandLine.cpp

Chris Lattner clattner at apple.com
Fri Mar 27 19:09:52 PDT 2009


Mike, who delete[]'s the string that is new'd in this code?

I would really really like to rip this out and move this logic to the  
clang driver.  Why should this exist?

-Chris

On Mar 27, 2009, at 7:08 PM, Chris Lattner wrote:

> Author: lattner
> Date: Fri Mar 27 21:08:47 2009
> New Revision: 67892
>
> URL: http://llvm.org/viewvc/llvm-project?rev=67892&view=rev
> Log:
> move a large method out of line.
>
> Modified:
>    llvm/trunk/include/llvm/Support/CommandLine.h
>    llvm/trunk/lib/Support/CommandLine.cpp
>
> Modified: llvm/trunk/include/llvm/Support/CommandLine.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=67892&r1=67891&r2=67892&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/include/llvm/Support/CommandLine.h (original)
> +++ llvm/trunk/include/llvm/Support/CommandLine.h Fri Mar 27  
> 21:08:47 2009
> @@ -540,22 +540,8 @@
>   bool IsInvertable;	// Should we synthezise a -xno- style option?
>   const char *ArgStr;
> public:
> -  void getExtraOptionNames(std::vector<const char*> &OptionNames) {
> -    if (IsInvertable) {
> -      char *s = new char [strlen(ArgStr) + 3 + 1];
> -      s[0] = ArgStr[0];
> -      if (strncmp(ArgStr+1, "no-", 3) == 0)
> -        strcpy(&s[1], &ArgStr[4]);
> -      else {
> -        s[1] = 'n';
> -        s[2] = 'o';
> -        s[3] = '-';
> -        strcpy(&s[4], ArgStr+1);
> -      }
> -      OptionNames.push_back(s);
> -    }
> -  }
> -
> +  void getExtraOptionNames(std::vector<const char*> &OptionNames);
> +
>   // parse - Return true on error.
>   bool parse(Option &O, const char *ArgName, const std::string &Arg,  
> bool &Val);
>
>
> Modified: llvm/trunk/lib/Support/CommandLine.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=67892&r1=67891&r2=67892&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Support/CommandLine.cpp (original)
> +++ llvm/trunk/lib/Support/CommandLine.cpp Fri Mar 27 21:08:47 2009
> @@ -877,6 +877,25 @@
>   return false;
> }
>
> +void parser<bool>::getExtraOptionNames(std::vector<const char*>  
> &OptionNames) {
> +  if (!IsInvertable)
> +    return;
> +
> +  char *s = new char [strlen(ArgStr) + 3 + 1];
> +  s[0] = ArgStr[0];
> +  if (strncmp(ArgStr+1, "no-", 3) == 0)
> +    strcpy(&s[1], &ArgStr[4]);
> +  else {
> +    s[1] = 'n';
> +    s[2] = 'o';
> +    s[3] = '-';
> +    strcpy(&s[4], ArgStr+1);
> +  }
> +  OptionNames.push_back(s);
> +}
> +
> +
> +
> // parser<boolOrDefault> implementation
> //
> bool parser<boolOrDefault>::parse(Option &O, const char *ArgName,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list