Skip to content

Commit 9a2999d

Browse files
committed
remove tmp file
1 parent b56631a commit 9a2999d

11 files changed

+41
-39
lines changed

a-84635e71.o.tmp

Whitespace-only changes.

a-9a215dcd.o.tmp

Whitespace-only changes.

a-d85fccc7.o.tmp

Whitespace-only changes.

a-f0f01220.o.tmp

Whitespace-only changes.

clang/lib/Sema/CheckExprLifetime.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
14751475
/*RevisitSubinits=*/!InitEntity);
14761476
}
14771477

1478-
void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
1478+
void checkInitLifetime(Sema &SemaRef, const InitializedEntity &Entity,
14791479
Expr *Init) {
14801480
auto LTResult = getEntityLifetime(&Entity);
14811481
LifetimeKind LK = LTResult.getInt();
@@ -1490,8 +1490,8 @@ void checkExprLifetimeMustTailArg(Sema &SemaRef,
14901490
/*AEntity=*/nullptr, /*CapEntity=*/nullptr, Init);
14911491
}
14921492

1493-
void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity,
1494-
Expr *Init) {
1493+
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity,
1494+
Expr *Init) {
14951495
bool EnableDanglingPointerAssignment = !SemaRef.getDiagnostics().isIgnored(
14961496
diag::warn_dangling_pointer_assignment, SourceLocation());
14971497
bool RunAnalysis = (EnableDanglingPointerAssignment &&
@@ -1506,8 +1506,8 @@ void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity,
15061506
/*CapEntity=*/nullptr, Init);
15071507
}
15081508

