Coverage Report

Created: 2026-07-11 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/internal/casts.h
Line
Count
Source
1
// Copyright 2021 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef THIRD_PARTY_CEL_CPP_INTERNAL_CASTS_H_
16
#define THIRD_PARTY_CEL_CPP_INTERNAL_CASTS_H_
17
18
#include <cassert>
19
#include <memory>
20
#include <type_traits>
21
22
namespace cel::internal {
23
24
template <typename To, typename From>
25
10.6k
To down_cast(From* from) {
26
10.6k
  static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
27
10.6k
  static_assert((std::is_base_of_v<From, std::remove_pointer_t<To>>),
28
10.6k
                "Target type not derived from source type.");
29
10.6k
#if !defined(__GNUC__) || defined(__GXX_RTTI)
30
10.6k
  assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
31
10.6k
#endif
32
10.6k
  return static_cast<To>(from);
33
10.6k
}
Unexecuted instantiation: google::api::expr::runtime::CelExpressionRecursiveImpl::EvaluationState* cel::internal::down_cast<google::api::expr::runtime::CelExpressionRecursiveImpl::EvaluationState*, google::api::expr::runtime::CelEvaluationState>(google::api::expr::runtime::CelEvaluationState*)
Unexecuted instantiation: google::api::expr::runtime::WrappedDirectStep const* cel::internal::down_cast<google::api::expr::runtime::WrappedDirectStep const*, google::api::expr::runtime::ExpressionStep const>(google::api::expr::runtime::ExpressionStep const*)
google::api::expr::runtime::CelExpressionFlatEvaluationState* cel::internal::down_cast<google::api::expr::runtime::CelExpressionFlatEvaluationState*, google::api::expr::runtime::CelEvaluationState>(google::api::expr::runtime::CelEvaluationState*)
Line
Count
Source
25
10.3k
To down_cast(From* from) {
26
10.3k
  static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
27
10.3k
  static_assert((std::is_base_of_v<From, std::remove_pointer_t<To>>),
28
10.3k
                "Target type not derived from source type.");
29
10.3k
#if !defined(__GNUC__) || defined(__GXX_RTTI)
30
  assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
31
10.3k
#endif
32
10.3k
  return static_cast<To>(from);
33
10.3k
}
Unexecuted instantiation: google::api::expr::runtime::TraceStep const* cel::internal::down_cast<google::api::expr::runtime::TraceStep const*, google::api::expr::runtime::DirectExpressionStep const>(google::api::expr::runtime::DirectExpressionStep const*)
Unexecuted instantiation: google::api::expr::runtime::DirectCompilerConstantStep const* cel::internal::down_cast<google::api::expr::runtime::DirectCompilerConstantStep const*, google::api::expr::runtime::DirectExpressionStep const>(google::api::expr::runtime::DirectExpressionStep const*)
Unexecuted instantiation: google::api::expr::runtime::CompilerConstantStep const* cel::internal::down_cast<google::api::expr::runtime::CompilerConstantStep const*, google::api::expr::runtime::ExpressionStep const>(google::api::expr::runtime::ExpressionStep const*)
cel::common_internal::CompatListValue const* cel::internal::down_cast<cel::common_internal::CompatListValue const*, cel::CustomListValueInterface const>(cel::CustomListValueInterface const*)
Line
Count
Source
25
217
To down_cast(From* from) {
26
217
  static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
27
217
  static_assert((std::is_base_of_v<From, std::remove_pointer_t<To>>),
28
217
                "Target type not derived from source type.");
29
217
#if !defined(__GNUC__) || defined(__GXX_RTTI)
30
  assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
31
217
#endif
32
217
  return static_cast<To>(from);
33
217
}
Unexecuted instantiation: cel::common_internal::MutableCompatListValue const* cel::internal::down_cast<cel::common_internal::MutableCompatListValue const*, cel::CustomListValueInterface const>(cel::CustomListValueInterface const*)
cel::common_internal::CompatMapValue const* cel::internal::down_cast<cel::common_internal::CompatMapValue const*, cel::CustomMapValueInterface const>(cel::CustomMapValueInterface const*)
Line
Count
Source
25
34
To down_cast(From* from) {
26
34
  static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
27
34
  static_assert((std::is_base_of_v<From, std::remove_pointer_t<To>>),
28
34
                "Target type not derived from source type.");
29
34
#if !defined(__GNUC__) || defined(__GXX_RTTI)
30
  assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
31
34
#endif
32
34
  return static_cast<To>(from);
33
34
}
Unexecuted instantiation: cel::common_internal::MutableCompatMapValue const* cel::internal::down_cast<cel::common_internal::MutableCompatMapValue const*, cel::CustomMapValueInterface const>(cel::CustomMapValueInterface const*)
Unexecuted instantiation: cel::common_internal::MutableListValue const* cel::internal::down_cast<cel::common_internal::MutableListValue const*, cel::CustomListValueInterface const>(cel::CustomListValueInterface const*)
Unexecuted instantiation: cel::common_internal::MutableMapValue const* cel::internal::down_cast<cel::common_internal::MutableMapValue const*, cel::CustomMapValueInterface const>(cel::CustomMapValueInterface const*)
34
35
template <typename To, typename From>
36
0
To down_cast(From& from) {
37
0
  static_assert(std::is_lvalue_reference_v<To>,
38
0
                "Target type not a lvalue reference.");
39
0
  static_assert((std::is_base_of_v<From, std::remove_reference_t<To>>),
40
0
                "Target type not derived from source type.");
41
0
#if !defined(__GNUC__) || defined(__GXX_RTTI)
42
  assert(dynamic_cast<std::add_pointer_t<std::remove_reference_t<To>>>(
43
0
             std::addressof(from)) != nullptr);
44
0
#endif
45
0
  return static_cast<To>(from);
46
0
}
Unexecuted instantiation: cel::runtime_internal::RuntimeImpl& cel::internal::down_cast<cel::runtime_internal::RuntimeImpl&, cel::Runtime>(cel::Runtime&)
Unexecuted instantiation: cel::common_internal::MutableListValue const& cel::internal::down_cast<cel::common_internal::MutableListValue const&, cel::CustomListValueInterface const>(cel::CustomListValueInterface const&)
Unexecuted instantiation: cel::common_internal::MutableCompatListValue const& cel::internal::down_cast<cel::common_internal::MutableCompatListValue const&, cel::CustomListValueInterface const>(cel::CustomListValueInterface const&)
Unexecuted instantiation: cel::common_internal::MutableMapValue const& cel::internal::down_cast<cel::common_internal::MutableMapValue const&, cel::CustomMapValueInterface const>(cel::CustomMapValueInterface const&)
Unexecuted instantiation: cel::common_internal::MutableCompatMapValue const& cel::internal::down_cast<cel::common_internal::MutableCompatMapValue const&, cel::CustomMapValueInterface const>(cel::CustomMapValueInterface const&)
47
48
}  // namespace cel::internal
49
50
#endif  // THIRD_PARTY_CEL_CPP_INTERNAL_CASTS_H_