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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits