@@ -776,13 +776,14 @@ ParseSubClassReference(Record *CurRec, bool isDefm) {
776
776
return Result;
777
777
}
778
778
779
- if (ParseTemplateArgValueList (Result.TemplateArgs , CurRec, Result.Rec )) {
779
+ SmallVector<SMLoc> ArgLocs;
780
+ if (ParseTemplateArgValueList (Result.TemplateArgs , ArgLocs, CurRec,
781
+ Result.Rec )) {
780
782
Result.Rec = nullptr ; // Error parsing value list.
781
783
return Result;
782
784
}
783
785
784
- if (CheckTemplateArgValues (Result.TemplateArgs , Result.RefRange .Start ,
785
- Result.Rec )) {
786
+ if (CheckTemplateArgValues (Result.TemplateArgs , ArgLocs, Result.Rec )) {
786
787
Result.Rec = nullptr ; // Error checking value list.
787
788
return Result;
788
789
}
@@ -812,7 +813,8 @@ ParseSubMultiClassReference(MultiClass *CurMC) {
812
813
return Result;
813
814
}
814
815
815
- if (ParseTemplateArgValueList (Result.TemplateArgs , &CurMC->Rec ,
816
+ SmallVector<SMLoc> ArgLocs;
817
+ if (ParseTemplateArgValueList (Result.TemplateArgs , ArgLocs, &CurMC->Rec ,
816
818
&Result.MC ->Rec )) {
817
819
Result.MC = nullptr ; // Error parsing value list.
818
820
return Result;
@@ -2722,11 +2724,12 @@ const Init *TGParser::ParseSimpleValue(Record *CurRec, const RecTy *ItemType,
2722
2724
}
2723
2725
2724
2726
SmallVector<const ArgumentInit *, 8 > Args;
2727
+ SmallVector<SMLoc> ArgLocs;
2725
2728
Lex.Lex (); // consume the <
2726
- if (ParseTemplateArgValueList (Args, CurRec, Class))
2729
+ if (ParseTemplateArgValueList (Args, ArgLocs, CurRec, Class))
2727
2730
return nullptr ; // Error parsing value list.
2728
2731
2729
- if (CheckTemplateArgValues (Args, NameLoc. Start , Class))
2732
+ if (CheckTemplateArgValues (Args, ArgLocs , Class))
2730
2733
return nullptr ; // Error checking template argument values.
2731
2734
2732
2735
if (resolveArguments (Class, Args, NameLoc.Start ))
@@ -3201,8 +3204,8 @@ void TGParser::ParseValueList(SmallVectorImpl<const Init *> &Result,
3201
3204
// PostionalArgValueList ::= [Value {',' Value}*]
3202
3205
// NamedArgValueList ::= [NameValue '=' Value {',' NameValue '=' Value}*]
3203
3206
bool TGParser::ParseTemplateArgValueList (
3204
- SmallVectorImpl<const ArgumentInit *> &Result, Record *CurRec,
3205
- const Record *ArgsRec) {
3207
+ SmallVectorImpl<const ArgumentInit *> &Result,
3208
+ SmallVectorImpl<SMLoc> &ArgLocs, Record *CurRec, const Record *ArgsRec) {
3206
3209
assert (Result.empty () && " Result vector is not empty" );
3207
3210
ArrayRef<const Init *> TArgs = ArgsRec->getTemplateArgs ();
3208
3211
@@ -3217,7 +3220,7 @@ bool TGParser::ParseTemplateArgValueList(
3217
3220
return true ;
3218
3221
}
3219
3222
3220
- SMLoc ValueLoc = Lex.getLoc ();
3223
+ SMLoc ValueLoc = ArgLocs. emplace_back ( Lex.getLoc () );
3221
3224
// If we are parsing named argument, we don't need to know the argument name
3222
3225
// and argument type will be resolved after we know the name.
3223
3226
const Init *Value = ParseValue (
@@ -4417,11 +4420,15 @@ bool TGParser::ParseFile() {
4417
4420
// If necessary, replace an argument with a cast to the required type.
4418
4421
// The argument count has already been checked.
4419
4422
bool TGParser::CheckTemplateArgValues (
4420
- SmallVectorImpl<const ArgumentInit *> &Values, SMLoc Loc ,
4423
+ SmallVectorImpl<const ArgumentInit *> &Values, ArrayRef< SMLoc> ValuesLocs ,
4421
4424
const Record *ArgsRec) {
4425
+ assert (Values.size () == ValuesLocs.size () &&
4426
+ " expected as many values as locations" );
4427
+
4422
4428
ArrayRef<const Init *> TArgs = ArgsRec->getTemplateArgs ();
4423
4429
4424
- for (const ArgumentInit *&Value : Values) {
4430
+ bool HasError = false ;
4431
+ for (auto [Value, Loc] : llvm::zip_equal (Values, ValuesLocs)) {
4425
4432
const Init *ArgName = nullptr ;
4426
4433
if (Value->isPositional ())
4427
4434
ArgName = TArgs[Value->getIndex ()];
@@ -4439,16 +4446,16 @@ bool TGParser::CheckTemplateArgValues(
4439
4446
" result of template arg value cast has wrong type" );
4440
4447
Value = Value->cloneWithValue (CastValue);
4441
4448
} else {
4442
- PrintFatalError (Loc, " Value specified for template argument ' " +
4443
- Arg-> getNameInitAsString () + " ' is of type " +
4444
- ArgValue-> getType ()-> getAsString () +
4445
- " ; expected type " + ArgType-> getAsString () +
4446
- " : " + ArgValue->getAsString ());
4449
+ HasError |= Error (
4450
+ Loc, " Value specified for template argument ' " +
4451
+ Arg-> getNameInitAsString () + " ' is of type " +
4452
+ ArgValue-> getType ()-> getAsString () + " ; expected type " +
4453
+ ArgType-> getAsString () + " : " + ArgValue->getAsString ());
4447
4454
}
4448
4455
}
4449
4456
}
4450
4457
4451
- return false ;
4458
+ return HasError ;
4452
4459
}
4453
4460
4454
4461
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0 commit comments