Lines Matching refs:End
57 LLVM_NODISCARD IdInfo lexIdentifier(const char *First, const char *const End);
59 const char *const End);
60 LLVM_NODISCARD bool minimizeImpl(const char *First, const char *const End);
61 LLVM_NODISCARD bool lexPPLine(const char *&First, const char *const End);
62 LLVM_NODISCARD bool lexAt(const char *&First, const char *const End);
63 LLVM_NODISCARD bool lexModule(const char *&First, const char *const End);
64 LLVM_NODISCARD bool lexDefine(const char *&First, const char *const End);
65 LLVM_NODISCARD bool lexPragma(const char *&First, const char *const End);
66 LLVM_NODISCARD bool lexEndif(const char *&First, const char *const End);
68 const char *&First, const char *const End);
83 Minimizer &append(StringRef S) { return append(S.begin(), S.end()); }
89 void printToNewline(const char *&First, const char *const End);
90 void printAdjacentModuleNameParts(const char *&First, const char *const End);
92 const char *const End);
93 void printDirectiveBody(const char *&First, const char *const End);
94 void printAdjacentMacroArgs(const char *&First, const char *const End);
95 LLVM_NODISCARD bool printMacroArgs(const char *&First, const char *const End);
98 /// true at the end.
107 } // end anonymous namespace
117 static void skipOverSpaces(const char *&First, const char *const End) {
118 while (First != End && isHorizontalWhitespace(*First))
147 static void skipRawString(const char *&First, const char *const End) {
152 while (Last != End && *Last != '(')
154 if (Last == End) {
155 First = Last; // Hit the end... just give up.
163 while (First != End && *First != ')')
165 if (First == End)
171 while (Last != End && size_t(Last - First) < Terminator.size() &&
175 // Check if we hit it (or the end of the file).
176 if (Last == End) {
189 // Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
190 static unsigned isEOL(const char *First, const char *const End) {
191 if (First == End)
193 if (End - First > 1 && isVerticalWhitespace(First[0]) &&
199 static void skipString(const char *&First, const char *const End) {
202 for (++First; First != End && *First != Terminator; ++First) {
203 // String and character literals don't extend past the end of the line.
211 if (++First == End)
217 skipOverSpaces(FirstAfterBackslashPastSpace, End);
218 if (unsigned NLSize = isEOL(FirstAfterBackslashPastSpace, End)) {
224 if (First != End)
229 static unsigned skipNewline(const char *&First, const char *End) {
230 if (First == End)
233 unsigned Len = isEOL(First, End);
243 static void skipToNewlineRaw(const char *&First, const char *const End) {
245 if (First == End)
248 unsigned Len = isEOL(First, End);
253 if (++First == End)
255 Len = isEOL(First, End);
282 static void skipLineComment(const char *&First, const char *const End) {
285 skipToNewlineRaw(First, End);
288 static void skipBlockComment(const char *&First, const char *const End) {
290 if (End - First < 4) {
291 First = End;
294 for (First += 3; First != End; ++First)
305 const char *const End) {
322 return (Cur + 1) < End && isIdentifierBody(*(Cur + 1));
325 static void skipLine(const char *&First, const char *const End) {
327 assert(First <= End);
328 if (First == End)
332 skipNewline(First, End);
336 while (First != End && !isVerticalWhitespace(*First)) {
339 (*First == '\'' && !isQuoteCppDigitSeparator(Start, First, End))) {
341 skipRawString(First, End);
343 skipString(First, End);
348 if (*First != '/' || End - First < 2) {
355 skipLineComment(First, End);
365 skipBlockComment(First, End);
367 if (First == End)
371 unsigned Len = skipNewline(First, End);
378 const char *const End) {
384 skipToNewlineRaw(First, End);
386 skipLine(First, End);
389 void Minimizer::printToNewline(const char *&First, const char *const End) {
390 while (First != End && !isVerticalWhitespace(*First)) {
397 skipRawString(Last, End);
399 skipString(Last, End);
402 if (*Last != '/' || End - Last < 2) {
417 skipLineComment(First, End);
422 skipBlockComment(First, End);
423 skipOverSpaces(First, End);
425 } while (Last != End && !isVerticalWhitespace(*Last));
429 if (Last == End || LastBeforeTrailingSpace == First ||
433 skipNewline(First, End);
444 skipNewline(First, End);
445 skipOverSpaces(First, End);
449 static void skipWhitespace(const char *&First, const char *const End) {
451 assert(First <= End);
452 skipOverSpaces(First, End);
454 if (End - First < 2)
458 skipNewline(++First, End);
468 skipLineComment(First, End);
477 skipBlockComment(First, End);
482 const char *const End) {
487 while (Last != End && (isIdentifierBody(*Last) || *Last == '.'));
492 bool Minimizer::printAtImportBody(const char *&First, const char *const End) {
494 skipWhitespace(First, End);
495 if (First == End)
499 skipNewline(First, End);
513 printAdjacentModuleNameParts(First, End);
517 void Minimizer::printDirectiveBody(const char *&First, const char *const End) {
518 skipWhitespace(First, End); // Skip initial whitespace.
519 printToNewline(First, End);
526 const char *const End) {
529 while (Last != End && isIdentifierBody(*Last))
535 getIdentifierContinuation(const char *First, const char *const End) {
536 if (End - First < 3 || First[0] != '\\' || !isVerticalWhitespace(First[1]))
540 skipNewline(First, End);
541 if (First == End)
547 End) {
548 const char *Last = lexRawIdentifier(First, End);
549 const char *Next = getIdentifierContinuation(Last, End);
556 Last = lexRawIdentifier(Next, End);
558 Next = getIdentifierContinuation(Last, End);
566 const char *const End) {
571 while (Last != End &&
577 bool Minimizer::printMacroArgs(const char *&First, const char *const End) {
581 skipWhitespace(First, End);
582 if (First == End)
594 printAdjacentMacroArgs(First, End);
603 const char *const End) {
604 skipWhitespace(First, End);
605 if (First == End || !isIdentifierHead(*First))
608 IdInfo FoundId = lexIdentifier(First, End);
613 bool Minimizer::lexAt(const char *&First, const char *const End) {
616 if (!isNextIdentifier("import", First, End)) {
617 skipLine(First, End);
622 if (printAtImportBody(First, End))
625 skipWhitespace(First, End);
626 if (First == End)
631 skipNewline(First, End);
635 bool Minimizer::lexModule(const char *&First, const char *const End) {
636 IdInfo Id = lexIdentifier(First, End);
641 skipWhitespace(First, End);
643 skipLine(First, End);
646 Id = lexIdentifier(First, End);
651 skipLine(First, End);
655 skipWhitespace(First, End);
667 skipLine(First, End);
683 printToNewline(First, End);
688 bool Minimizer::lexDefine(const char *&First, const char *const End) {
691 skipWhitespace(First, End);
696 IdInfo Id = lexIdentifier(First, End);
699 if (Last == End)
703 if (printMacroArgs(Last, End)) {
708 skipLine(Last, End);
712 skipWhitespace(Last, End);
713 if (Last == End)
717 printDirectiveBody(Last, End);
722 bool Minimizer::lexPragma(const char *&First, const char *const End) {
724 skipWhitespace(First, End);
725 if (First == End || !isIdentifierHead(*First))
728 IdInfo FoundId = lexIdentifier(First, End);
732 skipLine(First, End);
739 skipLine(First, End);
744 if (!isNextIdentifier("module", First, End)) {
745 skipLine(First, End);
750 if (!isNextIdentifier("import", First, End)) {
751 skipLine(First, End);
758 printDirectiveBody(First, End);
762 bool Minimizer::lexEndif(const char *&First, const char *const End) {
775 skipLine(First, End);
779 return lexDefault(pp_endif, "endif", First, End);
783 const char *&First, const char *const End) {
786 printDirectiveBody(First, End);
802 bool Minimizer::lexPPLine(const char *&First, const char *const End) {
803 assert(First != End);
805 skipWhitespace(First, End);
806 assert(First <= End);
807 if (First == End)
811 skipLine(First, End);
812 assert(First <= End);
818 return lexAt(First, End);
821 return lexModule(First, End);
825 skipWhitespace(First, End);
827 if (First == End)
831 skipLine(First, End);
836 IdInfo Id = lexIdentifier(First, End);
854 skipDirective(Id.Name, First, End);
859 return lexEndif(First, End);
862 return lexDefine(First, End);
865 return lexPragma(First, End);
868 return lexDefault(Kind, Id.Name, First, End);
871 static void skipUTF8ByteOrderMark(const char *&First, const char *const End) {
872 if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
877 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
878 skipUTF8ByteOrderMark(First, End);
879 while (First != End)
880 if (lexPPLine(First, End))
886 bool Error = minimizeImpl(Input.begin(), Input.end());