[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 3 09:08:00 PDT 2020


aaron.ballman added a comment.

In D70265#1954925 <https://reviews.llvm.org/D70265#1954925>, @vingeldal wrote:

> After looking more closely at the code I think the issue is within hasLocalStorage() which is called in hasGlobalStorage(). My expectation would be that anything inside of function scope would be considered local but I'm not very certain.
>  Any thoughts on whether hasLocalStorage() should be modified or if I should change the check and use some more ad-hoc implementation, instead of hasGlobalStorage(), to determine if the variable is local or global?


Not everything at function scope has local storage -- for instance, a variable declared with `static` or `extern` at local scope would not have local storage (storage != scope). `isLocalVarDeclOrParm()` or `isLocalVarDecl()` may help you out here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265





More information about the cfe-commits mailing list