This test provides test coverage for the following feature:
Variables which are captured by value into a lambda require a call to a
copy constructor.
Details
- Reviewers
 NoQ Szelethus baloghadamsoftware 
Diff Detail
- Repository
 - rG LLVM Github Monorepo
 - Build Status
 Buildable 40268 Build 40369: arc lint + arc unit 
Event Timeline
- Add capture by reference test
 - Add another class to ensure reachability inside function call is independent of each other in the first 2 test cases
 
- Remove link reference from commit message
 - Remove superfluous semicolons left in the code
 
I recommend starting with CFG tests for this feature. I.e., do -analyzer-checker debug.DumpCFG and make sure that every CFGStmt that corresponds to a constructor is a CFGConstructor (i.e., has a ConstructionContext explained in the dump). Cf. test/Analysis/cfg-rich-constructors.cpp.
| clang/test/Analysis/clangsa_unsupported_features/handle_constructors_for_lambda_captures.cpp | ||
|---|---|---|
| 12 | This test doesn't test whether the function is inlined. If the function is not inlined, the code will still be reachable when analyzed as top frame. See also clang_analyzer_checkInlined().  | |
| 30 | That's the reason why your tests seem to work. If you change it to ~incr_on_copy_for_simple_usage() {}, we will no longer evaluate the capture correctly. The difference here is that we allow ourselves inline the constructor without a construction context when the destructor is trivial. But when the destructor is non-trivial, our inability to keep track of the object under construction until destruction will have terrible consequences.  | |
| clang/test/Analysis/clangsa_unsupported_features/handle_constructors_for_lambda_captures.cpp | ||
|---|---|---|
| 30 | *allow ourselves to inline  | |
This test doesn't test whether the function is inlined. If the function is not inlined, the code will still be reachable when analyzed as top frame. See also clang_analyzer_checkInlined().