[PATCH] D115934: [analyzer] Add range constructor to CallDescriptionMap

Endre Fülöp via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 17 05:12:05 PST 2021


gamesh411 created this revision.
gamesh411 added reviewers: steakhal, martong.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
gamesh411 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

CallDescriptionMap benefits from a range constructor when the
CallDescription and mapped type pairs cannot be constructed at once, but
are built incrementally.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115934

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
  clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp


Index: clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
===================================================================
--- clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
+++ clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
@@ -19,6 +19,14 @@
 namespace ento {
 namespace {
 
+using ArgsContainer = std::vector<std::pair<CallDescription, bool>>;
+
+static_assert(
+    std::is_constructible<CallDescriptionMap<bool>,
+                          decltype(std::declval<ArgsContainer>().begin()),
+                          decltype(std::declval<ArgsContainer>().end())>(),
+    "should be range constructible");
+
 // A wrapper around CallDescriptionMap<bool> that allows verifying that
 // all functions have been found. This is needed because CallDescriptionMap
 // isn't supposed to support iteration.
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
@@ -134,6 +134,9 @@
       std::initializer_list<std::pair<CallDescription, T>> &&List)
       : LinearMap(List) {}
 
+  template <typename InputIt>
+  CallDescriptionMap(InputIt First, InputIt Last) : LinearMap(First, Last) {}
+
   ~CallDescriptionMap() = default;
 
   // These maps are usually stored once per checker, so let's make sure


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115934.395097.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211217/d428f896/attachment-0001.bin>


More information about the cfe-commits mailing list