14 #ifndef LLVM_CLANG_SEMA_OWNERSHIP_H
15 #define LLVM_CLANG_SEMA_OWNERSHIP_H
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/PointerIntPair.h"
27 class CXXCtorInitializer;
28 class CXXBaseSpecifier;
31 class ParsedTemplateArgument;
35 class TemplateParameterList;
45 template <
class PtrTy>
48 explicit OpaquePtr(
void *Ptr) : Ptr(Ptr) {}
61 template <
typename Po
inteeT> PointeeT*
getPtrTo()
const {
71 template <
typename PtrT> PtrT
getPtrAs()
const {
76 return Traits::getFromVoidPointer(Ptr);
80 Ptr = Traits::getAsVoidPointer(P);
83 explicit operator bool()
const {
return Ptr !=
nullptr; }
120 enum { NumLowBitsAvailable = 0 };
124 struct isPodLike<clang::OpaquePtr<T> > {
static const bool value =
true; };
129 class DiagnosticBuilder;
144 template<
class PtrTy,
152 : Val(PtrTy()), Invalid(Invalid) {}
162 bool isUnset()
const {
return !Invalid && !Val; }
164 PtrTy
get()
const {
return Val; }
165 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
167 void set(PtrTy V) { Val = V; }
178 template<
typename PtrTy>
186 : PtrWithInvalid(static_cast<
uintptr_t>(Invalid)) { }
189 void *VP = PtrTraits::getAsVoidPointer(V);
190 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
191 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
199 bool isInvalid()
const {
return PtrWithInvalid & 0x01; }
200 bool isUsable()
const {
return PtrWithInvalid > 0x01; }
201 bool isUnset()
const {
return PtrWithInvalid == 0; }
204 void *VP =
reinterpret_cast<void *
>(PtrWithInvalid & ~0x01);
205 return PtrTraits::getFromVoidPointer(VP);
207 template <
typename T> T *
getAs() {
return static_cast<T*
>(
get()); }
210 void *VP = PtrTraits::getAsVoidPointer(V);
211 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
212 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
216 void *VP = PtrTraits::getAsVoidPointer(RHS);
217 PtrWithInvalid =
reinterpret_cast<uintptr_t>(VP);
218 assert((PtrWithInvalid & 0x01) == 0 &&
"Badly aligned pointer");
241 static const bool value =
true;
244 static const bool value =
true;
247 static const bool value =
true;
250 static const bool value =
true;
278 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
283 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
OpaquePtr(std::nullptr_t=nullptr)
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
An opaque type for threading parsed type information through the parser.
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
Expr - This represents one expression.
void * getAsOpaquePointer() const
ActionResult< CXXCtorInitializer * > MemInitResult
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)
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)
UnionOpaquePtr - A version of OpaquePtr suitable for membership in a union.
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