clang: include/clang/Sema/Ownership.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CLANG_SEMA_OWNERSHIP_H

14#define LLVM_CLANG_SEMA_OWNERSHIP_H

15

18#include "llvm/ADT/ArrayRef.h"

19#include "llvm/Support/PointerLikeTypeTraits.h"

20#include "llvm/Support/type_traits.h"

21#include

22#include

23#include

24

25

26

27

28

30

31class CXXBaseSpecifier;

32class CXXCtorInitializer;

34class Expr;

35class ParsedTemplateArgument;

36class QualType;

37class Stmt;

38class TemplateName;

39class TemplateParameterList;

40

41

42

43

44

45

46

47

48

49 template

51 void *Ptr = nullptr;

52

53 explicit OpaquePtr(void *Ptr) : Ptr(Ptr) {}

54

56

57 public:

59

61

62

63

64

65

66 template PointeeT* getPtrTo() const {

67 return get();

68 }

69

70

71

72

73

74

75

76 template PtrT getPtrAs() const {

77 return get();

78 }

79

80 PtrTy get() const {

81 return Traits::getFromVoidPointer(Ptr);

82 }

83

85 Ptr = Traits::getAsVoidPointer(P);

86 }

87

88 explicit operator bool() const { return Ptr != nullptr; }

89

92 };

93

94

95

98

101 return OP;

102 }

103

106

108 Ptr = P.getAsOpaquePtr();

109 return *this;

110 }

111 };

112

113}

114

115namespace llvm {

116

117 template

119 static constexpr int NumLowBitsAvailable = 0;

120

122

123 return P.getAsOpaquePtr();

124 }

125

128 }

129 };

130

131}

132

134

135class StreamingDiagnostic;

136

137

138

139

141 static const bool value = false;

142};

143

144

145

146

147

148

149

150

151

152template <class PtrTy, bool Compress = IsResultPtrLowBitFree::value>

154 PtrTy Val = {};

155 bool Invalid = false;

156

157public:

158 ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {}

161

162

165

167 bool isUnset() const { return !Invalid && !Val; }

169

170 PtrTy get() const { return Val; }

171 template T *getAs() { return static_cast<T *>(get()); }

172

174 Val = RHS;

175 Invalid = false;

176 return *this;

177 }

178};

179

180

182 static constexpr uintptr_t UnsetValue = 0x0;

183 static constexpr uintptr_t InvalidValue = 0x1;

184

186

188

189public:

191 : Value(Invalid ? InvalidValue : UnsetValue) {}

194

195

198

202

204 void *VP = reinterpret_cast<void *>(Value & ~0x01);

205 return PtrTraits::getFromVoidPointer(VP);

206 }

207 template T *getAs() { return static_cast<T *>(get()); }

208

210 void *VP = PtrTraits::getAsVoidPointer(RHS);

212 assert((Value & 0x01) == 0 && "Badly aligned pointer");

213 return *this;

214 }

215

216

217

221 assert(Result.isInvalid() ||

222 PtrTraits::getAsVoidPointer(Result.get()) == P);

224 }

226};

227

228

231

232

233

234

236 static const bool value = true;

237};

239 static const bool value = true;

240};

242 static const bool value = true;

243};

245 static const bool value = true;

246};

247

253

257

263

267

270

273

275 assert(!R.isInvalid() && "operation was asserted to never fail!");

276 return R.get();

277}

278

280 assert(!R.isInvalid() && "operation was asserted to never fail!");

281 return R.get();

282}

283

284}

285

286#endif

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.

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)

Stmt - This represents one statement.

The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.

@ Decl

The l-value was an access to a declared entity or something equivalently strong, like the address of ...

The JSON file list parser is used to communicate input to InstallAPI.

Expr * AssertSuccess(ExprResult R)

@ Result

The result type of a method or function.

ActionResult< Expr * > ExprResult

ActionResult< Stmt * > StmtResult

ActionResult< ParsedType > TypeResult

const FunctionProtoType * T

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 clang::OpaquePtr< T > getFromVoidPointer(void *P)

static void * getAsVoidPointer(clang::OpaquePtr< T > P)