[cmake-developers] [PATCH 1/7] Refactor TargetTypeNames.

Peter Collingbourne peter at pcc.me.uk
Sun Oct 2 13:53:49 EDT 2011


On Tue, Sep 27, 2011 at 05:32:19PM +0200, Nicolas Desprès wrote:
> On Tue, Sep 27, 2011 at 3:55 PM, Rolf Eike Beer <eike at sf-mail.de> wrote:
> >> From: Nicolas Despres <nicolas.despres at gmail.com>
> >>
> >> Make it a static method instead of an array. It is safer for the
> >> type checking and if we add a new target type we will be warned to add
> >> a case to the switch.
> >
> >> +      case cmTarget::UNKNOWN_LIBRARY:
> >> +        return "UNKNOWN_LIBRARY";
> >> +        // break; /* unreachable */
> >> +    }
> >> +  return 0;
> >> +}
> >
> > Shouldn't this spit out a warning or error message?
> 
> Frankly I don't know. I just refactor the code and kept the same
> original behavior.

This function should not expect to be passed an invalid target type as
a parameter, especially since we are covering all of the enumerators.
I have modified this patch to add an assertion check that the end of
the function is unreachable.

While at it, I also removed the commented out break statements, which
are just noise.

The modified patch is now in my github branch.

Thanks,
-- 
Peter


More information about the cmake-developers mailing list