summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2015-11-08 21:10:39 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2015-11-08 21:10:39 +0000
commiteeb71758cc32933863a8f165c1a63c517fd9283a (patch)
tree470284cd44e5ecce4db918dd097e91ccb265cc19 /clang-tools-extra/docs
parentf85ad0411f1dcec5a1da1958c2663a50e8c2748b (diff)
downloadbcm5719-llvm-eeb71758cc32933863a8f165c1a63c517fd9283a.tar.gz
bcm5719-llvm-eeb71758cc32933863a8f165c1a63c517fd9283a.zip
[clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast
Summary: This check flags all use of c-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast. Use of these casts can violate type safety and cause the program to access a variable that is actually of type X to be accessed as if it were of an unrelated type Z. Note that a C-style (T)expression cast means to perform the first of the following that is possible: a const_cast, a static_cast, a static_cast followed by a const_cast, a reinterpret_cast, or a reinterpret_cast followed by a const_cast. This rule bans (T)expression only when used to perform an unsafe cast. This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type4-dont-use-c-style-texpression-casts-that-would-perform-a-static_cast-downcast-const_cast-or-reinterpret_cast. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14096 llvm-svn: 252425
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst15
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst1
2 files changed, 16 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
new file mode 100644
index 00000000000..900c1a1b404
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
@@ -0,0 +1,15 @@
+cppcoreguidelines-pro-type-cstyle-cast
+======================================
+
+This check flags all use of C-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast.
+
+Use of these casts can violate type safety and cause the program to access a
+variable that is actually of type X to be accessed as if it were of an
+unrelated type Z. Note that a C-style (T)expression cast means to perform
+the first of the following that is possible: a const_cast, a static_cast, a
+static_cast followed by a const_cast, a reinterpret_cast, or a
+reinterpret_cast followed by a const_cast. This rule bans (T)expression
+only when used to perform an unsafe cast.
+
+This rule is part of the "Type safety" profile of the C++ Core Guidelines, see
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type4-dont-use-c-style-texpression-casts-that-would-perform-a-static_cast-downcast-const_cast-or-reinterpret_cast.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 3551abced3e..b492b927c31 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -7,6 +7,7 @@ List of clang-tidy Checks
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-pointer-arithmetic
cppcoreguidelines-pro-type-const-cast
+ cppcoreguidelines-pro-type-cstyle-cast
cppcoreguidelines-pro-type-reinterpret-cast
cppcoreguidelines-pro-type-static-cast-downcast
cppcoreguidelines-pro-type-union-access
OpenPOWER on IntegriCloud