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

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CLANG_AST_COMMENTLEXER_H

14#define LLVM_CLANG_AST_COMMENTLEXER_H

15

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

19#include "llvm/ADT/StringRef.h"

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

21#include "llvm/Support/raw_ostream.h"

22

24namespace comments {

25

26class Lexer;

27class TextTokenRetokenizer;

28struct CommandInfo;

29class CommandTraits;

30

31namespace tok {

38 at_command,

52}

53

54

58

59

61

62

64

65

66

67

68

69

70 unsigned IntVal;

71

72

73

74 unsigned Length;

75

76

77 const char *TextPtr;

78

79public:

82

84 if (Length == 0 || Length == 1)

85 return Loc;

86 return Loc.getLocWithOffset(Length - 1);

87 }

88

91

94

95 unsigned getLength() const LLVM_READONLY { return Length; }

96 void setLength(unsigned L) { Length = L; }

97

98 StringRef getText() const LLVM_READONLY {

100 return StringRef(TextPtr, IntVal);

101 }

102

105 TextPtr = Text.data();

106 IntVal = Text.size();

107 }

108

111 return StringRef(TextPtr, IntVal);

112 }

113

116 TextPtr = Name.data();

117 IntVal = Name.size();

118 }

119

122 return IntVal;

123 }

124

127 IntVal = ID;

128 }

129

132 return IntVal;

133 }

134

137 IntVal = ID;

138 }

139

142 return StringRef(TextPtr, IntVal);

143 }

144

147 TextPtr = Text.data();

148 IntVal = Text.size();

149 }

150

153 return IntVal;

154 }

155

158 IntVal = ID;

159 }

160

163 return StringRef(TextPtr, IntVal);

164 }

165

168 TextPtr = Text.data();

169 IntVal = Text.size();

170 }

171

174 return StringRef(TextPtr, IntVal);

175 }

176

179 TextPtr = Name.data();

180 IntVal = Name.size();

181 }

182

185 return StringRef(TextPtr, IntVal);

186 }

187

190 TextPtr = Name.data();

191 IntVal = Name.size();

192 }

193

196 return StringRef(TextPtr, IntVal);

197 }

198

201 TextPtr = Str.data();

202 IntVal = Str.size();

203 }

204

207 return StringRef(TextPtr, IntVal);

208 }

209

212 TextPtr = Name.data();

213 IntVal = Name.size();

214 }

215

217};

218

219

221private:

223 void operator=(const Lexer &) = delete;

224

225

226

227 llvm::BumpPtrAllocator &Allocator;

228

230

232

233 const char *const BufferStart;

234 const char *const BufferEnd;

235

236 const char *BufferPtr;

237

238

239

240 const char *CommentEnd;

241

243

244

245

246

247 bool ParseCommands;

248

249 enum LexerCommentState : uint8_t {

250 LCS_BeforeComment,

251 LCS_InsideBCPLComment,

252 LCS_InsideCComment,

253 LCS_BetweenComments

254 };

255

256

257 LexerCommentState CommentState;

258

259 enum LexerState : uint8_t {

260

261 LS_Normal,

262

263

264

265 LS_VerbatimBlockFirstLine,

266

267

268

269 LS_VerbatimBlockBody,

270

271

272

273 LS_VerbatimLineText,

274

275

276 LS_HTMLStartTag,

277

278

279 LS_HTMLEndTag

280 };

281

282

283 LexerState State;

284

285

286

288

289

290

291 StringRef resolveHTMLNamedCharacterReference(StringRef Name) const;

292

293

294 StringRef resolveHTMLDecimalCharacterReference(StringRef Name) const;

295

296

297 StringRef resolveHTMLHexCharacterReference(StringRef Name) const;

298

299 void formTokenWithChars(Token &Result, const char *TokEnd,

301

302 void formTextToken(Token &Result, const char *TokEnd) {

303 StringRef Text(BufferPtr, TokEnd - BufferPtr);

306 }

307

309 assert(Loc >= BufferStart && Loc <= BufferEnd &&

310 "Location out of range for this buffer!");

311

312 const unsigned CharNo = Loc - BufferStart;

314 }

315

317 return Diags.Report(Loc, DiagID);

318 }

319

320

321 void skipLineStartingDecorations();

322

323

324 const char *skipTextToken();

325

326

327 void lexCommentText(Token &T);

328

329 void setupAndLexVerbatimBlock(Token &T, const char *TextBegin, char Marker,

331

332 void lexVerbatimBlockFirstLine(Token &T);

333

334 void lexVerbatimBlockBody(Token &T);

335

336 void setupAndLexVerbatimLine(Token &T, const char *TextBegin,

338

339 void lexVerbatimLineText(Token &T);

340

341 void lexHTMLCharacterReference(Token &T);

342

343 void setupAndLexHTMLStartTag(Token &T);

344

345 void lexHTMLStartTag(Token &T);

346

347 void setupAndLexHTMLEndTag(Token &T);

348

349 void lexHTMLEndTag(Token &T);

350

351public:

354 const char *BufferStart, const char *BufferEnd,

355 bool ParseCommands = true);

356

358

360};

361

362}

363}

364

365#endif

366

Defines the Diagnostic-related interfaces.

enum clang::sema::@1725::IndirectLocalPathEntry::EntryKind Kind

Defines the SourceManager interface.

A little helper class used to produce diagnostics.

Concrete class used by the front-end to report problems and issues.

DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)

Issue the message to the client.

Encodes a location in the source.

SourceLocation getLocWithOffset(IntTy Offset) const

Return a source location with the specified offset from this SourceLocation.

This class handles loading and caching of source files into memory.

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

@ Result

The result type of a method or function.

const FunctionProtoType * T