[LLVMdev] error api for APInt / APFloat

Erick Tryzelaar idadesub at users.sourceforge.net
Wed Aug 19 23:29:01 PDT 2009


On Wed, Aug 19, 2009 at 11:24 PM, Chris Lattner<clattner at apple.com> wrote:
>
> You're right that anything can be declared to be a property the caller needs
> to enforce.  This makes it a muddy issue that boils down to a judgement call
> based on how low-level the API is and how complex the invariant is.
>
> Two examples:
>
> Since APInt is a very low level class, bitwidth is something clients can be
> expected to have to know about.
>
> Since detecting errors in floating point string literals basically requires
> parsing the whole string, so making clients enforce all the invariants would
> basically make a string literal parsing routine useless.  Something like
> 'parsing a string' is also inherently an operation that can fail if the
> input is malformed, so returning an error code makes sense.
>
> Does this rationale seem reasonable to you?

Sure, that sounds good. I'll put together a patch for returning error
codes for the string parsing, but leave the rest as asserts.




More information about the llvm-dev mailing list