@@ -77,7 +77,9 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
77
77
SmallPtrSet<DeclRefExpr*, 4 > AlreadyDiagnosedBitCasts;
78
78
79
79
// / Keep track of the arguments to CallExprs.
80
- SmallPtrSet<Expr *, 2 > CallArgs;
80
+ // / Key -> an argument expression,
81
+ // / Value -> a call argument is associated with.
82
+ llvm::SmallDenseMap<Expr *, Expr *, 2 > CallArgs;
81
83
82
84
bool IsExprStmt;
83
85
@@ -141,30 +143,30 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
141
143
checkUseOfMetaTypeName (Base);
142
144
143
145
if (auto *OLE = dyn_cast<ObjectLiteralExpr>(E)) {
144
- CallArgs.insert (OLE->getArg ());
146
+ CallArgs.insert ({ OLE->getArg (), E} );
145
147
}
146
148
147
149
if (auto *SE = dyn_cast<SubscriptExpr>(E))
148
- CallArgs.insert (SE->getIndex ());
150
+ CallArgs.insert ({ SE->getIndex (), E} );
149
151
150
152
if (auto *DSE = dyn_cast<DynamicSubscriptExpr>(E))
151
- CallArgs.insert (DSE->getIndex ());
153
+ CallArgs.insert ({ DSE->getIndex (), E} );
152
154
153
155
if (auto *KPE = dyn_cast<KeyPathExpr>(E)) {
154
156
// raise an error if this KeyPath contains an effectful member.
155
157
checkForEffectfulKeyPath (KPE);
156
158
157
159
for (auto Comp : KPE->getComponents ()) {
158
160
if (auto *Arg = Comp.getIndexExpr ())
159
- CallArgs.insert (Arg);
161
+ CallArgs.insert ({ Arg, E} );
160
162
}
161
163
}
162
164
163
165
// Check function calls, looking through implicit conversions on the
164
166
// function and inspecting the arguments directly.
165
167
if (auto *Call = dyn_cast<ApplyExpr>(E)) {
166
168
// Record call arguments.
167
- CallArgs.insert (Call->getArg ());
169
+ CallArgs.insert ({ Call->getArg (), E} );
168
170
169
171
// Warn about surprising implicit optional promotions.
170
172
checkOptionalPromotions (Call);
0 commit comments