File indexing completed on 2026-05-10 08:37:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_APSIntPtr_H
0010 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_APSIntPtr_H
0011
0012 #include "llvm/ADT/APSInt.h"
0013 #include "llvm/Support/Compiler.h"
0014
0015 namespace clang::ento {
0016
0017
0018
0019 class APSIntPtr {
0020 using APSInt = llvm::APSInt;
0021
0022 public:
0023 APSIntPtr() = delete;
0024 APSIntPtr(const APSIntPtr &) = default;
0025 APSIntPtr &operator=(const APSIntPtr &) & = default;
0026 ~APSIntPtr() = default;
0027
0028
0029
0030
0031 static APSIntPtr unsafeConstructor(const APSInt *Ptr) {
0032 return APSIntPtr(Ptr);
0033 }
0034
0035 LLVM_ATTRIBUTE_RETURNS_NONNULL
0036 const APSInt *get() const { return Ptr; }
0037 operator const APSInt &() const { return *get(); }
0038
0039 APSInt operator-() const { return -*Ptr; }
0040 APSInt operator~() const { return ~*Ptr; }
0041
0042 #define DEFINE_OPERATOR(OP) \
0043 bool operator OP(APSIntPtr Other) const { return (*Ptr)OP(*Other.Ptr); }
0044 DEFINE_OPERATOR(>)
0045 DEFINE_OPERATOR(>=)
0046 DEFINE_OPERATOR(<)
0047 DEFINE_OPERATOR(<=)
0048 DEFINE_OPERATOR(==)
0049 DEFINE_OPERATOR(!=)
0050 #undef DEFINE_OPERATOR
0051
0052 const APSInt &operator*() const { return *Ptr; }
0053 const APSInt *operator->() const { return Ptr; }
0054
0055 private:
0056 explicit APSIntPtr(const APSInt *Ptr) : Ptr(Ptr) {}
0057
0058
0059 const APSInt *Ptr;
0060 };
0061
0062 }
0063
0064 #endif