From: Dominic Chen Date: Tue, 8 Nov 2016 22:39:14 +0000 (+0000) Subject: [analyzer] Provide Contains() on ImmutableMap program state partial trait. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5132a3d4434ab01df2b75ee83f4f7415eea09dcd;p=clang [analyzer] Provide Contains() on ImmutableMap program state partial trait. Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26373 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286306 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h index 6b4da7db24..a04fa90059 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // This file defines partial implementations of template specializations of -// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState +// the class ProgramStateTrait<>. ProgramStateTrait<> is used by ProgramState // to implement set/get methods for manipulating a ProgramState's // generic data map. // @@ -81,6 +81,10 @@ namespace ento { return F.remove(B, K); } + static bool Contains(data_type B, key_type K) { + return B.contains(K); + } + static inline context_type MakeContext(void *p) { return *((typename data_type::Factory*) p); } @@ -185,7 +189,7 @@ namespace ento { } }; - + // Partial specialization for bool. template <> struct ProgramStatePartialTrait { typedef bool data_type; @@ -198,7 +202,7 @@ namespace ento { return (void*) (uintptr_t) d; } }; - + // Partial specialization for unsigned. template <> struct ProgramStatePartialTrait { typedef unsigned data_type;