13#ifndef LLVM_CLANG_SEMA_OWNERSHIP_H
14#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"
50 template <
class PtrTy>
54 explicit OpaquePtr(
void *Ptr) : Ptr(Ptr) {}
61 static OpaquePtr
make(PtrTy P) { OpaquePtr OP; OP.
set(P);
return OP; }
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; }
153template <class PtrTy, bool Compress = IsResultPtrLowBitFree<PtrTy>::value>
156 bool Invalid =
false;
168 bool isUnset()
const {
return !Invalid && !Val; }
171 PtrTy
get()
const {
return Val; }
172 template <
typename T>
T *
getAs() {
return static_cast<T *
>(
get()); }
183 static constexpr uintptr_t UnsetValue = 0x0;
184 static constexpr uintptr_t InvalidValue = 0x1;
192 : Value(Invalid ? InvalidValue : UnsetValue) {}
200 bool isInvalid()
const {
return Value == InvalidValue; }
201 bool isUnset()
const {
return Value == UnsetValue; }
205 void *VP =
reinterpret_cast<void *
>(Value & ~0x01);
206 return PtrTraits::getFromVoidPointer(VP);
208 template <
typename T>
T *
getAs() {
return static_cast<T *
>(
get()); }
211 void *VP = PtrTraits::getAsVoidPointer(RHS);
213 assert((Value & 0x01) == 0 &&
"Badly aligned pointer");
222 assert(
Result.isInvalid() ||
223 PtrTraits::getAsVoidPointer(
Result.get()) == P);
276 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
281 assert(!R.
isInvalid() &&
"operation was asserted to never fail!");
Defines the C++ template declaration subclasses.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static ActionResult getFromOpaquePointer(void *P)
void * getAsOpaquePointer() const
ActionResult(bool Invalid=false)
ActionResult(const void *)=delete
ActionResult & operator=(PtrTy RHS)
ActionResult(volatile void *)=delete
ActionResult(const DiagnosticBuilder &)
The result of parsing/analyzing an expression, statement etc.
ActionResult(const void *)=delete
ActionResult & operator=(PtrTy RHS)
ActionResult(volatile void *)=delete
ActionResult(bool Invalid=false)
ActionResult(const DiagnosticBuilder &)
Represents a base class of a C++ class.
Represents a C++ base or member initializer.
Decl - This represents one declaration (or definition), e.g.
A little helper class used to produce diagnostics.
This represents one expression.
Wrapper for void* pointer.
PointeeT * getPtrTo() const
Returns plain pointer to the entity pointed by this wrapper.
OpaquePtr(std::nullptr_t=nullptr)
PtrT getPtrAs() const
Returns pointer converted to the specified type.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *P)
static OpaquePtr make(PtrTy P)
Represents the parsed form of a C++ template argument.
A (possibly-)qualified type.
Stmt - This represents one statement.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Represents a C++ template name within the type system.
Stores a list of template parameters for a TemplateDecl and its derived classes.
The JSON file list parser is used to communicate input to InstallAPI.
OpaquePtr< TemplateName > ParsedTemplateTy
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Expr * AssertSuccess(ExprResult R)
ActionResult< Decl * > DeclResult
MutableArrayRef< Expr * > MultiExprArg
MutableArrayRef< ParsedType > MultiTypeArg
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
UnionOpaquePtr< QualType > UnionParsedType
ActionResult< CXXCtorInitializer * > MemInitResult
const FunctionProtoType * T
ActionResult< CXXBaseSpecifier * > BaseResult
UnionOpaquePtr< TemplateName > UnionParsedTemplateTy
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
MutableArrayRef< Stmt * > MultiStmtArg
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
UnionOpaquePtr - A version of OpaquePtr suitable for membership in a union.
OpaquePtr< T > get() const
static UnionOpaquePtr make(OpaquePtr< T > P)
UnionOpaquePtr & operator=(OpaquePtr< T > P)
static constexpr int NumLowBitsAvailable
static clang::OpaquePtr< T > getFromVoidPointer(void *P)
static void * getAsVoidPointer(clang::OpaquePtr< T > P)