-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Open
Labels
clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
Description
std::string_view f1(std::string_view a) {
return a;
}
std::string_view f2(std::string_view a) {
return f1(a);
}
std::string_view ff(std::string_view a) {
std::string stack = "something on stack";
return f2(stack); // warning: return-stack-addr
}Along with annotation suggestions, we can also implicitly add lifetime annotation so that these annotations can be visible to functions which are parsed later. This allows to infer annotations for complete function call stacks (where the definitions are available).
The effectiveness of this also depends on the order of definitions processed by clang. For example, if f2 was analysed before f1, we cannot infer annotation for f2 and there also cannot detect the return-stack-addr. An ideal solution would be to analyse the function at the end of TU in topological order (callee then caller).
Metadata
Metadata
Assignees
Labels
clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
Type
Projects
Status
No status