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

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 21:08:07 PDT 2015


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