15#include "llvm/Support/ErrorHandling.h"
20 for (StringRef::const_iterator I = S.begin(), E = S.end(); I != E; ++I) {
31 llvm::BumpPtrAllocator &Allocator;
35 bool NoMoreInterestingTokens;
42 const char *BufferStart;
43 const char *BufferEnd;
44 const char *BufferPtr;
53 return Pos.CurToken >= Toks.size();
59 const Token &Tok = Toks[Pos.CurToken];
61 Pos.BufferStart = Tok.
getText().begin();
62 Pos.BufferEnd = Tok.
getText().end();
63 Pos.BufferPtr = Pos.BufferStart;
68 const unsigned CharNo = Pos.BufferPtr - Pos.BufferStart;
69 return Pos.BufferStartLoc.getLocWithOffset(CharNo);
74 assert(Pos.BufferPtr != Pos.BufferEnd);
75 return *Pos.BufferPtr;
80 assert(Pos.BufferPtr != Pos.BufferEnd);
82 if (Pos.BufferPtr == Pos.BufferEnd) {
84 if (isEnd() && !addToken())
96 if (NoMoreInterestingTokens)
105 NoMoreInterestingTokens =
true;
110 NoMoreInterestingTokens =
true;
114 Toks.push_back(
P.Tok);
116 if (Toks.size() == 1)
121 void consumeWhitespace() {
132 const char *TokBegin,
137 Result.setLength(TokLength);
139 Result.TextPtr =
"<UNSET>";
147 Allocator(Allocator),
P(
P), NoMoreInterestingTokens(
false) {
157 Position SavedPos = Pos;
161 const char *WordBegin = Pos.BufferPtr;
164 const char C = peek();
166 WordText.push_back(
C);
171 const unsigned Length = WordText.size();
177 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
179 memcpy(TextPtr, WordText.c_str(), Length + 1);
180 StringRef
Text = StringRef(TextPtr, Length);
182 formTokenWithChars(Tok, Loc, WordBegin, Length,
Text);
190 Position SavedPos = Pos;
194 const char *WordBegin = Pos.BufferPtr;
198 const char C = peek();
199 if (
C == OpenDelim) {
200 WordText.push_back(
C);
206 while (!
Error && !isEnd()) {
208 WordText.push_back(
C);
213 if (!
Error &&
C != CloseDelim)
221 const unsigned Length = WordText.size();
222 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
224 memcpy(TextPtr, WordText.c_str(), Length + 1);
225 StringRef
Text = StringRef(TextPtr, Length);
227 formTokenWithChars(Tok, Loc, WordBegin,
228 Pos.BufferPtr - WordBegin,
Text);
237 bool HavePartialTok =
false;
239 if (Pos.BufferPtr != Pos.BufferStart) {
240 formTokenWithChars(PartialTok, getSourceLocation(),
241 Pos.BufferPtr, Pos.BufferEnd - Pos.BufferPtr,
242 StringRef(Pos.BufferPtr,
243 Pos.BufferEnd - Pos.BufferPtr));
244 HavePartialTok =
true;
249 Pos.CurToken = Toks.size();
252 P.putBack(PartialTok);
256Parser::Parser(
Lexer &L,
Sema &S, llvm::BumpPtrAllocator &Allocator,
259 L(L), S(S), Allocator(Allocator), SourceMgr(SourceMgr), Diags(Diags),
296 unsigned ParsedArgs = 0;
298 while (ParsedArgs < NumArgs && Retokenizer.
lexWord(Arg)) {
334 if (isTokBlockCommand()) {
350 if (PC || TPC || Info->
NumArgs > 0) {
367 bool EmptyParagraph =
false;
368 if (isTokBlockCommand())
369 EmptyParagraph =
true;
373 EmptyParagraph = isTokBlockCommand();
384 Paragraph = cast<ParagraphComment>(
Block);
403 const Token CommandTok = Tok;
414 if (Args.size() < Info->
NumArgs) {
416 diag::warn_doc_inline_command_not_enough_arguments)
449 diag::warn_doc_html_start_tag_expected_quoted_string)
461 Equals.getLocation(),
486 diag::warn_doc_html_start_tag_expected_ident_or_greater);
505 bool StartLineInvalid;
513 if (StartLineInvalid || EndLineInvalid || StartLine == EndLine)
515 diag::warn_doc_html_start_tag_expected_ident_or_greater)
519 diag::warn_doc_html_start_tag_expected_ident_or_greater);
520 Diag(HST->
getLocation(), diag::note_doc_html_tag_started_here)
530 Token TokEndTag = Tok;
564 if (Content.size() == 0)
570 diag::warn_verbatim_block_end_without_start)
598 Token WhitespaceTok = Tok;
605 putBack(WhitespaceTok);
607 if (Content.size() > 0)
608 Content.back()->addTrailingNewline();
636 llvm_unreachable(
"should not see this token");
673 Lines.push_back(Line);
742 llvm_unreachable(
"should not see this token");
744 llvm_unreachable(
"bogus token kind");
Defines the SourceManager interface.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Concrete class used by the front-end to report problems and issues.
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.
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...