[PATCH] D19731: Parse PDB Name Hash Table

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 14:58:39 PDT 2016


zturner added inline comments.

================
Comment at: lib/DebugInfo/PDB/Raw/NameHashTable.cpp:132
@@ +131,3 @@
+  }
+  return 0; // 0 is an invalid name index
+}
----------------
zturner wrote:
> majnemer wrote:
> > If we are going to use `0` as our sentinel, can we assert that `NameIndex` isn't `0`?
> I think it would be better to just skip over 0 values.  If the number of buckets is larger than the number of strings (because say you added a string and then removed it) then you could have 0 values in the `IDs` array.  So I should probably fix `getStringForID` to check for an ID of 0 and also fix `getIDForString` to skip the entry if it finds a 0 id.
So another option, is that it seems like `Indicies[0] == 0`, and `NamesBuffer[0]` is the sentinel string.  So my hypothesis is that the correct thing to do is treat whatever is in `Indices[0]` as the "invalid ID".  So if I return `IDs[0]` here, and then check for `IDs[0]` in `getStringForID`, that should work and at least not be hardcoded.


http://reviews.llvm.org/D19731





More information about the llvm-commits mailing list