[PATCH] D27097: [ELF] Refactor target errors

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 08:38:41 PST 2016


ruiu added inline comments.


================
Comment at: ELF/Target.cpp:61
   if (!isInt<N>(V))
-    error("relocation " + toString(Type) + " out of range");
+    errorAt(false, Loc, "relocation " + toString(Type) + " out of range");
 }
----------------
I don't think we need a new error-ish function here. I'd define a function that returns the output location info as a string, then I could write like this.

  error(getErrorLoc(Loc) + ": relocation " + toString(Type) + " out of range");



================
Comment at: ELF/Target.cpp:813
   default:
-    fatal("unrecognized reloc " + Twine(Type));
+    errorAt(true, Loc, "unrecognized reloc " + Twine(Type));
   }
----------------
Then this can be

  fatal(getErrorLoc(Loc) + ": unrecognized reloc " + Twine(Type));


================
Comment at: ELF/Writer.cpp:1560-1561
+    if (ISLoc <= Loc && ISLoc + IS->getSize() > Loc) {
+      ErrLoc = getLocation(*IS, Loc - ISLoc);
+      break;
+    }
----------------
Just return the return value of getLocation().


https://reviews.llvm.org/D27097





More information about the llvm-commits mailing list