[PATCH] D23130: Add a check for definitions in the global namespace.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 12:54:23 PDT 2016


bkramer created this revision.
bkramer added a reviewer: alexfh.
bkramer added a subscriber: cfe-commits.

This is prone to ODR violations and generally frowned upon in many
codebases (e.g. LLVM). The checker flags definitions, variables and
classes in the global namespace. Common false positives like extern "C"
functions are filtered, symbols with internal linkage or hidden
visibility are not warned on either.

On LLVM most of the instances are helper functions that should be just
made static or globals that belong into a namespace.

https://reviews.llvm.org/D23130

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/GlobalNamespaceCheck.cpp
  clang-tidy/misc/GlobalNamespaceCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-global-namespace.rst
  test/clang-tidy/misc-global-namespace.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23130.66696.patch
Type: text/x-patch
Size: 8267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160803/ad39f9cf/attachment.bin>


More information about the cfe-commits mailing list