[PATCH] D54222: [clang-tidy/checks] Add a checker to detect returning static locals in public headers

Joe Ranieri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 7 12:55:09 PST 2018


jranieri-grammatech created this revision.
jranieri-grammatech added reviewers: aaron.ballman, alexfh, NoQ.
Herald added subscribers: cfe-commits, mgorny.

This adds a checker, llvm-problematic-statics, that detects functions in header files that return the address of a local static variable. These cause problems if the resulting pointer is expected to be unique because it may have different values across shared library boundaries.

It's has been a problem in the static analyzer that I've had to deal with in the past (https://reviews.llvm.org/D52905 and https://reviews.llvm.org/D52906).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54222

Files:
  clang-tidy/llvm/CMakeLists.txt
  clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tidy/llvm/ProblematicStaticsCheck.cpp
  clang-tidy/llvm/ProblematicStaticsCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/llvm-problematic-statics.rst
  test/clang-tidy/Inputs/Headers/include/ProblematicStatics.h
  test/clang-tidy/llvm-problematic-statics.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54222.173008.patch
Type: text/x-patch
Size: 6349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181107/bed75174/attachment.bin>


More information about the cfe-commits mailing list