[all-commits] [llvm/llvm-project] 132003: [ADT] Add `at` method (assertive lookup) to DenseM...

Xiangxi Guo (Ryan) via All-commits all-commits at lists.llvm.org
Fri Feb 17 08:32:54 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 132003603ae3453bc385ffd5ed53f5e8057ae1bc
      https://github.com/llvm/llvm-project/commit/132003603ae3453bc385ffd5ed53f5e8057ae1bc
  Author: Ryan Guo <ryanguo at modular.com>
  Date:   2023-02-17 (Fri, 17 Feb 2023)

  Changed paths:
    M llvm/include/llvm/ADT/DenseMap.h
    M llvm/include/llvm/ADT/StringMap.h
    M llvm/unittests/ADT/DenseMapTest.cpp
    M llvm/unittests/ADT/StringMapTest.cpp

  Log Message:
  -----------
  [ADT] Add `at` method (assertive lookup) to DenseMap and StringMap

This patch makes it easier for users when they want to use validated
lookup on DenseMap/StringMap as a composable C++ expression. For
instance:

```
// instead of
if (auto val = map.lookup(key))
   return val;
assert("...");

// we can write
return map.at(key);
```

Differential Revision: https://reviews.llvm.org/D143976




More information about the All-commits mailing list