[PATCH] D14943: [ELF] Factor out relocation checks into separate functions.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 11:09:26 PST 2015


ruiu added inline comments.

================
Comment at: ELF/Target.cpp:45
@@ -44,1 +44,3 @@
 
+template <unsigned N> static void checkIsInt(int64_t Val, uint32_t Type) {
+  if (!isInt<N>(Val))
----------------
checkIsInt -> checkInt
Val -> V

================
Comment at: ELF/Target.cpp:46-48
@@ +45,5 @@
+template <unsigned N> static void checkIsInt(int64_t Val, uint32_t Type) {
+  if (!isInt<N>(Val))
+    error("Relocation " + getELFRelocationTypeName(Config->EMachine, Type) +
+          " out of range");
+}
----------------
It's a minor point, but I don't like to mix strings with getElfRelocationTypeName() function call because the function name is too long. I'd write like this.

  if (isInt<N>(V))
    return;
  StringRef S = getELFRelocationTypeName(Config->EMachine, Type);
  error("Relocation " + S + " out of range");

================
Comment at: ELF/Target.cpp:51
@@ +50,3 @@
+
+template <unsigned N> static void checkIsUInt(uint64_t Val, uint32_t Type) {
+  if (!isUInt<N>(Val))
----------------
Ditto

================
Comment at: ELF/Target.cpp:57
@@ +56,3 @@
+
+template <unsigned N> static void checkAlignment(uint64_t Val, uint32_t Type) {
+  uint64_t Mask = (1 << N) - 1;
----------------
Ditto


http://reviews.llvm.org/D14943





More information about the llvm-commits mailing list