llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines
Matthias Gehre b785407c28 [clang-tidy] add check cppcoreguidelines-pro-type-union-access
Summary:
This check flags all access to members of unions. Passing unions as a
whole is not flagged.

Reading from a union member assumes that member was the last one
written, and writing to a union member assumes another member with a
nontrivial destructor had its destructor called. This is fragile because
it cannot generally be enforced to be safe in the language and so relies
on programmer discipline to get it right.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type7-avoid-accessing-members-of-raw-unions-prefer-variant-instead

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13784

llvm-svn: 250537
2015-10-16 18:46:30 +00:00
..
CMakeLists.txt [clang-tidy] add check cppcoreguidelines-pro-type-union-access 2015-10-16 18:46:30 +00:00
CppCoreGuidelinesTidyModule.cpp [clang-tidy] add check cppcoreguidelines-pro-type-union-access 2015-10-16 18:46:30 +00:00
Makefile
ProBoundsPointerArithmeticCheck.cpp [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic 2015-10-12 21:53:19 +00:00
ProBoundsPointerArithmeticCheck.h [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic 2015-10-12 21:53:19 +00:00
ProTypeConstCastCheck.cpp Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeConstCastCheck.h Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeReinterpretCastCheck.cpp Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeReinterpretCastCheck.h Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeStaticCastDowncastCheck.cpp [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast 2015-10-12 20:46:53 +00:00
ProTypeStaticCastDowncastCheck.h [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast 2015-10-12 20:46:53 +00:00
ProTypeUnionAccessCheck.cpp [clang-tidy] add check cppcoreguidelines-pro-type-union-access 2015-10-16 18:46:30 +00:00
ProTypeUnionAccessCheck.h [clang-tidy] add check cppcoreguidelines-pro-type-union-access 2015-10-16 18:46:30 +00:00