clang: include/clang/AST/AbstractBasicWriter.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CLANG_AST_ABSTRACTBASICWRITER_H

10#define LLVM_CLANG_AST_ABSTRACTBASICWRITER_H

11

14#include

15

17namespace serialization {

18

19template

21 return (value.isNull() ? std::optional() : std::optional(value));

22}

23

25 return (value ? std::optional<T *>(value) : std::optional<T *>());

26}

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98#include "clang/AST/AbstractBasicWriter.inc"

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119template

121protected:

122 using BasicWriterBase::asImpl;

124

125public:

126

127

128 Impl &find(const char *propertyName) {

129 return asImpl();

130 }

131

132

133

135

136 template

138 asImpl().writeUInt32(uint32_t(value));

139 }

140

141 template

143 asImpl().writeUInt32(array.size());

144 for (const T &elt : array) {

145 WriteDispatcher::write(asImpl(), elt);

146 }

147 }

148

149 template void writeOptional(std::optional value) {

150 WriteDispatcher::write(asImpl(), PackOptionalValue::pack(value));

151 }

152

154 asImpl().writeBool(value.isUnsigned());

155 asImpl().writeAPInt(value);

156 }

157

159 asImpl().writeUInt32(value.getBitWidth());

160 const uint64_t *words = value.getRawData();

161 for (size_t i = 0, e = value.getNumWords(); i != e; ++i)

162 asImpl().writeUInt64(words[i]);

163 }

164

166 asImpl().writeUInt32(sema.getWidth());

167 asImpl().writeUInt32(sema.getScale());

168 asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 |

169 sema.hasUnsignedPadding() << 2);

170 }

171

176 asImpl().writeQualType(elemTy);

177 asImpl().writeUInt32(path.size());

178 auto &ctx = ((BasicWriterBase *)this)->getASTContext();

179 for (auto elem : path) {

181 asImpl().writeUInt32(elem.getAsBaseOrMember().getInt());

182 const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer();

183 if (const auto *recordDecl = dyn_cast(baseOrMember)) {

185 elemTy = ctx.getRecordType(recordDecl);

186 } else {

187 const auto *valueDecl = cast(baseOrMember);

188 asImpl().writeDeclRef(valueDecl);

190 }

191 } else {

192 asImpl().writeUInt32(elem.getAsArrayIndex());

193 elemTy = ctx.getAsArrayType(elemTy)->getElementType();

194 }

195 }

196 }

197

199 static_assert(sizeof(value.getAsOpaqueValue()) <= sizeof(uint64_t),

200 "update this if the value size changes");

202 }

203

206 asImpl().writeUInt32(uint32_t(esi.Type));

212 asImpl().writeDeclRef(esi.SourceDecl);

215 asImpl().writeDeclRef(esi.SourceDecl);

216 }

217 }

218

220 static_assert(sizeof(epi.getOpaqueValue()) <= sizeof(uint32_t),

221 "opaque value doesn't fit into uint32_t");

223 }

224

226 asImpl().writeUInt32(E.toOpaqueInt32());

227 }

228

231 }

232

234

235

237

238

239 while (NNS) {

240 nestedNames.push_back(NNS);

242 }

243

244 asImpl().writeUInt32(nestedNames.size());

245 while (!nestedNames.empty()) {

246 NNS = nestedNames.pop_back_val();

248 asImpl().writeNestedNameSpecifierKind(kind);

249 switch (kind) {

252 continue;

253

255 asImpl().writeNamespaceDeclRef(NNS->getAsNamespace());

256 continue;

257

260 continue;

261

265 continue;

266

268

269 continue;

270

273 continue;

274 }

275 llvm_unreachable("bad nested name specifier kind");

276 }

277 }

278};

279

280}

281}

282

283#endif

Defines the clang::ASTContext interface.

Defines the C++ template declaration subclasses.

ArrayRef< LValuePathEntry > Path

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

Decl - This represents one declaration (or definition), e.g.

Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...

Expr * getCondition() const

Represents an abstract function effect, using just an enumeration describing its kind.

Interesting information about a specific parameter that can't simply be reflected in parameter's type...

unsigned char getOpaqueValue() const

Represents a C++ nested name specifier, such as "\::std::vector::".

CXXRecordDecl * getAsRecordDecl() const

Retrieve the record declaration stored in this nested name specifier.

SpecifierKind getKind() const

Determine what kind of nested name specifier is stored.

NamespaceAliasDecl * getAsNamespaceAlias() const

Retrieve the namespace alias stored in this nested name specifier.

IdentifierInfo * getAsIdentifier() const

Retrieve the identifier stored in this nested name specifier.

NestedNameSpecifier * getPrefix() const

Return the prefix of this nested name specifier.

SpecifierKind

The kind of specifier that completes this nested name specifier.

@ NamespaceAlias

A namespace alias, stored as a NamespaceAliasDecl*.

@ TypeSpec

A type, stored as a Type*.

@ TypeSpecWithTemplate

A type that was preceded by the 'template' keyword, stored as a Type*.

@ Super

Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.

@ Identifier

An identifier, stored as an IdentifierInfo*.

@ Global

The global specifier '::'. There is no stored value.

@ Namespace

A namespace, stored as a NamespaceDecl*.

NamespaceDecl * getAsNamespace() const

Retrieve the namespace stored in this nested name specifier.

const Type * getAsType() const

Retrieve the type stored in this nested name specifier.

A (possibly-)qualified type.

The collection of all-type qualifiers we support.

uint64_t getAsOpaqueValue() const

A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...

const T * getAs() const

Member-template getAs'.

DataStreamBasicWriter provides convenience implementations for many BasicWriter methods based on the ...

void writeEffectConditionExpr(EffectConditionExpr CE)

void writeExceptionSpecInfo(const FunctionProtoType::ExceptionSpecInfo &esi)

void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema)

void writeFunctionEffect(FunctionEffect E)

void writeArray(llvm::ArrayRef< T > array)

DataStreamBasicWriter(ASTContext &ctx)

void writeOptional(std::optional< T > value)

void writeExtParameterInfo(FunctionProtoType::ExtParameterInfo epi)

void writeAPInt(const llvm::APInt &value)

Impl & find(const char *propertyName)

Implement property-find by ignoring it.

void writeAPSInt(const llvm::APSInt &value)

void writeLValuePathSerializationHelper(APValue::LValuePathSerializationHelper lvaluePath)

void writeQualifiers(Qualifiers value)

void writeNestedNameSpecifier(NestedNameSpecifier *NNS)

const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > valueDecl

Matches any value declaration.

const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl

Matches class, struct, and union declarations.

std::optional< T > makeOptionalFromNullable(const T &value)

std::optional< T * > makeOptionalFromPointer(T *value)

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

bool isComputedNoexcept(ExceptionSpecificationType ESpecType)

const FunctionProtoType * T

@ EST_Uninstantiated

not instantiated yet

@ EST_Unevaluated

not evaluated yet, for special member function

@ EST_Dynamic

throw(T1, T2)

Holds information about the various types of exception specification.

FunctionDecl * SourceDecl

The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.

FunctionDecl * SourceTemplate

The function template whose exception specification this is instantiated from, for EST_Uninstantiated...

ExceptionSpecificationType Type

The kind of exception specification this is.

ArrayRef< QualType > Exceptions

Explicitly-specified list of exception types.

Expr * NoexceptExpr

Noexcept expression, if this is a computed noexcept specification.