[PATCH] D143976: [ADT] Add lookupOrTrap method to DenseMap and StringMap
Xiangxi Guo (Ryan) via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 21:51:55 PST 2023
StrongerXi added inline comments.
================
Comment at: llvm/include/llvm/ADT/DenseMap.h:213
+ dbgs() << "[DenseMap::lookupOrTrap] key not found; " << Msg << "\n";
+ std::abort();
+ }
----------------
lattner wrote:
> Unfortunately, I don't think we can afford to include this level of debug tracing in here. This adds a bunch of #include dependencies, and (more problematically) includes a bunch of code in the non assert build.
>
> The standard LLVM way to do this (see in things like ArrayRef's subscript) is to just assert with a fixed message "lookupOrTrap failed due to a missing key", using the standard `assert` macro.
Ah good points, updated.
================
Comment at: llvm/include/llvm/ADT/StringMap.h:234-236
+ const_iterator Iter = find(Key);
+ if (Iter != end())
+ return Iter->second;
----------------
Updated because I noticed they didn't follow the convention of capitalized variable names.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143976/new/
https://reviews.llvm.org/D143976
More information about the llvm-commits
mailing list