1509-
void checkExprLifetime(Sema &SemaRef, const CapturingEntity &Entity,
1510-
Expr *Init) {
1509+
void checkCaptureByLifetime(Sema &SemaRef, const CapturingEntity &Entity,
1510+
Expr *Init) {
15111511
return checkExprLifetimeImpl(SemaRef, /*InitEntity=*/nullptr,
15121512
/*ExtendingEntity=*/nullptr, LK_LifetimeCapture,
15131513
/*AEntity=*/nullptr,

clang/lib/Sema/CheckExprLifetime.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ struct CapturingEntity {
4040
/// Check that the lifetime of the given expr (and its subobjects) is
4141
/// sufficient for initializing the entity, and perform lifetime extension
4242
/// (when permitted) if not.
43-
void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
43+
void checkInitLifetime(Sema &SemaRef, const InitializedEntity &Entity,
4444
Expr *Init);
4545

4646
/// Check that the lifetime of the given expr (and its subobjects) is
4747
/// sufficient for assigning to the entity.
48-
void checkExprLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init);
48+
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity,
49+
Expr *Init);
4950

50-
void checkExprLifetime(Sema &SemaRef, const CapturingEntity &Entity,
51-
Expr *Init);
51+
void checkCaptureByLifetime(Sema &SemaRef, const CapturingEntity &Entity,
52+
Expr *Init);
5253

5354
/// Check that the lifetime of the given expr (and its subobjects) is
5455
/// sufficient, assuming that it is passed as an argument to a musttail

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3252,7 +3252,7 @@ void Sema::checkLifetimeCaptureBy(FunctionDecl *FD, bool IsMemberFunction,
32523252
Expr *Capturing = const_cast<Expr *>(GetArgAt(CapturingParamIdx));
32533253
CapturingEntity CE{Capturing};
32543254
// Ensure that 'Captured' outlives the 'Capturing' entity.
3255-
checkExprLifetime(*this, CE, Captured);
3255+
checkCaptureByLifetime(*this, CE, Captured);
32563256
}
32573257
};
32583258
for (unsigned I = 0; I < FD->getNumParams(); ++I)

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13822,7 +13822,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
1382213822
CheckForNullPointerDereference(*this, LHSExpr);
1382313823

1382413824
AssignedEntity AE{LHSExpr};
13825-
checkExprLifetime(*this, AE, RHS.get());
13825+
checkAssignmentLifetime(*this, AE, RHS.get());
1382613826

1382713827
if (getLangOpts().CPlusPlus20 && LHSType.isVolatileQualified()) {
1382813828
if (CompoundType.isNull()) {

clang/lib/Sema/SemaInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7404,7 +7404,7 @@ PerformConstructorInitialization(Sema &S,
74047404

74057405
void Sema::checkInitializerLifetime(const InitializedEntity &Entity,
74067406
Expr *Init) {
7407-
return sema::checkExprLifetime(*this, Entity, Init);
7407+
return sema::checkInitLifetime(*this, Entity, Init);
74087408
}
74097409

74107410
static void DiagnoseNarrowingInInitList(Sema &S,

clang/lib/Sema/SemaOverload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14811,7 +14811,7 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
1481114811
// Check for a self move.
1481214812
DiagnoseSelfMove(Args[0], Args[1], OpLoc);
1481314813
// lifetime check.
14814-
checkExprLifetime(
14814+
checkAssignmentLifetime(
1481514815
*this, AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
1481614816
Args[1]);
1481714817
}

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

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void noCaptureStringView(std::string_view sv, X &x);
2323
void captureString(const std::string &s [[clang::lifetime_capture_by(x)]], X &x);
2424
void captureRValString(std::string &&s [[clang::lifetime_capture_by(x)]], X &x);
2525

26+
// Return reference to the argument through lifetimebound.
2627
const std::string& getLB(const std::string &s [[clang::lifetimebound]]);
2728
const std::string& getLB(std::string_view sv [[clang::lifetimebound]]);
2829
const std::string* getPointerLB(const std::string &s [[clang::lifetimebound]]);
@@ -167,45 +168,45 @@ MyStringViewNotPointer getMySVNotP();
167168

168169
void container_of_pointers() {
169170
std::string local;
170-
MyVector<std::string> vs;
171-
vs.push_back(std::string()); // Ok.
171+
MyVector<std::string> vector_of_string;
172+
vector_of_string.push_back(std::string()); // Ok.
172173

173-
MyVector<std::string_view> vsv;
174-
vsv.push_back(std::string()); // expected-warning {{object whose reference is captured by 'vsv'}}
175-
vsv.push_back(substr(std::string())); // expected-warning {{object whose reference is captured by 'vsv'}}
174+
MyVector<std::string_view> vector_of_view;
175+
vector_of_view.push_back(std::string()); // expected-warning {{object whose reference is captured by 'vector_of_view'}}
176+
vector_of_view.push_back(substr(std::string())); // expected-warning {{captured}}
176177

177-
MyVector<const std::string*> vp;
178-
vp.push_back(getPointerLB(std::string())); // expected-warning {{object whose reference is captured by 'vp'}}
179-
vp.push_back(getPointerLB(*getPointerLB(std::string()))); // expected-warning {{object whose reference is captured by 'vp'}}
180-
vp.push_back(getPointerLB(local));
181-
vp.push_back(getPointerNoLB(std::string()));
178+
MyVector<const std::string*> vector_of_pointer;
179+
vector_of_pointer.push_back(getPointerLB(std::string())); // expected-warning {{captured}}
180+
vector_of_pointer.push_back(getPointerLB(*getPointerLB(std::string()))); // expected-warning {{captured}}
181+
vector_of_pointer.push_back(getPointerLB(local));
182+
vector_of_pointer.push_back(getPointerNoLB(std::string()));
182183

183184
// User-defined [[gsl::Pointer]]
184-
vsv.push_back(getMySV());
185-
vsv.push_back(getMySVNotP());
185+
vector_of_view.push_back(getMySV());
186+
vector_of_view.push_back(getMySVNotP());
186187

187188
// Vector of user defined gsl::Pointer.
188-
MyVector<MyStringView> vmysv;
189-
vmysv.push_back(getMySV());
190-
vmysv.push_back(MyStringView{});
191-
vmysv.push_back(std::string_view{});
192-
vmysv.push_back(std::string{}); // expected-warning {{object whose reference is captured by 'vmysv'}}
193-
vmysv.push_back(substr(std::string{})); // expected-warning {{object whose reference is captured by 'vmysv'}}
194-
vmysv.push_back(getLB(substr(std::string{}))); // expected-warning {{object whose reference is captured by 'vmysv'}}
195-
vmysv.push_back(strcopy(getLB(substr(std::string{}))));
189+
MyVector<MyStringView> vector_of_my_view;
190+
vector_of_my_view.push_back(getMySV());
191+
vector_of_my_view.push_back(MyStringView{});
192+
vector_of_my_view.push_back(std::string_view{});
193+
vector_of_my_view.push_back(std::string{}); // expected-warning {{object whose reference is captured by 'vector_of_my_view'}}
194+
vector_of_my_view.push_back(substr(std::string{})); // expected-warning {{captured}}
195+
vector_of_my_view.push_back(getLB(substr(std::string{}))); // expected-warning {{captured}}
196+
vector_of_my_view.push_back(strcopy(getLB(substr(std::string{}))));
196197

197198
// With std::optional container.
198-
std::optional<std::string_view> optionalSV;
199-
vsv.push_back(optionalSV.value());
200-
vsv.push_back(getOptionalS().value()); // expected-warning {{object whose reference is captured by 'vsv'}}
199+
std::optional<std::string_view> optional_of_view;
200+
vector_of_view.push_back(optional_of_view.value());
201+
vector_of_view.push_back(getOptionalS().value()); // expected-warning {{captured}}
201202

202203
// FIXME: Following 2 cases are false positives:
203-
vsv.push_back(getOptionalSV().value()); // expected-warning {{object whose reference}}
204-
vsv.push_back(getOptionalMySV().value()); // expected-warning {{object whose reference}}
204+
vector_of_view.push_back(getOptionalSV().value()); // expected-warning {{captured}}
205+
vector_of_view.push_back(getOptionalMySV().value()); // expected-warning {{captured}}
205206

206207
// (maybe) FIXME: We may choose to diagnose the following case.
207208
// This happens because 'MyStringViewNotPointer' is not marked as a [[gsl::Pointer]] but is derived from one.
208-
vsv.push_back(getOptionalMySVNotP().value()); // expected-warning {{object whose reference is captured by 'vsv'}}
209+
vector_of_view.push_back(getOptionalMySVNotP().value()); // expected-warning {{captured}}
209210
}
210211

211212
namespace temporary_views {

0 commit comments

Comments
 (0)