diff options
| author | Alexander Kornienko <alexfh@google.com> | 2017-06-02 17:36:32 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2017-06-02 17:36:32 +0000 |
| commit | d9a4491b0a05a70733a80622d29a49d79210622a (patch) | |
| tree | f4cb0a552e8a0096874142cf045bc67ee1bf07cb /clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst | |
| parent | cdb5dad4cc4039e357c0437d9789b0353a989565 (diff) | |
| download | bcm5719-llvm-d9a4491b0a05a70733a80622d29a49d79210622a.tar.gz bcm5719-llvm-d9a4491b0a05a70733a80622d29a49d79210622a.zip | |
[clang-tidy] check for __func__/__FUNCTION__ in lambdas
Add a clang-tidy check for using func__/FUNCTION__ inside lambdas. This
evaluates to the string operator(), which is almost never useful and almost
certainly not what the author intended.
Patch by Bryce Liu!
Differential Revision: https://reviews.llvm.org/D33497
llvm-svn: 304570
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst')
| -rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst new file mode 100644 index 00000000000..1ab584c1411 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/misc-lambda-function-name.rst @@ -0,0 +1,27 @@ +.. title:: clang-tidy - misc-lambda-function-name + +misc-lambda-function-name +========================= + +Checks for attempts to get the name of a function from within a lambda +expression. The name of a lambda is always something like ``operator()``, which +is almost never what was intended. + +Example: + +.. code-block:: c++ + + void FancyFunction() { + [] { printf("Called from %s\n", __func__); }(); + [] { printf("Now called from %s\n", __FUNCTION__); }(); + } + +Output:: + + Called from operator() + Now called from operator() + +Likely intended output:: + + Called from FancyFunction + Now called from FancyFunction |

