14 #ifndef LLVM_CLANG_SEMA_OWNERSHIP_H
15 #define LLVM_CLANG_SEMA_OWNERSHIP_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/PointerIntPair.h"
26 class CXXCtorInitializer;
27 class CXXBaseSpecifier;
30 class ParsedTemplateArgument;
34 class TemplateParameterList;
44 template <
class PtrTy>
47 explicit OpaquePtr(
void *Ptr) : Ptr(Ptr) {}
60 template <
typename Po
inteeT> PointeeT*
getPtrTo()
const {
70 template <
typename PtrT> PtrT
getPtrAs()
const {
75 return Traits::getFromVoidPointer(Ptr);
79 Ptr = Traits::getAsVoidPointer(P);
82 explicit operator bool()
const {
return Ptr !=
nullptr; }
119 enum { NumLowBitsAvailable = 0 };
123 struct isPodLike<clang::OpaquePtr<T> > {
static const bool value =
true; };
128 class DiagnosticBuilder;
143 template<
class PtrTy,
151 : Val(PtrTy()), Invalid(Invalid) {}
161 bool isUnset()
const {
return !Invalid && !Val; }
163 PtrTy
get()
const {
return Val; }
164 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
166 void set(PtrTy V) { Val = V; }
177 template<
typename PtrTy>
181 uintptr_t PtrWithInvalid;
185 : PtrWithInvalid(static_cast<uintptr_t>(Invalid)) { }
188 void *VP = PtrTraits::getAsVoidPointer(V);
189 PtrWithInvalid =
reinterpret_cast<uintptr_t
>(VP);
190 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
198 bool isInvalid()
const {
return PtrWithInvalid & 0x01; }
199 bool isUsable()
const {
return PtrWithInvalid > 0x01; }
200 bool isUnset()
const {
return PtrWithInvalid == 0; }
203 void *VP =
reinterpret_cast<void *
>(PtrWithInvalid & ~0x01);
204 return PtrTraits::getFromVoidPointer(VP);
206 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
209 void *VP = PtrTraits::getAsVoidPointer(V);
210 PtrWithInvalid =
reinterpret_cast<uintptr_t
>(VP);
211 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
215 void *VP = PtrTraits::getAsVoidPointer(RHS);
216 PtrWithInvalid =
reinterpret_cast<uintptr_t
>(VP);
217 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
225 Result.PtrWithInvalid = (uintptr_t)P;
240 static const bool value =
true;
243 static const bool value =
true;
246 static const bool value =
true;
249 static const bool value =
true;
277 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
282 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
UnionOpaquePtr< QualType > UnionParsedType
ActionResult< Expr * > ExprResult
const ActionResult & operator=(PtrTy RHS)
Wrapper for void* pointer.
static ActionResult getFromOpaquePointer(void *P)
MutableArrayRef< Stmt * > MultiStmtArg
OpaquePtr< QualType > ParsedType
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
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.
ActionResult< Decl * > DeclResult
void * getAsOpaquePointer() const
ActionResult< CXXCtorInitializer * > MemInitResult
The result type of a method or function.
ActionResult(bool Invalid=false)
PtrT getPtrAs() const
Returns pointer converted to the specified type.
static UnionOpaquePtr make(OpaquePtr< T > P)
ActionResult< CXXBaseSpecifier * > BaseResult
MutableArrayRef< Expr * > MultiExprArg
static void * getAsVoidPointer(clang::OpaquePtr< T > P)
static clang::OpaquePtr< T > getFromVoidPointer(void *P)
Represents a C++ base or member initializer.
UnionOpaquePtr & operator=(OpaquePtr< T > P)
ActionResult< Stmt * > StmtResult
void * getAsOpaquePtr() const
ActionResult< ParsedType > TypeResult
Represents a base class of a C++ class.
ActionResult(bool Invalid=false)
ActionResult(const DiagnosticBuilder &)
OpaquePtr< TemplateName > ParsedTemplateTy
static OpaquePtr make(PtrTy P)
PointeeT * getPtrTo() const
Returns plain pointer to the entity pointed by this wrapper.
Expr * AssertSuccess(ExprResult R)
static OpaquePtr getFromOpaquePtr(void *P)
const ActionResult & operator=(PtrTy RHS)
MutableArrayRef< ParsedType > MultiTypeArg