[PATCH] D12347: [MC/AsmParser] Avoid setting MCSymbol.IsUsed

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 13:10:24 PDT 2015


What we normally do is:

foo(/*SetUsed*/ false);


On 26 August 2015 at 00:08, Vedant Kumar <vsk at apple.com> wrote:
> vsk added a comment.
>
> In http://reviews.llvm.org/D12347#232844, @compnerd wrote:
>
>> The various `false` parameters slightly muddle the code IMO, since they are for value accessors.
>
>
> We could save the IsUsed state and restore it before the MCSymbol leaves scope. E.g;
>
>   bool IsUsed = Sym->isUsed();
>   if (expect_defined)
>     TheCondState.CondMet = (Sym && !Sym->isUndefined());
>   else
>     TheCondState.CondMet = (!Sym || Sym->isUndefined());
>   Sym->setUsed(IsUsed);
>
> Alternatively we could make a separate set of read-only accessors: `isUndefinedRO`, `getVariableValueRO`, ... (with a better name).
>
> Is there an approach you'd prefer?
>
>
> http://reviews.llvm.org/D12347
>
>
>


More information about the llvm-commits mailing list