forked from OSchip/llvm-project
[TableGen] Detect multiple Processors with the same name.
Due to a bad merge we ended up with duplicate entries in our downstream repo. I was surprised that nothing caught it. I wrote this check so I could fix our downstream repo and figured I might as well share it. Reviewed By: RKSimon, spatel Differential Revision: https://reviews.llvm.org/D118497
This commit is contained in:
parent
46283589ef
commit
1aeb3314d8
|
@ -521,6 +521,15 @@ void CodeGenSchedModels::collectProcModels() {
|
||||||
RecVec ProcRecords = Records.getAllDerivedDefinitions("Processor");
|
RecVec ProcRecords = Records.getAllDerivedDefinitions("Processor");
|
||||||
llvm::sort(ProcRecords, LessRecordFieldName());
|
llvm::sort(ProcRecords, LessRecordFieldName());
|
||||||
|
|
||||||
|
// Check for duplicated names.
|
||||||
|
auto I = std::adjacent_find(ProcRecords.begin(), ProcRecords.end(),
|
||||||
|
[](const Record *Rec1, const Record *Rec2) {
|
||||||
|
return Rec1->getValueAsString("Name") == Rec2->getValueAsString("Name");
|
||||||
|
});
|
||||||
|
if (I != ProcRecords.end())
|
||||||
|
PrintFatalError((*I)->getLoc(), "Duplicate processor name " +
|
||||||
|
(*I)->getValueAsString("Name"));
|
||||||
|
|
||||||
// Reserve space because we can. Reallocation would be ok.
|
// Reserve space because we can. Reallocation would be ok.
|
||||||
ProcModels.reserve(ProcRecords.size()+1);
|
ProcModels.reserve(ProcRecords.size()+1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue