[PATCH] D124556: [NFC] Prevent shadowing a variable declared in `if`

Ken Matsui via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 05:46:42 PDT 2022


ken-matsui added a comment.

@hubert.reinterpretcast,

Sorry to have missed providing a summary.

In most cases, shadowing a declaration of a local variable should be avoided to prevent making others confused and mistakes because we need to figure out the boundaries of the declaration. In this case, the variable declared by `const char *S` in `if` can be accessed by every branch. That means that declarations in `else if` had shadowed the declaration in `if`, so I changed them to use the same declaration used in `if`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124556/new/

https://reviews.llvm.org/D124556



More information about the cfe-commits mailing list