[patch] Make it explicit that nulls are not allowed in names

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Nov 18 06:09:46 PST 2013


ping

On 14 November 2013 08:33, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>>> The object files we support use null terminated strings, so there is
>>> no way to support these.
>>>
>>> This patch adds an assert to catch bad API use and an error check in
>>> the .ll parser.
>>
>> I think this would be better as part of the IR Verifier than in setName(), but the idea is sensible.
>
> I can move it there, but why? My rule of the thumb has been that
> invariants that are only true at the end of pass are checked in the
> Verifier. Invariants that are always true are checked on
> constructors/setters.
>
> For example, the GlobalVariable constructor has
>
>  if (InitVal) {
>     assert(InitVal->getType() == Ty &&
>            "Initializer should be the same type as the GlobalVariable!");
>
> If someone is passing an initializer, they should be able to get the
> type right at construction time. On the other hand, the verifier is
> the one that checks that if there is no initializer
>
>     Assert1(GV.hasExternalLinkage() || GV.hasDLLImportLinkage() ||
>             GV.hasExternalWeakLinkage(),
>             "invalid linkage type for global .declaration", &GV);
>
> The reason being that it is convenient in some cases to create a
> variable without an initializer and then set it, so this invariant is
> invalid at construction time.
>
> Cheers,
> Rafael




More information about the llvm-commits mailing list