Added AST matcher for ignoring elidable move constructors
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 6455 ↗ | (On Diff #204097) | 80 columns |
| 6455 ↗ | (On Diff #204097) | It would help if you described why a user would want to skip the elidable constructor using this matcher rather than hardcoding the presence of such an AST node. |
| 6457 ↗ | (On Diff #204097) | I'd suggest to rephrase the example using the "Given:" format (see other comments around), and wrap the code to 80 columns. |
| clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | ||
| 575 ↗ | (On Diff #204097) | Can you run these tests in both C++14 and C++17 modes? |
| 628 ↗ | (On Diff #204097) | Need a space before the open brace, and indentation in the function body (in every test). |
| 631 ↗ | (On Diff #204097) | Please clang-format. |
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 6455 ↗ | (On Diff #204229) | "Matches expressions that match InnerMatcher that are possibly wrapped in an elidable constructor." Then a blank line, and the rest of the explanation. |
| 6458 ↗ | (On Diff #204229) | part of the AST in C++14 and earlier. |
| 6460 ↗ | (On Diff #204229) | Therefore, to write a matcher that works in all language modes, the matcher has to skip elidable constructor AST nodes if they appear in the AST. |
| 6467 ↗ | (On Diff #204229) | Can this sample be simplified? For example, B does not need to be a template (I think), and f() can be simplified to not call B twice. |
| clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | ||
| 628 ↗ | (On Diff #204097) | Not done? I was talking about the code in the code snippet. |
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 6477 ↗ | (On Diff #204229) | Is the matcher only strict to move constructor? looks like the matcher implementation is for general constructors, just ignoringElidableConstructorCall? we may have elidable copy constructor. |
| 6479 ↗ | (On Diff #204229) | nit: LLVM uses CamelCase style. |
| 6486 ↗ | (On Diff #204229) | I think this return is unnecessary, since we will fall through at line 6489. |
- Using CamelCase and also renamed ignoringElidableMoveConstructorCall to ignoringElidableConstructorCall
- Added match conditionally overload to control in what language standard a match should run in
| clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | ||
|---|---|---|
| 600 ↗ | (On Diff #204277) | Please inline the variables that are used once. |
| clang/unittests/ASTMatchers/ASTMatchersTest.h | ||
| 61 ↗ | (On Diff #204277) | Please drop the explicit values. |
| 64 ↗ | (On Diff #204277) | 2a |
| 68 ↗ | (On Diff #204277) | "2a" (we don't know the year yet) |
| 144 ↗ | (On Diff #204277) | 80 columns. |
| 154 ↗ | (On Diff #204277) | No need for semicolon. |
| 157 ↗ | (On Diff #204277) | I'd say it is too clever, and suggest to write an explicit switch. |
looks most good to me, a few nits.
| clang/include/clang/ASTMatchers/ASTMatchers.h | ||
|---|---|---|
| 6488 ↗ | (On Diff #204442) | This return statement is not needed. |
| clang/unittests/ASTMatchers/ASTMatchersTest.h | ||
| 16 ↗ | (On Diff #204442) | looks like the include is not used? |
| 153 ↗ | (On Diff #204442) | nit: add a llvm_unreachable for default. |
| 177 ↗ | (On Diff #204442) | nit: no {} needed for a single-statement body. |
thanks, looks good to me. I'll commit for you. @gribozavr do you want to take another look on the patch?
| clang/unittests/ASTMatchers/ASTMatchersTest.h | ||
|---|---|---|
| 153 ↗ | (On Diff #204442) | this is not done? |
| clang/unittests/ASTMatchers/ASTMatchersTest.h | ||
|---|---|---|
| 153 ↗ | (On Diff #204442) | But the switch covers all enum values so that would give warnings |