Skip to content

Commit cfe3362

Browse files
committed
update docs
1 parent feedd49 commit cfe3362

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4008,6 +4008,22 @@ The attribute supports specifying more than one capturing entities:
40084008
s2.insert(a);
40094009
}
40104010

4011+
Limitation: The capturing entity ``X`` is not used by the analysis and is
4012+
used for documentation purposes only. This is because the analysis is
4013+
statement-local and only detects use of a temporary as an argument to the
4014+
annotated parameter.
4015+
4016+
.. code-block:: c++
4017+
4018+
void addToSet(std::string_view a [[clang::lifetime_capture_by(s)]], std::set<std::string_view>& s);
4019+
void use() {
4020+
std::set<std::string_view> s;
4021+
if (foo()) {
4022+
std::string str;
4023+
addToSet(str, s); // Not detected.
4024+
}
4025+
}
4026+
40114027
.. _`lifetimebound`: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
40124028
}];
40134029
}

clang/test/Sema/warn-lifetime-analysis-capture-by.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
#include "Inputs/lifetime-analysis.h"
44

5-
struct X {
6-
const int *x;
7-
};
5+
struct X {} x;
86
X x;
97

108
// ****************************************************************************

0 commit comments

Comments
 (0)