-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
#include <string_view>
class S {
std::string_view a, b;
};
void foo() {
S* ptr;
{
S s;
ptr = &s;
}
(void)ptr;
}
We do not have destructor calls and therefore no expiry facts for the loans created.
CFG and LifetimeFacts
[B2 (ENTRY)]
Succs (1): B1
[B1]
1: S *ptr;
2: (CXXConstructExpr, S)
3: S s;
4: s
5: &[B1.4]
6: ptr
7: [B1.6] = [B1.5]
8: ptr
9: (void)[B1.8] (CStyleCastExpr, ToVoid, void)
Preds (1): B2
Succs (1): B0
[B0 (EXIT)]
Preds (1): B1
==========================================
Lifetime Analysis Facts:
==========================================
Function: foo
Block B2:
End of Block
Block B1:
Issue (0 (Path: s), ToOrigin: 0 (Expr: DeclRefExpr))
OriginFlow (Dest: 1 (Expr: UnaryOperator), Src: 0 (Expr: DeclRefExpr))
Use (2 (Decl: ptr), Write)
OriginFlow (Dest: 2 (Decl: ptr), Src: 1 (Expr: UnaryOperator))
Use (2 (Decl: ptr), Read)
End of Block
Block B0:
End of Block
Compiler returned: 0
We can use AddLifetime
to make CFG add lifetime related events where destructor calls are not in the CFG.
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