Coverage Report

Created: 2020-02-15 09:57

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/Interp/Integral.h
Line
Count
Source (jump to first uncovered line)
1
//===--- Integral.h - Wrapper for numeric types for the VM ------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// Defines the VM types and helpers operating on types.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_AST_INTERP_INTEGRAL_H
14
#define LLVM_CLANG_AST_INTERP_INTEGRAL_H
15
16
#include "clang/AST/ComparisonCategories.h"
17
#include "clang/AST/APValue.h"
18
#include "llvm/ADT/APSInt.h"
19
#include "llvm/Support/MathExtras.h"
20
#include "llvm/Support/raw_ostream.h"
21
#include <cstddef>
22
#include <cstdint>
23
24
namespace clang {
25
namespace interp {
26
27
using APInt = llvm::APInt;
28
using APSInt = llvm::APSInt;
29
30
/// Helper to compare two comparable types.
31
template <typename T>
32
0
ComparisonCategoryResult Compare(const T &X, const T &Y) {
33
0
  if (X < Y)
34
0
    return ComparisonCategoryResult::Less;
35
0
  if (X > Y)
36
0
    return ComparisonCategoryResult::Greater;
37
0
  return ComparisonCategoryResult::Equal;
38
0
}
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<bool>(bool const&, bool const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<unsigned int>(unsigned int const&, unsigned int const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<signed char>(signed char const&, signed char const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<unsigned char>(unsigned char const&, unsigned char const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<short>(short const&, short const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<unsigned short>(unsigned short const&, unsigned short const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<int>(int const&, int const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<long long>(long long const&, long long const&)
Unexecuted instantiation: clang::ComparisonCategoryResult clang::interp::Compare<unsigned long long>(unsigned long long const&, unsigned long long const&)
39
40
// Helper structure to select the representation.
41
template <unsigned Bits, bool Signed> struct Repr;
42
template <> struct Repr<8, false> { using Type = uint8_t; };
43
template <> struct Repr<16, false> { using Type = uint16_t; };
44
template <> struct Repr<32, false> { using Type = uint32_t; };
45
template <> struct Repr<64, false> { using Type = uint64_t; };
46
template <> struct Repr<8, true> { using Type = int8_t; };
47
template <> struct Repr<16, true> { using Type = int16_t; };
48
template <> struct Repr<32, true> { using Type = int32_t; };
49
template <> struct Repr<64, true> { using Type = int64_t; };
50
51
/// Wrapper around numeric types.
52
///
53
/// These wrappers are required to shared an interface between APSint and
54
/// builtin primitive numeral types, while optimising for storage and
55
/// allowing methods operating on primitive type to compile to fast code.
56
template <unsigned Bits, bool Signed> class Integral {
57
private:
58
  template <unsigned OtherBits, bool OtherSigned> friend class Integral;
59
60
  // The primitive representing the integral.
61
  using T = typename Repr<Bits, Signed>::Type;
62
  T V;
63
64
  /// Primitive representing limits.
65
  static const auto Min = std::numeric_limits<T>::min();
66
  static const auto Max = std::numeric_limits<T>::max();
67
68
  /// Construct an integral from anything that is convertible to storage.
69
0
  template <typename T> explicit Integral(T V) : V(V) {}
Unexecuted instantiation: clang::interp::Integral<8u, true>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<8u, true>::Integral<signed char>(signed char)
Unexecuted instantiation: clang::interp::Integral<8u, true>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<8u, false>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<8u, false>::Integral<unsigned char>(unsigned char)
Unexecuted instantiation: clang::interp::Integral<8u, false>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<16u, true>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<16u, true>::Integral<short>(short)
Unexecuted instantiation: clang::interp::Integral<16u, true>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<16u, false>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<16u, false>::Integral<unsigned short>(unsigned short)
Unexecuted instantiation: clang::interp::Integral<16u, false>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<32u, true>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<32u, true>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<32u, false>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<32u, false>::Integral<unsigned int>(unsigned int)
Unexecuted instantiation: clang::interp::Integral<64u, true>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<64u, false>::Integral<long long>(long long)
Unexecuted instantiation: clang::interp::Integral<64u, false>::Integral<unsigned long long>(unsigned long long)
Unexecuted instantiation: clang::interp::Integral<32u, false>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<64u, true>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<64u, false>::Integral<int>(int)
Unexecuted instantiation: clang::interp::Integral<8u, true>::Integral<unsigned int>(unsigned int)
Unexecuted instantiation: clang::interp::Integral<16u, false>::Integral<unsigned int>(unsigned int)
70
71
public:
72
  /// Zero-initializes an integral.
73
0
  Integral() : V(0) {}
Unexecuted instantiation: clang::interp::Integral<8u, true>::Integral()
Unexecuted instantiation: clang::interp::Integral<8u, false>::Integral()
Unexecuted instantiation: clang::interp::Integral<16u, true>::Integral()
Unexecuted instantiation: clang::interp::Integral<16u, false>::Integral()
Unexecuted instantiation: clang::interp::Integral<32u, true>::Integral()
Unexecuted instantiation: clang::interp::Integral<32u, false>::Integral()
Unexecuted instantiation: clang::interp::Integral<64u, true>::Integral()
Unexecuted instantiation: clang::interp::Integral<64u, false>::Integral()
74
75
  /// Constructs an integral from another integral.
76
  template <unsigned SrcBits, bool SrcSign>
77
  explicit Integral(Integral<SrcBits, SrcSign> V) : V(V.V) {}
78
79
  /// Construct an integral from a value based on signedness.
80
  explicit Integral(const APSInt &V)
81
      : V(V.isSigned() ? V.getSExtValue() : V.getZExtValue()) {}
82
83
0
  bool operator<(Integral RHS) const { return V < RHS.V; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::operator<(clang::interp::Integral<8u, true>) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::operator<(clang::interp::Integral<8u, false>) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::operator<(clang::interp::Integral<16u, true>) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::operator<(clang::interp::Integral<16u, false>) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::operator<(clang::interp::Integral<32u, true>) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::operator<(clang::interp::Integral<32u, false>) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::operator<(clang::interp::Integral<64u, true>) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::operator<(clang::interp::Integral<64u, false>) const
84
0
  bool operator>(Integral RHS) const { return V > RHS.V; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::operator>(clang::interp::Integral<8u, true>) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::operator>(clang::interp::Integral<8u, false>) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::operator>(clang::interp::Integral<16u, true>) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::operator>(clang::interp::Integral<16u, false>) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::operator>(clang::interp::Integral<32u, true>) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::operator>(clang::interp::Integral<32u, false>) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::operator>(clang::interp::Integral<64u, true>) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::operator>(clang::interp::Integral<64u, false>) const
85
  bool operator<=(Integral RHS) const { return V <= RHS.V; }
86
  bool operator>=(Integral RHS) const { return V >= RHS.V; }
87
0
  bool operator==(Integral RHS) const { return V == RHS.V; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::operator==(clang::interp::Integral<8u, true>) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::operator==(clang::interp::Integral<8u, false>) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::operator==(clang::interp::Integral<16u, true>) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::operator==(clang::interp::Integral<16u, false>) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::operator==(clang::interp::Integral<32u, true>) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::operator==(clang::interp::Integral<32u, false>) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::operator==(clang::interp::Integral<64u, true>) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::operator==(clang::interp::Integral<64u, false>) const
88
  bool operator!=(Integral RHS) const { return V != RHS.V; }
89
90
0
  bool operator>(unsigned RHS) const {
91
0
    return V >= 0 && static_cast<unsigned>(V) > RHS;
92
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::operator>(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::operator>(unsigned int) const
93
94
0
  Integral operator-() const { return Integral(-V); }
Unexecuted instantiation: clang::interp::Integral<8u, true>::operator-() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::operator-() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::operator-() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::operator-() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::operator-() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::operator-() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::operator-() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::operator-() const
95
  Integral operator~() const { return Integral(~V); }
96
97
  template <unsigned DstBits, bool DstSign>
98
  explicit operator Integral<DstBits, DstSign>() const {
99
    return Integral<DstBits, DstSign>(V);
100
  }
101
102
  explicit operator unsigned() const { return V; }
103
0
  explicit operator int64_t() const { return V; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::operator long long() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::operator long long() const
104
  explicit operator uint64_t() const { return V; }
105
106
0
  APSInt toAPSInt() const {
107
0
    return APSInt(APInt(Bits, static_cast<uint64_t>(V), Signed), !Signed);
108
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::toAPSInt() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::toAPSInt() const
109
0
  APSInt toAPSInt(unsigned NumBits) const {
110
0
    if (Signed)
111
0
      return APSInt(toAPSInt().sextOrTrunc(NumBits), !Signed);
112
0
    else
113
0
      return APSInt(toAPSInt().zextOrTrunc(NumBits), !Signed);
114
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::toAPSInt(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::toAPSInt(unsigned int) const
115
0
  APValue toAPValue() const { return APValue(toAPSInt()); }
Unexecuted instantiation: clang::interp::Integral<8u, true>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::toAPValue() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::toAPValue() const
116
117
  Integral<Bits, false> toUnsigned() const {
118
    return Integral<Bits, false>(*this);
119
  }
120
121
0
  constexpr static unsigned bitWidth() { return Bits; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<8u, false>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<16u, true>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<16u, false>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<32u, true>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<32u, false>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<64u, true>::bitWidth()
Unexecuted instantiation: clang::interp::Integral<64u, false>::bitWidth()
122
123
0
  bool isZero() const { return !V; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::isZero() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::isZero() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::isZero() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::isZero() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::isZero() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::isZero() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::isZero() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::isZero() const
124
125
0
  bool isMin() const { return *this == min(bitWidth()); }
Unexecuted instantiation: clang::interp::Integral<8u, true>::isMin() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::isMin() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::isMin() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::isMin() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::isMin() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::isMin() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::isMin() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::isMin() const
126
127
  bool isMinusOne() const { return Signed && V == T(-1); }
128
129
  constexpr static bool isSigned() { return Signed; }
130
131
0
  bool isNegative() const { return V < T(0); }
Unexecuted instantiation: clang::interp::Integral<8u, true>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::isNegative() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::isNegative() const
132
0
  bool isPositive() const { return !isNegative(); }
Unexecuted instantiation: clang::interp::Integral<8u, true>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<8u, false>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<16u, true>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<16u, false>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<32u, true>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<32u, false>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<64u, true>::isPositive() const
Unexecuted instantiation: clang::interp::Integral<64u, false>::isPositive() const
133
134
0
  ComparisonCategoryResult compare(const Integral &RHS) const {
135
0
    return Compare(V, RHS.V);
136
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::compare(clang::interp::Integral<8u, true> const&) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::compare(clang::interp::Integral<8u, false> const&) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::compare(clang::interp::Integral<16u, true> const&) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::compare(clang::interp::Integral<16u, false> const&) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::compare(clang::interp::Integral<32u, true> const&) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::compare(clang::interp::Integral<32u, false> const&) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::compare(clang::interp::Integral<64u, true> const&) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::compare(clang::interp::Integral<64u, false> const&) const
137
138
  unsigned countLeadingZeros() const { return llvm::countLeadingZeros<T>(V); }
139
140
0
  Integral truncate(unsigned TruncBits) const {
141
0
    if (TruncBits >= Bits)
142
0
      return *this;
143
0
    const T BitMask = (T(1) << T(TruncBits)) - 1;
144
0
    const T SignBit = T(1) << (TruncBits - 1);
145
0
    const T ExtMask = ~BitMask;
146
0
    return Integral((V & BitMask) | (Signed && (V & SignBit) ? ExtMask : 0));
147
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::truncate(unsigned int) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::truncate(unsigned int) const
148
149
0
  void print(llvm::raw_ostream &OS) const { OS << V; }
Unexecuted instantiation: clang::interp::Integral<8u, true>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<8u, false>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<16u, true>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<16u, false>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<32u, true>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<32u, false>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<64u, true>::print(llvm::raw_ostream&) const
Unexecuted instantiation: clang::interp::Integral<64u, false>::print(llvm::raw_ostream&) const
150
151
0
  static Integral min(unsigned NumBits) {
152
0
    return Integral(Min);
153
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<8u, false>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<16u, true>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<16u, false>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<32u, true>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<32u, false>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<64u, true>::min(unsigned int)
Unexecuted instantiation: clang::interp::Integral<64u, false>::min(unsigned int)
154
  static Integral max(unsigned NumBits) {
155
    return Integral(Max);
156
  }
157
158
  template <typename T>
159
0
  static std::enable_if_t<std::is_integral<T>::value, Integral> from(T Value) {
160
0
    return Integral(Value);
161
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<8u, true> >::type clang::interp::Integral<8u, true>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<8u, false> >::type clang::interp::Integral<8u, false>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<16u, true> >::type clang::interp::Integral<16u, true>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<16u, false> >::type clang::interp::Integral<16u, false>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<32u, true> >::type clang::interp::Integral<32u, true>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<32u, false> >::type clang::interp::Integral<32u, false>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<64u, true> >::type clang::interp::Integral<64u, true>::from<int>(int)
Unexecuted instantiation: std::__1::enable_if<std::is_integral<int>::value, clang::interp::Integral<64u, false> >::type clang::interp::Integral<64u, false>::from<int>(int)
162
163
  template <unsigned SrcBits, bool SrcSign>
164
  static std::enable_if_t<SrcBits != 0, Integral>
165
  from(Integral<SrcBits, SrcSign> Value) {
166
    return Integral(Value.V);
167
  }
168
169
  template <bool SrcSign> static Integral from(Integral<0, SrcSign> Value) {
170
    if (SrcSign)
171
      return Integral(Value.V.getSExtValue());
172
    else
173
      return Integral(Value.V.getZExtValue());
174
  }
175
176
0
  static Integral zero() { return from(0); }
Unexecuted instantiation: clang::interp::Integral<8u, true>::zero()
Unexecuted instantiation: clang::interp::Integral<8u, false>::zero()
Unexecuted instantiation: clang::interp::Integral<16u, true>::zero()
Unexecuted instantiation: clang::interp::Integral<16u, false>::zero()
Unexecuted instantiation: clang::interp::Integral<32u, true>::zero()
Unexecuted instantiation: clang::interp::Integral<32u, false>::zero()
Unexecuted instantiation: clang::interp::Integral<64u, true>::zero()
Unexecuted instantiation: clang::interp::Integral<64u, false>::zero()
177
178
0
  template <typename T> static Integral from(T Value, unsigned NumBits) {
179
0
    return Integral(Value);
180
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true> clang::interp::Integral<8u, true>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<8u, false> clang::interp::Integral<8u, false>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<16u, true> clang::interp::Integral<16u, true>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<16u, false> clang::interp::Integral<16u, false>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<32u, true> clang::interp::Integral<32u, true>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<32u, false> clang::interp::Integral<32u, false>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<64u, true> clang::interp::Integral<64u, true>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<64u, false> clang::interp::Integral<64u, false>::from<long long>(long long, unsigned int)
Unexecuted instantiation: clang::interp::Integral<8u, true> clang::interp::Integral<8u, true>::from<unsigned int>(unsigned int, unsigned int)
Unexecuted instantiation: clang::interp::Integral<16u, false> clang::interp::Integral<16u, false>::from<unsigned int>(unsigned int, unsigned int)
Unexecuted instantiation: clang::interp::Integral<32u, false> clang::interp::Integral<32u, false>::from<unsigned int>(unsigned int, unsigned int)
181
182
  static bool inRange(int64_t Value, unsigned NumBits) {
183
    return CheckRange<T, Min, Max>(Value);
184
  }
185
186
  static bool increment(Integral A, Integral *R) {
187
    return add(A, Integral(T(1)), A.bitWidth(), R);
188
  }
189
190
  static bool decrement(Integral A, Integral *R) {
191
    return sub(A, Integral(T(1)), A.bitWidth(), R);
192
  }
193
194
0
  static bool add(Integral A, Integral B, unsigned OpBits, Integral *R) {
195
0
    return CheckAddUB(A.V, B.V, R->V);
196
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::add(clang::interp::Integral<8u, true>, clang::interp::Integral<8u, true>, unsigned int, clang::interp::Integral<8u, true>*)
Unexecuted instantiation: clang::interp::Integral<8u, false>::add(clang::interp::Integral<8u, false>, clang::interp::Integral<8u, false>, unsigned int, clang::interp::Integral<8u, false>*)
Unexecuted instantiation: clang::interp::Integral<16u, true>::add(clang::interp::Integral<16u, true>, clang::interp::Integral<16u, true>, unsigned int, clang::interp::Integral<16u, true>*)
Unexecuted instantiation: clang::interp::Integral<16u, false>::add(clang::interp::Integral<16u, false>, clang::interp::Integral<16u, false>, unsigned int, clang::interp::Integral<16u, false>*)
Unexecuted instantiation: clang::interp::Integral<32u, true>::add(clang::interp::Integral<32u, true>, clang::interp::Integral<32u, true>, unsigned int, clang::interp::Integral<32u, true>*)
Unexecuted instantiation: clang::interp::Integral<32u, false>::add(clang::interp::Integral<32u, false>, clang::interp::Integral<32u, false>, unsigned int, clang::interp::Integral<32u, false>*)
Unexecuted instantiation: clang::interp::Integral<64u, true>::add(clang::interp::Integral<64u, true>, clang::interp::Integral<64u, true>, unsigned int, clang::interp::Integral<64u, true>*)
Unexecuted instantiation: clang::interp::Integral<64u, false>::add(clang::interp::Integral<64u, false>, clang::interp::Integral<64u, false>, unsigned int, clang::interp::Integral<64u, false>*)
197
198
0
  static bool sub(Integral A, Integral B, unsigned OpBits, Integral *R) {
199
0
    return CheckSubUB(A.V, B.V, R->V);
200
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::sub(clang::interp::Integral<8u, true>, clang::interp::Integral<8u, true>, unsigned int, clang::interp::Integral<8u, true>*)
Unexecuted instantiation: clang::interp::Integral<8u, false>::sub(clang::interp::Integral<8u, false>, clang::interp::Integral<8u, false>, unsigned int, clang::interp::Integral<8u, false>*)
Unexecuted instantiation: clang::interp::Integral<16u, true>::sub(clang::interp::Integral<16u, true>, clang::interp::Integral<16u, true>, unsigned int, clang::interp::Integral<16u, true>*)
Unexecuted instantiation: clang::interp::Integral<16u, false>::sub(clang::interp::Integral<16u, false>, clang::interp::Integral<16u, false>, unsigned int, clang::interp::Integral<16u, false>*)
Unexecuted instantiation: clang::interp::Integral<32u, true>::sub(clang::interp::Integral<32u, true>, clang::interp::Integral<32u, true>, unsigned int, clang::interp::Integral<32u, true>*)
Unexecuted instantiation: clang::interp::Integral<32u, false>::sub(clang::interp::Integral<32u, false>, clang::interp::Integral<32u, false>, unsigned int, clang::interp::Integral<32u, false>*)
Unexecuted instantiation: clang::interp::Integral<64u, true>::sub(clang::interp::Integral<64u, true>, clang::interp::Integral<64u, true>, unsigned int, clang::interp::Integral<64u, true>*)
Unexecuted instantiation: clang::interp::Integral<64u, false>::sub(clang::interp::Integral<64u, false>, clang::interp::Integral<64u, false>, unsigned int, clang::interp::Integral<64u, false>*)
201
202
0
  static bool mul(Integral A, Integral B, unsigned OpBits, Integral *R) {
203
0
    return CheckMulUB(A.V, B.V, R->V);
204
0
  }
Unexecuted instantiation: clang::interp::Integral<8u, true>::mul(clang::interp::Integral<8u, true>, clang::interp::Integral<8u, true>, unsigned int, clang::interp::Integral<8u, true>*)
Unexecuted instantiation: clang::interp::Integral<8u, false>::mul(clang::interp::Integral<8u, false>, clang::interp::Integral<8u, false>, unsigned int, clang::interp::Integral<8u, false>*)
Unexecuted instantiation: clang::interp::Integral<16u, true>::mul(clang::interp::Integral<16u, true>, clang::interp::Integral<16u, true>, unsigned int, clang::interp::Integral<16u, true>*)
Unexecuted instantiation: clang::interp::Integral<16u, false>::mul(clang::interp::Integral<16u, false>, clang::interp::Integral<16u, false>, unsigned int, clang::interp::Integral<16u, false>*)
Unexecuted instantiation: clang::interp::Integral<32u, true>::mul(clang::interp::Integral<32u, true>, clang::interp::Integral<32u, true>, unsigned int, clang::interp::Integral<32u, true>*)
Unexecuted instantiation: clang::interp::Integral<32u, false>::mul(clang::interp::Integral<32u, false>, clang::interp::Integral<32u, false>, unsigned int, clang::interp::Integral<32u, false>*)
Unexecuted instantiation: clang::interp::Integral<64u, true>::mul(clang::interp::Integral<64u, true>, clang::interp::Integral<64u, true>, unsigned int, clang::interp::Integral<64u, true>*)
Unexecuted instantiation: clang::interp::Integral<64u, false>::mul(clang::interp::Integral<64u, false>, clang::interp::Integral<64u, false>, unsigned int, clang::interp::Integral<64u, false>*)
205
206
private:
207
  template <typename T>
208
  static std::enable_if_t<std::is_signed<T>::value, bool> CheckAddUB(T A, T B,
209
0
                                                                     T &R) {
210
0
    return llvm::AddOverflow<T>(A, B, R);
211
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_signed<signed char>::value, bool>::type clang::interp::Integral<8u, true>::CheckAddUB<signed char>(signed char, signed char, signed char&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<short>::value, bool>::type clang::interp::Integral<16u, true>::CheckAddUB<short>(short, short, short&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<int>::value, bool>::type clang::interp::Integral<32u, true>::CheckAddUB<int>(int, int, int&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<long long>::value, bool>::type clang::interp::Integral<64u, true>::CheckAddUB<long long>(long long, long long, long long&)
212
213
  template <typename T>
214
  static std::enable_if_t<std::is_unsigned<T>::value, bool> CheckAddUB(T A, T B,
215
0
                                                                       T &R) {
216
0
    R = A + B;
217
0
    return false;
218
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned char>::value, bool>::type clang::interp::Integral<8u, false>::CheckAddUB<unsigned char>(unsigned char, unsigned char, unsigned char&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned short>::value, bool>::type clang::interp::Integral<16u, false>::CheckAddUB<unsigned short>(unsigned short, unsigned short, unsigned short&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned int>::value, bool>::type clang::interp::Integral<32u, false>::CheckAddUB<unsigned int>(unsigned int, unsigned int, unsigned int&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned long long>::value, bool>::type clang::interp::Integral<64u, false>::CheckAddUB<unsigned long long>(unsigned long long, unsigned long long, unsigned long long&)
219
220
  template <typename T>
221
  static std::enable_if_t<std::is_signed<T>::value, bool> CheckSubUB(T A, T B,
222
0
                                                                     T &R) {
223
0
    return llvm::SubOverflow<T>(A, B, R);
224
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_signed<signed char>::value, bool>::type clang::interp::Integral<8u, true>::CheckSubUB<signed char>(signed char, signed char, signed char&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<short>::value, bool>::type clang::interp::Integral<16u, true>::CheckSubUB<short>(short, short, short&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<int>::value, bool>::type clang::interp::Integral<32u, true>::CheckSubUB<int>(int, int, int&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<long long>::value, bool>::type clang::interp::Integral<64u, true>::CheckSubUB<long long>(long long, long long, long long&)
225
226
  template <typename T>
227
  static std::enable_if_t<std::is_unsigned<T>::value, bool> CheckSubUB(T A, T B,
228
0
                                                                       T &R) {
229
0
    R = A - B;
230
0
    return false;
231
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned char>::value, bool>::type clang::interp::Integral<8u, false>::CheckSubUB<unsigned char>(unsigned char, unsigned char, unsigned char&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned short>::value, bool>::type clang::interp::Integral<16u, false>::CheckSubUB<unsigned short>(unsigned short, unsigned short, unsigned short&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned int>::value, bool>::type clang::interp::Integral<32u, false>::CheckSubUB<unsigned int>(unsigned int, unsigned int, unsigned int&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned long long>::value, bool>::type clang::interp::Integral<64u, false>::CheckSubUB<unsigned long long>(unsigned long long, unsigned long long, unsigned long long&)
232
233
  template <typename T>
234
  static std::enable_if_t<std::is_signed<T>::value, bool> CheckMulUB(T A, T B,
235
0
                                                                     T &R) {
236
0
    return llvm::MulOverflow<T>(A, B, R);
237
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_signed<signed char>::value, bool>::type clang::interp::Integral<8u, true>::CheckMulUB<signed char>(signed char, signed char, signed char&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<short>::value, bool>::type clang::interp::Integral<16u, true>::CheckMulUB<short>(short, short, short&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<int>::value, bool>::type clang::interp::Integral<32u, true>::CheckMulUB<int>(int, int, int&)
Unexecuted instantiation: std::__1::enable_if<std::is_signed<long long>::value, bool>::type clang::interp::Integral<64u, true>::CheckMulUB<long long>(long long, long long, long long&)
238
239
  template <typename T>
240
  static std::enable_if_t<std::is_unsigned<T>::value, bool> CheckMulUB(T A, T B,
241
0
                                                                       T &R) {
242
0
    R = A * B;
243
0
    return false;
244
0
  }
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned char>::value, bool>::type clang::interp::Integral<8u, false>::CheckMulUB<unsigned char>(unsigned char, unsigned char, unsigned char&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned short>::value, bool>::type clang::interp::Integral<16u, false>::CheckMulUB<unsigned short>(unsigned short, unsigned short, unsigned short&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned int>::value, bool>::type clang::interp::Integral<32u, false>::CheckMulUB<unsigned int>(unsigned int, unsigned int, unsigned int&)
Unexecuted instantiation: std::__1::enable_if<std::is_unsigned<unsigned long long>::value, bool>::type clang::interp::Integral<64u, false>::CheckMulUB<unsigned long long>(unsigned long long, unsigned long long, unsigned long long&)
245
246
  template <typename T, T Min, T Max>
247
  static std::enable_if_t<std::is_signed<T>::value, bool>
248
  CheckRange(int64_t V) {
249
    return Min <= V && V <= Max;
250
  }
251
252
  template <typename T, T Min, T Max>
253
  static std::enable_if_t<std::is_unsigned<T>::value, bool>
254
  CheckRange(int64_t V) {
255
    return V >= 0 && static_cast<uint64_t>(V) <= Max;
256
  }
257
};
258
259
template <unsigned Bits, bool Signed>
260
0
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, Integral<Bits, Signed> I) {
261
0
  I.print(OS);
262
0
  return OS;
263
0
}
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<8u, true>(llvm::raw_ostream&, clang::interp::Integral<8u, true>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<8u, false>(llvm::raw_ostream&, clang::interp::Integral<8u, false>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<16u, true>(llvm::raw_ostream&, clang::interp::Integral<16u, true>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<16u, false>(llvm::raw_ostream&, clang::interp::Integral<16u, false>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<32u, true>(llvm::raw_ostream&, clang::interp::Integral<32u, true>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<32u, false>(llvm::raw_ostream&, clang::interp::Integral<32u, false>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<64u, true>(llvm::raw_ostream&, clang::interp::Integral<64u, true>)
Unexecuted instantiation: llvm::raw_ostream& clang::interp::operator<<<64u, false>(llvm::raw_ostream&, clang::interp::Integral<64u, false>)
264
265
} // namespace interp
266
} // namespace clang
267
268
#endif