[PATCH] D77461: [clang-tidy] Remove false positive in AvoidNonConstGlobalVariables

Kim Viggedal via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 4 07:56:22 PDT 2020


vingeldal added a comment.
Herald added a subscriber: wuzish.

After looking in to it I got less certain of where the error lies and eventually I got uncertain if this even is a false negative, so I started out with just posting a change where the unit test is updated to detect the issue.
This is just to have a start for a discussion of how this should actually work and what is the best way forward.

The purpose of the rule is to avoid code which causes hidden dependencies. The given example of a potential false positive is a free function with a static variable.
Now, wouldn't a static variable inside a function body make the function stateful thereby risking that the function gives different results for the same input, in ways that might look arbitrary or random to the caller.
I think that might actually be a good example of what the rule is meant to prevent so maybe this isn't a false positive after all?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77461





More information about the cfe-commits mailing list