Skip to content

Commit

Permalink
Bring F14 skeleton closer to reality
Browse files Browse the repository at this point in the history
Summary: The F14 maps use inheritance, which matters when it comes to writing matchers for each function. This commit brings the test skeleton in line with reality, such that test behavior matches the real thing.

Reviewed By: skcho

Differential Revision: D49821895

fbshipit-source-id: 61c46588c207835d3024e93cb2cf2d2f29e30bf3
  • Loading branch information
nicovank authored and facebook-github-bot committed Oct 2, 2023
1 parent 6cab9af commit 0150fba
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions infer/tests/codetoanalyze/cpp/pulse/reference_stability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#include <initializer_list>
#include <unordered_map>
#include <utility>
#include <type_traits>

// Keep a simplified skeleton of F14 maps for testing.
namespace folly {
struct F14HashToken;

namespace f14::detail {
template <typename Key, typename Mapped>
struct F14BasicMap {
using key_type = Key;
Expand Down Expand Up @@ -164,12 +166,33 @@ struct F14BasicMap {
void reserve(std::size_t capacity);
};

template <typename K, typename V>
using F14ValueMap = F14BasicMap<K, V>;
template <typename K, typename V>
using F14VectorMap = F14BasicMap<K, V>;
template <typename K, typename V>
using F14FastMap = F14BasicMap<K, V>;
template <typename Key, typename Mapped>
class F14VectorMapImpl : public F14BasicMap<Key, Mapped> {
using F14BasicMap<Key, Mapped>::F14BasicMap;
};
} // namespace f14::detail

template <typename Key, typename Mapped>
class F14ValueMap : public f14::detail::F14BasicMap<Key, Mapped> {
using f14::detail::F14BasicMap<Key, Mapped>::F14BasicMap;
};

template <typename Key, typename Mapped>
class F14VectorMap : public f14::detail::F14VectorMapImpl<Key, Mapped> {
using f14::detail::F14VectorMapImpl<Key, Mapped>::F14VectorMapImpl;
};

template <typename Key, typename Mapped>
class F14FastMap : public std::conditional<
sizeof(std::pair<Key const, Mapped>) < 24,
F14ValueMap<Key, Mapped>,
f14::detail::F14VectorMapImpl<Key, Mapped>>::type {
using Super =
std::conditional<sizeof(std::pair<Key const, Mapped>) < 24,
F14ValueMap<Key, Mapped>,
f14::detail::F14VectorMapImpl<Key, Mapped>>::type;
using Super::Super;
};
} // namespace folly

void unordered_map_ok() {
Expand Down

0 comments on commit 0150fba

Please sign in to comment.