@@ -176,7 +176,8 @@ class DiagnoseUnknownCompileTimeValues : public SILModuleTransform {
176176
177177 void verifyLocal (DebugValueInst *DBI) {
178178 auto Decl = DBI->getDecl ();
179- if (!Decl || !isa<VarDecl>(Decl) || isa<ParamDecl>(Decl) || !Decl->isConstVal ())
179+ if (!Decl || !isa<VarDecl>(Decl) || isa<ParamDecl>(Decl) ||
180+ !Decl->isConstVal ())
180181 return ;
181182
182183 auto Value = ConstExprState.getConstantValue (DBI->getOperand ());
@@ -228,14 +229,16 @@ class DiagnoseUnknownCompileTimeValues : public SILModuleTransform {
228229
229230 if (hasConst) {
230231 for (size_t i = 0 ; i < CalleeParameters->size (); ++i) {
231- auto CorrespondingArg = ApplyArgRefs[i];
232- if (CalleeParameters->get (i)->isConstVal ()) {
232+ const auto &CorrespondingArg = ApplyArgRefs[i];
233+ const auto &CorrespondingParameter = CalleeParameters->get (i);
234+ if (CorrespondingParameter->isConstVal ()) {
233235 LLVM_DEBUG ({
234- llvm::dbgs () << " Argument of fn{" << CalleeDecl->getNameStr () << " } " ;
235- llvm::dbgs () << CalleeParameters->get (i)->getNameStr () << " : " ;
236+ llvm::dbgs () << " Argument of fn{" << CalleeDecl->getNameStr ()
237+ << " } " ;
238+ llvm::dbgs () << CorrespondingParameter->getNameStr () << " : " ;
236239 std::string typeName;
237240 llvm::raw_string_ostream out (typeName);
238- CalleeParameters-> get (i) ->getTypeRepr ()->print (out);
241+ CorrespondingParameter ->getTypeRepr ()->print (out);
239242 auto Value = ConstExprState.getConstantValue (CorrespondingArg);
240243 llvm::dbgs () << typeName << " = " ;
241244 printSymbolicValueValue (Value, Allocator);
@@ -248,6 +251,10 @@ class DiagnoseUnknownCompileTimeValues : public SILModuleTransform {
248251 ArgLocation = ApplyExprNode->getArgs ()[i].getLoc ();
249252 getModule ()->getASTContext ().Diags .diagnose (
250253 ArgLocation, diag::require_const_arg_for_parameter);
254+ getModule ()->getASTContext ().Diags .diagnose (
255+ CorrespondingParameter->getLoc (),
256+ diag::kind_declname_declared_here, DescriptiveDeclKind::Param,
257+ CorrespondingParameter->getName ());
251258 }
252259 }
253260 }
0 commit comments