14 #ifndef LLVM_CLANG_SEMA_OWNERSHIP_H 15 #define LLVM_CLANG_SEMA_OWNERSHIP_H 19 #include "llvm/ADT/ArrayRef.h" 20 #include "llvm/Support/PointerLikeTypeTraits.h" 21 #include "llvm/Support/type_traits.h" 32 class CXXBaseSpecifier;
33 class CXXCtorInitializer;
36 class ParsedTemplateArgument;
40 class TemplateParameterList;
50 template <
class PtrTy>
54 explicit OpaquePtr(
void *Ptr) : Ptr(Ptr) {}
67 template <
typename Po
inteeT> PointeeT*
getPtrTo()
const {
77 template <
typename PtrT> PtrT
getPtrAs()
const {
82 return Traits::getFromVoidPointer(Ptr);
86 Ptr = Traits::getAsVoidPointer(
P);
89 explicit operator bool()
const {
return Ptr !=
nullptr; }
120 enum { NumLowBitsAvailable = 0 };
140 class DiagnosticBuilder;
147 static const bool value =
false;
155 template<
class PtrTy,
172 bool isUnset()
const {
return !Invalid && !Val; }
174 PtrTy
get()
const {
return Val; }
175 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
177 void set(PtrTy V) { Val = V; }
188 template<
typename PtrTy>
198 : PtrWithInvalid(static_cast<
uintptr_t>(Invalid)) {}
201 void *VP = PtrTraits::getAsVoidPointer(V);
202 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
203 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
212 bool isInvalid()
const {
return PtrWithInvalid & 0x01; }
213 bool isUsable()
const {
return PtrWithInvalid > 0x01; }
214 bool isUnset()
const {
return PtrWithInvalid == 0; }
217 void *VP =
reinterpret_cast<void *
>(PtrWithInvalid & ~0x01);
218 return PtrTraits::getFromVoidPointer(VP);
221 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
224 void *VP = PtrTraits::getAsVoidPointer(V);
225 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
226 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
230 void *VP = PtrTraits::getAsVoidPointer(RHS);
231 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
232 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
255 static const bool value =
true;
258 static const bool value =
true;
261 static const bool value =
true;
264 static const bool value =
true;
293 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
298 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
304 #endif // LLVM_CLANG_SEMA_OWNERSHIP_H OpaquePtr(std::nullptr_t=nullptr)
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
Expr - This represents one expression.
The result type of a method or function.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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)