YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/util/cast.h
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_UTIL_CAST_H_
15
#define YB_UTIL_CAST_H_
16
17
#include <memory>
18
19
namespace yb {
20
21
11.0M
inline char* to_char_ptr(uint8_t* uptr) {
22
11.0M
  return reinterpret_cast<char *>(uptr);
23
11.0M
}
24
25
13.9G
inline const char* to_char_ptr(const uint8_t* uptr) {
26
13.9G
  return reinterpret_cast<const char *>(uptr);
27
13.9G
}
28
29
2.62G
inline uint8_t* to_uchar_ptr(char *ptr) {
30
2.62G
  return reinterpret_cast<uint8_t *>(ptr);
31
2.62G
}
32
33
95.2G
inline const uint8_t* to_uchar_ptr(const char *ptr) {
34
95.2G
  return reinterpret_cast<const uint8_t *>(ptr);
35
95.2G
}
36
37
template<class Out, class In>
38
7.72G
Out pointer_cast(In* in) {
39
7.72G
  void* temp = in;
40
7.72G
  return static_cast<Out>(temp);
41
7.72G
}
unsigned char* yb::pointer_cast<unsigned char*, char>(char*)
Line
Count
Source
38
195M
Out pointer_cast(In* in) {
39
195M
  void* temp = in;
40
195M
  return static_cast<Out>(temp);
41
195M
}
char* yb::pointer_cast<char*, unsigned char>(unsigned char*)
Line
Count
Source
38
4.92M
Out pointer_cast(In* in) {
39
4.92M
  void* temp = in;
40
4.92M
  return static_cast<Out>(temp);
41
4.92M
}
std::__1::atomic<bool>* yb::pointer_cast<std::__1::atomic<bool>*, bool>(bool*)
Line
Count
Source
38
4.44G
Out pointer_cast(In* in) {
39
4.44G
  void* temp = in;
40
4.44G
  return static_cast<Out>(temp);
41
4.44G
}
std::__1::atomic<int>* yb::pointer_cast<std::__1::atomic<int>*, int>(int*)
Line
Count
Source
38
1.06G
Out pointer_cast(In* in) {
39
1.06G
  void* temp = in;
40
1.06G
  return static_cast<Out>(temp);
41
1.06G
}
char const* yb::pointer_cast<char const*, unsigned int>(unsigned int*)
Line
Count
Source
38
5.69M
Out pointer_cast(In* in) {
39
5.69M
  void* temp = in;
40
5.69M
  return static_cast<Out>(temp);
41
5.69M
}
char const* yb::pointer_cast<char const*, unsigned char>(unsigned char*)
Line
Count
Source
38
3.26M
Out pointer_cast(In* in) {
39
3.26M
  void* temp = in;
40
3.26M
  return static_cast<Out>(temp);
41
3.26M
}
std::__1::atomic<double>* yb::pointer_cast<std::__1::atomic<double>*, double>(double*)
Line
Count
Source
38
3.86M
Out pointer_cast(In* in) {
39
3.86M
  void* temp = in;
40
3.86M
  return static_cast<Out>(temp);
41
3.86M
}
char const* yb::pointer_cast<char const*, yb::tserver::TServerSharedData>(yb::tserver::TServerSharedData*)
Line
Count
Source
38
8
Out pointer_cast(In* in) {
39
8
  void* temp = in;
40
8
  return static_cast<Out>(temp);
41
8
}
std::__1::atomic<long long>* yb::pointer_cast<std::__1::atomic<long long>*, long long>(long long*)
Line
Count
Source
38
345M
Out pointer_cast(In* in) {
39
345M
  void* temp = in;
40
345M
  return static_cast<Out>(temp);
41
345M
}
std::__1::atomic<unsigned long long>* yb::pointer_cast<std::__1::atomic<unsigned long long>*, unsigned long long>(unsigned long long*)
Line
Count
Source
38
422M
Out pointer_cast(In* in) {
39
422M
  void* temp = in;
40
422M
  return static_cast<Out>(temp);
41
422M
}
Unexecuted instantiation: char const* yb::pointer_cast<char const*, unsigned long>(unsigned long*)
Unexecuted instantiation: char const* yb::pointer_cast<char const*, yb::docdb::TransactionDumpOp>(yb::docdb::TransactionDumpOp*)
char* yb::pointer_cast<char*, unsigned long>(unsigned long*)
Line
Count
Source
38
86.6M
Out pointer_cast(In* in) {
39
86.6M
  void* temp = in;
40
86.6M
  return static_cast<Out>(temp);
41
86.6M
}
char* yb::pointer_cast<char*, yb::tserver::TServerSharedData>(yb::tserver::TServerSharedData*)
Line
Count
Source
38
8
Out pointer_cast(In* in) {
39
8
  void* temp = in;
40
8
  return static_cast<Out>(temp);
41
8
}
unsigned char* yb::pointer_cast<unsigned char*, yb::internal::ArenaComponent<yb::internal::ThreadSafeArenaTraits> >(yb::internal::ArenaComponent<yb::internal::ThreadSafeArenaTraits>*)
Line
Count
Source
38
913M
Out pointer_cast(In* in) {
39
913M
  void* temp = in;
40
913M
  return static_cast<Out>(temp);
41
913M
}
unsigned char* yb::pointer_cast<unsigned char*, yb::internal::ArenaComponent<yb::internal::ArenaTraits> >(yb::internal::ArenaComponent<yb::internal::ArenaTraits>*)
Line
Count
Source
38
7.44M
Out pointer_cast(In* in) {
39
7.44M
  void* temp = in;
40
7.44M
  return static_cast<Out>(temp);
41
7.44M
}
yb::Status::State* yb::pointer_cast<yb::Status::State*, YBCStatusStruct>(YBCStatusStruct*)
Line
Count
Source
38
1.60M
Out pointer_cast(In* in) {
39
1.60M
  void* temp = in;
40
1.60M
  return static_cast<Out>(temp);
41
1.60M
}
YBCStatusStruct* yb::pointer_cast<YBCStatusStruct*, yb::Status::State>(yb::Status::State*)
Line
Count
Source
38
226M
Out pointer_cast(In* in) {
39
226M
  void* temp = in;
40
226M
  return static_cast<Out>(temp);
41
226M
}
Unexecuted instantiation: conflict_resolution.cc:unsigned char const* yb::pointer_cast<unsigned char const*, yb::docdb::(anonymous namespace)::TransactionData>(yb::docdb::(anonymous namespace)::TransactionData*)
void** yb::pointer_cast<void**, redisReply*>(redisReply**)
Line
Count
Source
38
424
Out pointer_cast(In* in) {
39
424
  void* temp = in;
40
424
  return static_cast<Out>(temp);
41
424
}
42
43
template<class Out, class In>
44
118M
Out pointer_cast(const In* in) {
45
118M
  const void* temp = in;
46
118M
  return static_cast<Out>(temp);
47
118M
}
char const* yb::pointer_cast<char const*, yb::HybridTime>(yb::HybridTime const*)
Line
Count
Source
44
80
Out pointer_cast(const In* in) {
45
80
  const void* temp = in;
46
80
  return static_cast<Out>(temp);
47
80
}
Unexecuted instantiation: char const* yb::pointer_cast<char const*, int>(int const*)
char const* yb::pointer_cast<char const*, unsigned char>(unsigned char const*)
Line
Count
Source
44
22.2k
Out pointer_cast(const In* in) {
45
22.2k
  const void* temp = in;
46
22.2k
  return static_cast<Out>(temp);
47
22.2k
}
unsigned char const* yb::pointer_cast<unsigned char const*, unsigned char>(unsigned char const*)
Line
Count
Source
44
10.2k
Out pointer_cast(const In* in) {
45
10.2k
  const void* temp = in;
46
10.2k
  return static_cast<Out>(temp);
47
10.2k
}
unsigned char const* yb::pointer_cast<unsigned char const*, char>(char const*)
Line
Count
Source
44
54.0M
Out pointer_cast(const In* in) {
45
54.0M
  const void* temp = in;
46
54.0M
  return static_cast<Out>(temp);
47
54.0M
}
char const* yb::pointer_cast<char const*, char>(char const*)
Line
Count
Source
44
198
Out pointer_cast(const In* in) {
45
198
  const void* temp = in;
46
198
  return static_cast<Out>(temp);
47
198
}
char const* yb::pointer_cast<char const*, void*>(void* const*)
Line
Count
Source
44
64
Out pointer_cast(const In* in) {
45
64
  const void* temp = in;
46
64
  return static_cast<Out>(temp);
47
64
}
Unexecuted instantiation: char const* yb::pointer_cast<char const*, yb::ReadHybridTime>(yb::ReadHybridTime const*)
Unexecuted instantiation: char const* yb::pointer_cast<char const*, yb::DocHybridTime>(yb::DocHybridTime const*)
Unexecuted instantiation: char const* yb::pointer_cast<char const*, bool>(bool const*)
Unexecuted instantiation: char const* yb::pointer_cast<char const*, unsigned long>(unsigned long const*)
char const* yb::pointer_cast<char const*, unsigned int>(unsigned int const*)
Line
Count
Source
44
64.6M
Out pointer_cast(const In* in) {
45
64.6M
  const void* temp = in;
46
64.6M
  return static_cast<Out>(temp);
47
64.6M
}
48
49
template<class D, class S>
50
std::unique_ptr<D> down_pointer_cast(std::unique_ptr<S> s) {
51
  auto* f = s.release();
52
  assert(f == nullptr || dynamic_cast<D*>(f) != nullptr);
53
  return std::unique_ptr<D>(static_cast<D*>(f));
54
}
55
56
}  // namespace yb
57
58
using yb::pointer_cast;
59
60
#endif  // YB_UTIL_CAST_H_