Skip to content

Commit b9a26fe

Browse files
Abseil Teamcopybara-github
authored andcommitted
Add ABSL_ATTRIBUTE_LIFETIME_BOUND to Flag help generator
Since this method is only called by `NonConst` which immediately converts it to a `std::string`, this is currently safe. Add annotation nevertheless to show the contract. This currently makes the majority of lifetime annotation suggestion provided by the lifetime analysis https://godbolt.org/z/hKvrE1hG1 PiperOrigin-RevId: 843275432 Change-Id: Ib1a0513eca944a9c7c4c612c3111bf05881c746d
1 parent ba9fa8c commit b9a26fe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

absl/flags/flag.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ ABSL_NAMESPACE_END
241241
/* default value argument. That keeps temporaries alive */ \
242242
/* long enough for NonConst to work correctly. */ \
243243
static constexpr absl::string_view Value( \
244-
absl::string_view absl_flag_help = ABSL_FLAG_IMPL_FLAGHELP(txt)) { \
244+
absl::string_view absl_flag_help ABSL_ATTRIBUTE_LIFETIME_BOUND = \
245+
ABSL_FLAG_IMPL_FLAGHELP(txt)) { \
245246
return absl_flag_help; \
246247
} \
247248
static std::string NonConst() { return std::string(Value()); } \

0 commit comments

Comments
 (0)