HighCommander4 wrote: > StringMap insertion may cause elements to be rehased, or the underlying > storage to be reallocated, so it is generatelly unsafe to take pointers to > StringMap "values".
Are you sure about this? The [comment above](https://searchfox.org/llvm/rev/f5742c4d540a20651a67de51e16242a52e5d4064/clang-tools-extra/clangd/GlobalCompilationDatabase.h#145) the declaration of `DirCaches` specifically says "We can hand out pointers as they're stable and entries are never removed." And while I haven't studied the implementation of `StringMap` in detail, I at least can't find an obvious place where values would get moved after initial insertion: the hashtable stores [pointers to entries](https://searchfox.org/llvm/rev/f5742c4d540a20651a67de51e16242a52e5d4064/llvm/include/llvm/ADT/StringMap.h#35-38) (suggesting that you can reallocate/rearrange the table without moving the entry objects themselves), and the entries are created via placement-new [here](https://searchfox.org/llvm/rev/f5742c4d540a20651a67de51e16242a52e5d4064/llvm/include/llvm/ADT/StringMapEntry.h#128) and I'm not seeing what would call that during a rehash or reallocation. https://github.com/llvm/llvm-project/pull/169339 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
