13 #ifndef LLVM_CLANG_SEMA_OWNERSHIP_H 14 #define LLVM_CLANG_SEMA_OWNERSHIP_H 18 #include "llvm/ADT/ArrayRef.h" 19 #include "llvm/Support/PointerLikeTypeTraits.h" 20 #include "llvm/Support/type_traits.h" 31 class CXXBaseSpecifier;
32 class CXXCtorInitializer;
35 class ParsedTemplateArgument;
39 class TemplateParameterList;
49 template <
class PtrTy>
53 explicit OpaquePtr(
void *Ptr) : Ptr(Ptr) {}
66 template <
typename Po
inteeT> PointeeT*
getPtrTo()
const {
76 template <
typename PtrT> PtrT
getPtrAs()
const {
81 return Traits::getFromVoidPointer(Ptr);
85 Ptr = Traits::getAsVoidPointer(
P);
88 explicit operator bool()
const {
return Ptr !=
nullptr; }
119 enum { NumLowBitsAvailable = 0 };
136 class DiagnosticBuilder;
143 static const bool value =
false;
151 template<
class PtrTy,
168 bool isUnset()
const {
return !Invalid && !Val; }
170 PtrTy
get()
const {
return Val; }
171 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
173 void set(PtrTy
V) { Val =
V; }
184 template<
typename PtrTy>
194 : PtrWithInvalid(static_cast<
uintptr_t>(Invalid)) {}
197 void *VP = PtrTraits::getAsVoidPointer(V);
198 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
199 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
208 bool isInvalid()
const {
return PtrWithInvalid & 0x01; }
209 bool isUsable()
const {
return PtrWithInvalid > 0x01; }
210 bool isUnset()
const {
return PtrWithInvalid == 0; }
213 void *VP =
reinterpret_cast<void *
>(PtrWithInvalid & ~0x01);
214 return PtrTraits::getFromVoidPointer(VP);
217 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
220 void *VP = PtrTraits::getAsVoidPointer(
V);
221 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
222 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
226 void *VP = PtrTraits::getAsVoidPointer(RHS);
227 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
228 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
251 static const bool value =
true;
254 static const bool value =
true;
257 static const bool value =
true;
260 static const bool value =
true;
289 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
294 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
300 #endif // LLVM_CLANG_SEMA_OWNERSHIP_H OpaquePtr(std::nullptr_t=nullptr)
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
PointeeT * getPtrTo() const
Returns plain pointer to the entity pointed by this wrapper.
Stmt - This represents one statement.
const ActionResult & operator=(PtrTy RHS)
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Wrapper for void* pointer.
static ActionResult getFromOpaquePointer(void *P)
ActionResult< Stmt * > StmtResult
PtrT getPtrAs() const
Returns pointer converted to the specified type.
void * getAsOpaquePtr() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
ActionResult(const DiagnosticBuilder &)
A little helper class used to produce diagnostics.
This represents one expression.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
The result type of a method or function.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ActionResult(bool Invalid=false)
static UnionOpaquePtr make(OpaquePtr< T > P)
UnionOpaquePtr - A version of OpaquePtr suitable for membership in a union.
Dataflow Directional Tag Classes.
static void * getAsVoidPointer(clang::OpaquePtr< T > P)
Represents a C++ base or member initializer.
UnionOpaquePtr & operator=(OpaquePtr< T > P)
static clang::OpaquePtr< T > getFromVoidPointer(void *P)
Represents a base class of a C++ class.
ActionResult< Expr * > ExprResult
void * getAsOpaquePointer() const
ActionResult(bool Invalid=false)
ActionResult(const DiagnosticBuilder &)
static OpaquePtr make(PtrTy P)
Expr * AssertSuccess(ExprResult R)
static OpaquePtr getFromOpaquePtr(void *P)
const ActionResult & operator=(PtrTy RHS)