Skip to content

Commit 9072577

Browse files
committed
[NFC] Add release notes and address review comments
Signed-off-by: yronglin <[email protected]>
1 parent b5117ef commit 9072577

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ Code Completion
216216
Static Analyzer
217217
---------------
218218

219+
- Clang currently support extending lifetime of object bound to
220+
reference members of aggregates in CFG and ExprEngine, that are
221+
created from default member initializer.
222+
219223
New features
220224
^^^^^^^^^^^^
221225

clang/lib/Analysis/ReachableCode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ bool DeadCodeScan::isDeadCodeRoot(const clang::CFGBlock *Block) {
457457
// Check if the given `DeadStmt` is one of target statements or is a sub-stmt of
458458
// them. `Block` is the CFGBlock containing the `DeadStmt`.
459459
template <class... Ts>
460-
static bool isDeadSubStmtInOneOf(const Stmt *DeadStmt, const CFGBlock *Block) {
460+
static bool isDeadStmtInOneOf(const Stmt *DeadStmt, const CFGBlock *Block) {
461461
// The coroutine statement, co_return, co_await, or co_yield.
462462
const Stmt *TargetStmt = nullptr;
463463
// Find the first coroutine statement after the DeadStmt in the block.
@@ -503,8 +503,8 @@ static bool isValidDeadStmt(const Stmt *S, const clang::CFGBlock *Block) {
503503
// If the dead stmt is a sub-stmt of CXXDefaultInitExpr and CXXDefaultArgExpr,
504504
// we would rather expect to find CXXDefaultInitExpr and CXXDefaultArgExpr as
505505
// a valid dead stmt.
506-
return !isDeadSubStmtInOneOf<CoreturnStmt, CoroutineSuspendExpr,
507-
CXXDefaultArgExpr, CXXDefaultInitExpr>(S, Block);
506+
return !isDeadStmtInOneOf<CoreturnStmt, CoroutineSuspendExpr,
507+
CXXDefaultArgExpr, CXXDefaultInitExpr>(S, Block);
508508
}
509509

510510
const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5570,7 +5570,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
55705570
/*SkipImmediateInvocations=*/NestedDefaultChecking))
55715571
return ExprError();
55725572

5573-
Expr *RewrittenExpr = Init == Param->getDefaultArg() ? nullptr : Init;
5573+
Expr *RewrittenExpr = (Init == Param->getDefaultArg() ? nullptr : Init);
55745574
return CXXDefaultArgExpr::Create(Context, InitializationContext->Loc, Param,
55755575
RewrittenExpr,
55765576
InitializationContext->Context);

clang/test/Analysis/lifetime-extended-regions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void aggregateWithReferences() {
121121
clang_analyzer_dump(viaReference.rx); // expected-warning-re {{&lifetime_extended_object{int, viaReference, S{{[0-9]+}}} }}
122122
clang_analyzer_dump(viaReference.ry); // expected-warning-re {{&lifetime_extended_object{Composite, viaReference, S{{[0-9]+}}} }}
123123

124-
// The lifetime lifetime of object bound to reference members of aggregates,
124+
// The lifetime of object bound to reference members of aggregates,
125125
// that are created from default member initializer was extended.
126126
RefAggregate defaultInitExtended{i};
127127
clang_analyzer_dump(defaultInitExtended.ry); // expected-warning-re {{&lifetime_extended_object{Composite, defaultInitExtended, S{{[0-9]+}}} }}

0 commit comments

Comments
 (0)