[PATCH] D13620: Documentation for "Throw by value, catch by reference" check in clang-tidy

Tobias Langner via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 23:54:07 PDT 2015


randomcppprogrammer created this revision.
randomcppprogrammer added reviewers: aaron.ballman, cfe-commits.

adds documentation for the check mentioned in the title

http://reviews.llvm.org/D13620

Files:
  docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

Index: docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
===================================================================
--- /dev/null
+++ docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
@@ -0,0 +1,11 @@
+misc-throw-by-value-catch-by-reference
+======================================
+
+Finds violations of the rule "Throw by value, catch by reference" presented for example in "C++ Coding Standards" by H. Sutter and A. Alexandrescu. This check also has the option to find violations of the rule "Throw anonymous temporaries" (https://www.securecoding.cert.org/confluence/display/cplusplus/ERR09-CPP.+Throw+anonymous+temporaries). The option is named "CheckThrowTemporaries" and it's on by default.
+
+Exceptions:
+- throwing string literals will not be flagged despite being a pointer. They are not susceptible to slicing and the usage of string literals is idomatic.
+- catching character pointers (char, wchar_t, unicode character types) will not be flagged to allow catching sting literals.
+- moved named values will not be flagged as not throwing an anonymous temporary. In this case we can be sure that the user knows that the object can't be accessed outside catch blocks handling the error.
+- throwing function parameters will not be flagged as not throwing an anonymous temporary. This allows helper functions for throwing.
+- re-throwing caught exception variables will not be flragged as not throwing an anonymous temporary. Although this can usually be done by just writing "throw;" it happens often enough in real code.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13620.37026.patch
Type: text/x-patch
Size: 1574 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151010/2cf03c9d/attachment.bin>


More information about the cfe-commits mailing list