@@ -12597,6 +12597,12 @@ namespace {
12597
12597
bool isRecordType;
12598
12598
bool isPODType;
12599
12599
bool isReferenceType;
12600
+ // Tracks whether the current expression is being visited within a
12601
+ // CXXOperatorCallExpr. This flag is set to true when entering a
12602
+ // CXXOperatorCallExpr and reset to false upon exit. It is used to detect
12603
+ // when a LambdaExpr is an operand of an operator call, enabling special
12604
+ // handling of its capture initializations.
12605
+ bool isInCXXOperatorCall;
12600
12606
12601
12607
bool isInitList;
12602
12608
llvm::SmallVector<unsigned, 4> InitFieldIndex;
@@ -12609,6 +12615,7 @@ namespace {
12609
12615
isPODType = false;
12610
12616
isRecordType = false;
12611
12617
isReferenceType = false;
12618
+ isInCXXOperatorCall = false;
12612
12619
isInitList = false;
12613
12620
if (ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
12614
12621
isPODType = VD->getType().isPODType(S.Context);
@@ -12796,6 +12803,7 @@ namespace {
12796
12803
}
12797
12804
12798
12805
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
12806
+ isInCXXOperatorCall = true;
12799
12807
Expr *Callee = E->getCallee();
12800
12808
12801
12809
if (isa<UnresolvedLookupExpr>(Callee))
@@ -12804,6 +12812,20 @@ namespace {
12804
12812
Visit(Callee);
12805
12813
for (auto Arg: E->arguments())
12806
12814
HandleValue(Arg->IgnoreParenImpCasts());
12815
+ isInCXXOperatorCall = false;
12816
+ }
12817
+
12818
+ void VisitLambdaExpr(LambdaExpr *E) {
12819
+ if (isInCXXOperatorCall) {
12820
+ for (const auto &init : E->capture_inits()) {
12821
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(init))
12822
+ HandleDeclRefExpr(DRE);
12823
+ else
12824
+ Visit(init);
12825
+ }
12826
+ return;
12827
+ }
12828
+ Inherited::VisitLambdaExpr(E);
12807
12829
}
12808
12830
12809
12831
void VisitUnaryOperator(UnaryOperator *E) {
0 commit comments