[llvm] [SystemZ][z/OS] yaml2obj GOFF symbols (PR #75971)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 08:46:56 PDT 2024


================
@@ -308,11 +308,14 @@ bool GOFFState::writeObject() {
   if (HasError)
     return false;
   // Iterate over all records.
-  for (const std::unique_ptr<llvm::GOFFYAML::RecordBase> &Rec : Doc.Records)
+  unsigned RecordNum = 0;
+  for (const std::unique_ptr<llvm::GOFFYAML::RecordBase> &Rec : Doc.Records) {
     if (const auto *Sym = dyn_cast<GOFFYAML::Symbol>(Rec.get()))
       writeSymbol(*Sym);
     else
-      reportError("unknown record type");
+      reportError("unknown record type on record index" + Twine(RecordNum));
----------------
jh7370 wrote:

```suggestion
      reportError("record with index " + Twine(RecordNum) + " has unknown record type " + Twine(Rec.Type));
```
This is clearer, I think. `Rec.Type` may not be the right thing - I just used this as a placeholder so that I didn't have to look up the actual member that is used to determine what kind of Record it is.

You should also have a test case for this error.

https://github.com/llvm/llvm-project/pull/75971


More information about the llvm-commits mailing list