Lines Matching refs:CurPtr
610 const char *CurPtr = Buffer.begin(); in ComputePreamble() local
612 while (CurPtr != Buffer.end()) { in ComputePreamble()
613 char ch = *CurPtr++; in ComputePreamble()
620 if (CurPtr != Buffer.end()) in ComputePreamble()
621 MaxLineOffset = CurPtr - Buffer.begin(); in ComputePreamble()
1721 bool Lexer::tryConsumeIdentifierUCN(const char *&CurPtr, unsigned Size, in tryConsumeIdentifierUCN() argument
1723 const char *UCNPtr = CurPtr + Size; in tryConsumeIdentifierUCN()
1724 uint32_t CodePoint = tryReadUCN(UCNPtr, CurPtr, /*Token=*/nullptr); in tryConsumeIdentifierUCN()
1736 makeCharRange(*this, CurPtr, UCNPtr), in tryConsumeIdentifierUCN()
1745 makeCharRange(*this, CurPtr, UCNPtr)); in tryConsumeIdentifierUCN()
1748 makeCharRange(*this, CurPtr, UCNPtr), in tryConsumeIdentifierUCN()
1753 if ((UCNPtr - CurPtr == 6 && CurPtr[1] == 'u') || in tryConsumeIdentifierUCN()
1754 (UCNPtr - CurPtr == 10 && CurPtr[1] == 'U')) in tryConsumeIdentifierUCN()
1755 CurPtr = UCNPtr; in tryConsumeIdentifierUCN()
1757 while (CurPtr != UCNPtr) in tryConsumeIdentifierUCN()
1758 (void)getAndAdvanceChar(CurPtr, Result); in tryConsumeIdentifierUCN()
1762 bool Lexer::tryConsumeIdentifierUTF8Char(const char *&CurPtr, Token &Result) { in tryConsumeIdentifierUTF8Char() argument
1769 getCharAndSize(CurPtr, FirstCodeUnitSize); in tryConsumeIdentifierUTF8Char()
1770 const char *CharStart = CurPtr + FirstCodeUnitSize - 1; in tryConsumeIdentifierUTF8Char()
1808 ConsumeChar(CurPtr, FirstCodeUnitSize, Result); in tryConsumeIdentifierUTF8Char()
1809 CurPtr = UnicodePtr; in tryConsumeIdentifierUTF8Char()
1814 const char *CurPtr) { in LexUnicodeIdentifierStart() argument
1821 makeCharRange(*this, BufferPtr, CurPtr)); in LexUnicodeIdentifierStart()
1823 makeCharRange(*this, BufferPtr, CurPtr), in LexUnicodeIdentifierStart()
1826 makeCharRange(*this, BufferPtr, CurPtr)); in LexUnicodeIdentifierStart()
1830 return LexIdentifierContinue(Result, CurPtr); in LexUnicodeIdentifierStart()
1847 makeCharRange(*this, BufferPtr, CurPtr), /*IsStart*/ true); in LexUnicodeIdentifierStart()
1848 BufferPtr = CurPtr; in LexUnicodeIdentifierStart()
1855 FormTokenWithChars(Result, CurPtr, tok::unknown); in LexUnicodeIdentifierStart()
1860 fastParseASCIIIdentifier(const char *CurPtr, in fastParseASCIIIdentifier() argument
1871 while (LLVM_LIKELY(BufferEnd - CurPtr >= BytesPerRegister)) { in fastParseASCIIIdentifier()
1872 __m128i Cv = _mm_loadu_si128((const __m128i *)(CurPtr)); in fastParseASCIIIdentifier()
1877 CurPtr += Consumed; in fastParseASCIIIdentifier()
1880 return CurPtr; in fastParseASCIIIdentifier()
1884 unsigned char C = *CurPtr; in fastParseASCIIIdentifier()
1886 C = *++CurPtr; in fastParseASCIIIdentifier()
1887 return CurPtr; in fastParseASCIIIdentifier()
1890 bool Lexer::LexIdentifierContinue(Token &Result, const char *CurPtr) { in LexIdentifierContinue() argument
1895 CurPtr = fastParseASCIIIdentifier(CurPtr, BufferEnd); in LexIdentifierContinue()
1899 unsigned char C = getCharAndSize(CurPtr, Size); in LexIdentifierContinue()
1901 CurPtr = ConsumeChar(CurPtr, Size, Result); in LexIdentifierContinue()
1910 Diag(CurPtr, diag::ext_dollar_in_identifier); in LexIdentifierContinue()
1911 CurPtr = ConsumeChar(CurPtr, Size, Result); in LexIdentifierContinue()
1914 if (C == '\\' && tryConsumeIdentifierUCN(CurPtr, Size, Result)) in LexIdentifierContinue()
1916 if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr, Result)) in LexIdentifierContinue()
1923 FormTokenWithChars(Result, CurPtr, tok::raw_identifier); in LexIdentifierContinue()
1940 if (isCodeCompletionPoint(CurPtr)) { in LexIdentifierContinue()
1948 assert(*CurPtr == 0 && "Completion character must be 0"); in LexIdentifierContinue()
1949 ++CurPtr; in LexIdentifierContinue()
1953 if (CurPtr < BufferEnd) { in LexIdentifierContinue()
1954 while (isAsciiIdentifierContinue(*CurPtr)) in LexIdentifierContinue()
1955 ++CurPtr; in LexIdentifierContinue()
1957 BufferPtr = CurPtr; in LexIdentifierContinue()
1986 bool Lexer::LexNumericConstant(Token &Result, const char *CurPtr) { in LexNumericConstant() argument
1988 char C = getCharAndSize(CurPtr, Size); in LexNumericConstant()
1991 CurPtr = ConsumeChar(CurPtr, Size, Result); in LexNumericConstant()
1993 if (LangOpts.HLSL && C == '.' && (*CurPtr == 'x' || *CurPtr == 'r')) { in LexNumericConstant()
1994 CurPtr -= Size; in LexNumericConstant()
1997 C = getCharAndSize(CurPtr, Size); in LexNumericConstant()
2005 return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result)); in LexNumericConstant()
2018 std::find(BufferPtr, CurPtr, '_') != CurPtr) in LexNumericConstant()
2022 return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result)); in LexNumericConstant()
2027 auto [Next, NextSize] = getCharAndSizeNoWarn(CurPtr + Size, LangOpts); in LexNumericConstant()
2030 Diag(CurPtr, LangOpts.CPlusPlus in LexNumericConstant()
2033 CurPtr = ConsumeChar(CurPtr, Size, Result); in LexNumericConstant()
2034 CurPtr = ConsumeChar(CurPtr, NextSize, Result); in LexNumericConstant()
2035 return LexNumericConstant(Result, CurPtr); in LexNumericConstant()
2040 if (C == '\\' && tryConsumeIdentifierUCN(CurPtr, Size, Result)) in LexNumericConstant()
2041 return LexNumericConstant(Result, CurPtr); in LexNumericConstant()
2042 if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr, Result)) in LexNumericConstant()
2043 return LexNumericConstant(Result, CurPtr); in LexNumericConstant()
2047 FormTokenWithChars(Result, CurPtr, tok::numeric_constant); in LexNumericConstant()
2054 const char *Lexer::LexUDSuffix(Token &Result, const char *CurPtr, in LexUDSuffix() argument
2060 char C = getCharAndSize(CurPtr, Size); in LexUDSuffix()
2064 if (C == '\\' && tryConsumeIdentifierUCN(CurPtr, Size, Result)) in LexUDSuffix()
2066 else if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr, Result)) in LexUDSuffix()
2069 return CurPtr; in LexUDSuffix()
2074 Diag(CurPtr, in LexUDSuffix()
2077 << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " "); in LexUDSuffix()
2078 return CurPtr; in LexUDSuffix()
2100 getCharAndSizeNoWarn(CurPtr + Consumed, LangOpts); in LexUDSuffix()
2120 Diag(CurPtr, LangOpts.MSVCCompat in LexUDSuffix()
2123 << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " "); in LexUDSuffix()
2124 return CurPtr; in LexUDSuffix()
2127 CurPtr = ConsumeChar(CurPtr, Size, Result); in LexUDSuffix()
2132 C = getCharAndSize(CurPtr, Size); in LexUDSuffix()
2134 CurPtr = ConsumeChar(CurPtr, Size, Result); in LexUDSuffix()
2135 } else if (C == '\\' && tryConsumeIdentifierUCN(CurPtr, Size, Result)) { in LexUDSuffix()
2136 } else if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr, Result)) { in LexUDSuffix()
2141 return CurPtr; in LexUDSuffix()
2146 bool Lexer::LexStringLiteral(Token &Result, const char *CurPtr, in LexStringLiteral() argument
2148 const char *AfterQuote = CurPtr; in LexStringLiteral()
2159 char C = getAndAdvanceChar(CurPtr, Result); in LexStringLiteral()
2164 C = getAndAdvanceChar(CurPtr, Result); in LexStringLiteral()
2167 (C == 0 && CurPtr-1 == BufferEnd)) { // End of file. in LexStringLiteral()
2170 FormTokenWithChars(Result, CurPtr-1, tok::unknown); in LexStringLiteral()
2175 if (isCodeCompletionPoint(CurPtr-1)) { in LexStringLiteral()
2177 codeCompleteIncludedFile(AfterQuote, CurPtr - 1, /*IsAngled=*/false); in LexStringLiteral()
2180 FormTokenWithChars(Result, CurPtr - 1, tok::unknown); in LexStringLiteral()
2185 NulCharacter = CurPtr-1; in LexStringLiteral()
2187 C = getAndAdvanceChar(CurPtr, Result); in LexStringLiteral()
2192 CurPtr = LexUDSuffix(Result, CurPtr, true); in LexStringLiteral()
2200 FormTokenWithChars(Result, CurPtr, Kind); in LexStringLiteral()
2207 bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, in LexRawStringLiteral() argument
2219 while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) in LexRawStringLiteral()
2223 if (CurPtr[PrefixLen] != '(') { in LexRawStringLiteral()
2225 const char *PrefixEnd = &CurPtr[PrefixLen]; in LexRawStringLiteral()
2238 char C = *CurPtr++; in LexRawStringLiteral()
2242 if (C == 0 && CurPtr-1 == BufferEnd) { in LexRawStringLiteral()
2243 --CurPtr; in LexRawStringLiteral()
2248 FormTokenWithChars(Result, CurPtr, tok::unknown); in LexRawStringLiteral()
2253 const char *Prefix = CurPtr; in LexRawStringLiteral()
2254 CurPtr += PrefixLen + 1; // skip over prefix and '(' in LexRawStringLiteral()
2257 char C = *CurPtr++; in LexRawStringLiteral()
2261 if (strncmp(CurPtr, Prefix, PrefixLen) == 0 && CurPtr[PrefixLen] == '"') { in LexRawStringLiteral()
2262 CurPtr += PrefixLen + 1; // skip over prefix and '"' in LexRawStringLiteral()
2265 } else if (C == 0 && CurPtr-1 == BufferEnd) { // End of file. in LexRawStringLiteral()
2269 FormTokenWithChars(Result, CurPtr-1, tok::unknown); in LexRawStringLiteral()
2276 CurPtr = LexUDSuffix(Result, CurPtr, true); in LexRawStringLiteral()
2280 FormTokenWithChars(Result, CurPtr, Kind); in LexRawStringLiteral()
2287 bool Lexer::LexAngledStringLiteral(Token &Result, const char *CurPtr) { in LexAngledStringLiteral() argument
2290 const char *AfterLessPos = CurPtr; in LexAngledStringLiteral()
2291 char C = getAndAdvanceChar(CurPtr, Result); in LexAngledStringLiteral()
2296 C = getAndAdvanceChar(CurPtr, Result); in LexAngledStringLiteral()
2299 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file. in LexAngledStringLiteral()
2307 if (isCodeCompletionPoint(CurPtr - 1)) { in LexAngledStringLiteral()
2308 codeCompleteIncludedFile(AfterLessPos, CurPtr - 1, /*IsAngled=*/true); in LexAngledStringLiteral()
2310 FormTokenWithChars(Result, CurPtr - 1, tok::unknown); in LexAngledStringLiteral()
2313 NulCharacter = CurPtr-1; in LexAngledStringLiteral()
2315 C = getAndAdvanceChar(CurPtr, Result); in LexAngledStringLiteral()
2324 FormTokenWithChars(Result, CurPtr, tok::header_name); in LexAngledStringLiteral()
2364 bool Lexer::LexCharConstant(Token &Result, const char *CurPtr, in LexCharConstant() argument
2378 char C = getAndAdvanceChar(CurPtr, Result); in LexCharConstant()
2382 FormTokenWithChars(Result, CurPtr, tok::unknown); in LexCharConstant()
2389 C = getAndAdvanceChar(CurPtr, Result); in LexCharConstant()
2392 (C == 0 && CurPtr-1 == BufferEnd)) { // End of file. in LexCharConstant()
2395 FormTokenWithChars(Result, CurPtr-1, tok::unknown); in LexCharConstant()
2400 if (isCodeCompletionPoint(CurPtr-1)) { in LexCharConstant()
2402 FormTokenWithChars(Result, CurPtr-1, tok::unknown); in LexCharConstant()
2407 NulCharacter = CurPtr-1; in LexCharConstant()
2409 C = getAndAdvanceChar(CurPtr, Result); in LexCharConstant()
2414 CurPtr = LexUDSuffix(Result, CurPtr, false); in LexCharConstant()
2422 FormTokenWithChars(Result, CurPtr, Kind); in LexCharConstant()
2431 bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr, in SkipWhitespace() argument
2434 bool SawNewline = isVerticalWhitespace(CurPtr[-1]); in SkipWhitespace()
2436 unsigned char Char = *CurPtr; in SkipWhitespace()
2445 setLastNewLine(CurPtr - 1); in SkipWhitespace()
2451 Char = *++CurPtr; in SkipWhitespace()
2459 BufferPtr = CurPtr; in SkipWhitespace()
2464 if (*CurPtr == '\n') in SkipWhitespace()
2465 setLastNewLine(CurPtr); in SkipWhitespace()
2467 Char = *++CurPtr; in SkipWhitespace()
2472 FormTokenWithChars(Result, CurPtr, tok::unknown); in SkipWhitespace()
2482 char PrevChar = CurPtr[-1]; in SkipWhitespace()
2497 BufferPtr = CurPtr; in SkipWhitespace()
2507 bool Lexer::SkipLineComment(Token &Result, const char *CurPtr, in SkipLineComment() argument
2535 C = *CurPtr; in SkipLineComment()
2539 C = *++CurPtr; in SkipLineComment()
2545 (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd); in SkipLineComment()
2548 Diag(CurPtr, diag::warn_invalid_utf8_in_comment); in SkipLineComment()
2550 ++CurPtr; in SkipLineComment()
2553 CurPtr += Length; in SkipLineComment()
2558 const char *NextLine = CurPtr; in SkipLineComment()
2561 const char *EscapePtr = CurPtr-1; in SkipLineComment()
2570 CurPtr = EscapePtr; in SkipLineComment()
2574 CurPtr = EscapePtr-2; in SkipLineComment()
2587 const char *OldPtr = CurPtr; in SkipLineComment()
2590 C = getAndAdvanceChar(CurPtr, Result); in SkipLineComment()
2595 if (C != 0 && CurPtr == OldPtr+1) { in SkipLineComment()
2596 CurPtr = NextLine; in SkipLineComment()
2603 if (CurPtr != OldPtr + 1 && C != '/' && in SkipLineComment()
2604 (CurPtr == BufferEnd + 1 || CurPtr[0] != '/')) { in SkipLineComment()
2605 for (; OldPtr != CurPtr; ++OldPtr) in SkipLineComment()
2610 const char *ForwardPtr = CurPtr; in SkipLineComment()
2623 if (C == '\r' || C == '\n' || CurPtr == BufferEnd + 1) { in SkipLineComment()
2624 --CurPtr; in SkipLineComment()
2628 if (C == '\0' && isCodeCompletionPoint(CurPtr-1)) { in SkipLineComment()
2639 getSourceLocation(CurPtr)))) { in SkipLineComment()
2640 BufferPtr = CurPtr; in SkipLineComment()
2646 return SaveLineComment(Result, CurPtr); in SkipLineComment()
2650 if (ParsingPreprocessorDirective || CurPtr == BufferEnd) { in SkipLineComment()
2651 BufferPtr = CurPtr; in SkipLineComment()
2660 NewLinePtr = CurPtr++; in SkipLineComment()
2667 BufferPtr = CurPtr; in SkipLineComment()
2673 bool Lexer::SaveLineComment(Token &Result, const char *CurPtr) { in SaveLineComment() argument
2676 FormTokenWithChars(Result, CurPtr, tok::comment); in SaveLineComment()
2701 static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr, Lexer *L, in isEndOfBlockCommentWithEscapedNewLine() argument
2703 assert(CurPtr[0] == '\n' || CurPtr[0] == '\r'); in isEndOfBlockCommentWithEscapedNewLine()
2712 --CurPtr; in isEndOfBlockCommentWithEscapedNewLine()
2715 if (CurPtr[0] == '\n' || CurPtr[0] == '\r') { in isEndOfBlockCommentWithEscapedNewLine()
2717 if (CurPtr[0] == CurPtr[1]) in isEndOfBlockCommentWithEscapedNewLine()
2720 --CurPtr; in isEndOfBlockCommentWithEscapedNewLine()
2725 while (isHorizontalWhitespace(*CurPtr) || *CurPtr == 0) { in isEndOfBlockCommentWithEscapedNewLine()
2726 SpacePos = CurPtr; in isEndOfBlockCommentWithEscapedNewLine()
2727 --CurPtr; in isEndOfBlockCommentWithEscapedNewLine()
2731 if (*CurPtr == '\\') { in isEndOfBlockCommentWithEscapedNewLine()
2732 --CurPtr; in isEndOfBlockCommentWithEscapedNewLine()
2733 } else if (CurPtr[0] == '/' && CurPtr[-1] == '?' && CurPtr[-2] == '?') { in isEndOfBlockCommentWithEscapedNewLine()
2735 TrigraphPos = CurPtr - 2; in isEndOfBlockCommentWithEscapedNewLine()
2736 CurPtr -= 3; in isEndOfBlockCommentWithEscapedNewLine()
2743 if (*CurPtr == '*') in isEndOfBlockCommentWithEscapedNewLine()
2746 if (*CurPtr != '\n' && *CurPtr != '\r') in isEndOfBlockCommentWithEscapedNewLine()
2764 L->Diag(CurPtr + 1, diag::escaped_newline_block_comment_end); in isEndOfBlockCommentWithEscapedNewLine()
2789 bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr, in SkipBlockComment() argument
2800 unsigned char C = getCharAndSize(CurPtr, CharSize); in SkipBlockComment()
2801 CurPtr += CharSize; in SkipBlockComment()
2802 if (C == 0 && CurPtr == BufferEnd+1) { in SkipBlockComment()
2805 --CurPtr; in SkipBlockComment()
2810 FormTokenWithChars(Result, CurPtr, tok::unknown); in SkipBlockComment()
2814 BufferPtr = CurPtr; in SkipBlockComment()
2821 C = *CurPtr++; in SkipBlockComment()
2832 if (CurPtr + 24 < BufferEnd && in SkipBlockComment()
2837 while (C != '/' && (intptr_t)CurPtr % 16 != 0) { in SkipBlockComment()
2840 C = *CurPtr++; in SkipBlockComment()
2846 while (CurPtr + 16 < BufferEnd) { in SkipBlockComment()
2847 int Mask = _mm_movemask_epi8(*(const __m128i *)CurPtr); in SkipBlockComment()
2852 int cmp = _mm_movemask_epi8(_mm_cmpeq_epi8(*(const __m128i*)CurPtr, in SkipBlockComment()
2858 CurPtr += llvm::countr_zero<unsigned>(cmp) + 1; in SkipBlockComment()
2861 CurPtr += 16; in SkipBlockComment()
2871 while (CurPtr + 16 < BufferEnd) { in SkipBlockComment()
2873 vec_any_ge(*(const __vector unsigned char *)CurPtr, LongUTF))) in SkipBlockComment()
2875 if (vec_any_eq(*(const __vector unsigned char *)CurPtr, Slashes)) { in SkipBlockComment()
2878 CurPtr += 16; in SkipBlockComment()
2882 while (CurPtr + 16 < BufferEnd) { in SkipBlockComment()
2885 HasNonASCII |= !isASCII(CurPtr[I]); in SkipBlockComment()
2892 HasSlash |= CurPtr[I] == '/'; in SkipBlockComment()
2895 CurPtr += 16; in SkipBlockComment()
2900 C = *CurPtr++; in SkipBlockComment()
2909 C = *CurPtr++; in SkipBlockComment()
2916 (const llvm::UTF8 *)CurPtr - 1, (const llvm::UTF8 *)BufferEnd); in SkipBlockComment()
2919 Diag(CurPtr - 1, diag::warn_invalid_utf8_in_comment); in SkipBlockComment()
2923 CurPtr += Length - 1; in SkipBlockComment()
2925 C = *CurPtr++; in SkipBlockComment()
2930 if (CurPtr[-2] == '*') // We found the final */. We're done! in SkipBlockComment()
2933 if ((CurPtr[-2] == '\n' || CurPtr[-2] == '\r')) { in SkipBlockComment()
2934 if (isEndOfBlockCommentWithEscapedNewLine(CurPtr - 2, this, in SkipBlockComment()
2941 if (CurPtr[0] == '*' && CurPtr[1] != '/') { in SkipBlockComment()
2946 Diag(CurPtr-1, diag::warn_nested_block_comment); in SkipBlockComment()
2948 } else if (C == 0 && CurPtr == BufferEnd+1) { in SkipBlockComment()
2954 --CurPtr; in SkipBlockComment()
2959 FormTokenWithChars(Result, CurPtr, tok::unknown); in SkipBlockComment()
2963 BufferPtr = CurPtr; in SkipBlockComment()
2965 } else if (C == '\0' && isCodeCompletionPoint(CurPtr-1)) { in SkipBlockComment()
2971 C = *CurPtr++; in SkipBlockComment()
2977 getSourceLocation(CurPtr)))) { in SkipBlockComment()
2978 BufferPtr = CurPtr; in SkipBlockComment()
2984 FormTokenWithChars(Result, CurPtr, tok::comment); in SkipBlockComment()
2992 if (isHorizontalWhitespace(*CurPtr)) { in SkipBlockComment()
2993 SkipWhitespace(Result, CurPtr+1, TokAtPhysicalStartOfLine); in SkipBlockComment()
2998 BufferPtr = CurPtr; in SkipBlockComment()
3016 const char *CurPtr = BufferPtr; in ReadToEndOfLine() local
3018 char Char = getAndAdvanceChar(CurPtr, Tmp); in ReadToEndOfLine()
3026 if (CurPtr-1 != BufferEnd) { in ReadToEndOfLine()
3027 if (isCodeCompletionPoint(CurPtr-1)) { in ReadToEndOfLine()
3043 assert(CurPtr[-1] == Char && "Trigraphs for newline?"); in ReadToEndOfLine()
3044 BufferPtr = CurPtr-1; in ReadToEndOfLine()
3065 bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { in LexEndOfFile() argument
3073 FormTokenWithChars(Result, CurPtr, tok::eod); in LexEndOfFile()
3112 if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r')) { in LexEndOfFile()
3134 BufferPtr = CurPtr; in LexEndOfFile()
3185 static const char *FindConflictEnd(const char *CurPtr, const char *BufferEnd, in FindConflictEnd() argument
3189 auto RestOfBuffer = StringRef(CurPtr, BufferEnd - CurPtr).substr(TermLen); in FindConflictEnd()
3208 bool Lexer::IsStartOfConflictMarker(const char *CurPtr) { in IsStartOfConflictMarker() argument
3210 if (CurPtr != BufferStart && in IsStartOfConflictMarker()
3211 CurPtr[-1] != '\n' && CurPtr[-1] != '\r') in IsStartOfConflictMarker()
3215 if (!StringRef(CurPtr, BufferEnd - CurPtr).starts_with("<<<<<<<") && in IsStartOfConflictMarker()
3216 !StringRef(CurPtr, BufferEnd - CurPtr).starts_with(">>>> ")) in IsStartOfConflictMarker()
3224 ConflictMarkerKind Kind = *CurPtr == '<' ? CMK_Normal : CMK_Perforce; in IsStartOfConflictMarker()
3228 if (FindConflictEnd(CurPtr, BufferEnd, Kind)) { in IsStartOfConflictMarker()
3231 Diag(CurPtr, diag::err_conflict_marker); in IsStartOfConflictMarker()
3236 while (*CurPtr != '\r' && *CurPtr != '\n') { in IsStartOfConflictMarker()
3237 assert(CurPtr != BufferEnd && "Didn't find end of line"); in IsStartOfConflictMarker()
3238 ++CurPtr; in IsStartOfConflictMarker()
3240 BufferPtr = CurPtr; in IsStartOfConflictMarker()
3252 bool Lexer::HandleEndOfConflictMarker(const char *CurPtr) { in HandleEndOfConflictMarker() argument
3254 if (CurPtr != BufferStart && in HandleEndOfConflictMarker()
3255 CurPtr[-1] != '\n' && CurPtr[-1] != '\r') in HandleEndOfConflictMarker()
3265 if (CurPtr[i] != CurPtr[0]) in HandleEndOfConflictMarker()
3271 if (const char *End = FindConflictEnd(CurPtr, BufferEnd, in HandleEndOfConflictMarker()
3273 CurPtr = End; in HandleEndOfConflictMarker()
3276 while (CurPtr != BufferEnd && *CurPtr != '\r' && *CurPtr != '\n') in HandleEndOfConflictMarker()
3277 ++CurPtr; in HandleEndOfConflictMarker()
3279 BufferPtr = CurPtr; in HandleEndOfConflictMarker()
3289 static const char *findPlaceholderEnd(const char *CurPtr, in findPlaceholderEnd() argument
3291 if (CurPtr == BufferEnd) in findPlaceholderEnd()
3294 for (; CurPtr != BufferEnd; ++CurPtr) { in findPlaceholderEnd()
3295 if (CurPtr[0] == '#' && CurPtr[1] == '>') in findPlaceholderEnd()
3296 return CurPtr + 2; in findPlaceholderEnd()
3301 bool Lexer::lexEditorPlaceholder(Token &Result, const char *CurPtr) { in lexEditorPlaceholder() argument
3302 assert(CurPtr[-1] == '<' && CurPtr[0] == '#' && "Not a placeholder!"); in lexEditorPlaceholder()
3305 const char *End = findPlaceholderEnd(CurPtr + 1, BufferEnd); in lexEditorPlaceholder()
3308 const char *Start = CurPtr - 1; in lexEditorPlaceholder()
3320 bool Lexer::isCodeCompletionPoint(const char *CurPtr) const { in isCodeCompletionPoint()
3322 SourceLocation Loc = FileLoc.getLocWithOffset(CurPtr-BufferStart); in isCodeCompletionPoint()
3353 const char *CurPtr = StartPtr + CharSize; in tryReadNumericUCN() local
3354 const char *KindLoc = &CurPtr[-1]; in tryReadNumericUCN()
3358 char C = getCharAndSize(CurPtr, CharSize); in tryReadNumericUCN()
3361 CurPtr += CharSize; in tryReadNumericUCN()
3366 CurPtr += CharSize; in tryReadNumericUCN()
3389 CurPtr += CharSize; in tryReadNumericUCN()
3432 if (CurPtr - StartPtr == (ptrdiff_t)(Count + 1 + (Delimited ? 2 : 0))) in tryReadNumericUCN()
3433 StartPtr = CurPtr; in tryReadNumericUCN()
3435 while (StartPtr != CurPtr) in tryReadNumericUCN()
3438 StartPtr = CurPtr; in tryReadNumericUCN()
3452 const char *CurPtr = StartPtr + CharSize; in tryReadNamedUCN() local
3453 const char *KindLoc = &CurPtr[-1]; in tryReadNamedUCN()
3455 C = getCharAndSize(CurPtr, CharSize); in tryReadNamedUCN()
3461 CurPtr += CharSize; in tryReadNamedUCN()
3462 const char *StartName = CurPtr; in tryReadNamedUCN()
3466 C = getCharAndSize(CurPtr, CharSize); in tryReadNamedUCN()
3467 CurPtr += CharSize; in tryReadNamedUCN()
3495 << makeCharRange(*this, StartName, CurPtr - CharSize); in tryReadNamedUCN()
3499 makeCharRange(*this, StartName, CurPtr - CharSize), in tryReadNamedUCN()
3526 if (CurPtr - StartPtr == (ptrdiff_t)(Buffer.size() + 3)) in tryReadNamedUCN()
3527 StartPtr = CurPtr; in tryReadNamedUCN()
3529 while (StartPtr != CurPtr) in tryReadNamedUCN()
3532 StartPtr = CurPtr; in tryReadNamedUCN()
3603 const char *CurPtr) { in CheckUnicodeWhitespace() argument
3607 << makeCharRange(*this, BufferPtr, CurPtr); in CheckUnicodeWhitespace()
3665 const char *CurPtr = BufferPtr; in LexTokenInternal() local
3668 if (isHorizontalWhitespace(*CurPtr)) { in LexTokenInternal()
3670 ++CurPtr; in LexTokenInternal()
3671 } while (isHorizontalWhitespace(*CurPtr)); in LexTokenInternal()
3677 FormTokenWithChars(Result, CurPtr, tok::unknown); in LexTokenInternal()
3682 BufferPtr = CurPtr; in LexTokenInternal()
3689 char Char = getAndAdvanceChar(CurPtr, Result); in LexTokenInternal()
3698 if (CurPtr-1 == BufferEnd) in LexTokenInternal()
3699 return LexEndOfFile(Result, CurPtr-1); in LexTokenInternal()
3702 if (isCodeCompletionPoint(CurPtr-1)) { in LexTokenInternal()
3705 FormTokenWithChars(Result, CurPtr, tok::code_completion); in LexTokenInternal()
3710 Diag(CurPtr-1, diag::null_in_file); in LexTokenInternal()
3712 if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) in LexTokenInternal()
3723 Diag(CurPtr-1, diag::ext_ctrl_z_eof_microsoft); in LexTokenInternal()
3724 return LexEndOfFile(Result, CurPtr-1); in LexTokenInternal()
3732 if (CurPtr[0] == '\n') in LexTokenInternal()
3733 (void)getAndAdvanceChar(CurPtr, Result); in LexTokenInternal()
3749 NewLinePtr = CurPtr - 1; in LexTokenInternal()
3758 if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) in LexTokenInternal()
3770 if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) in LexTokenInternal()
3774 CurPtr = BufferPtr; in LexTokenInternal()
3778 if (CurPtr[0] == '/' && CurPtr[1] == '/' && !inKeepCommentMode() && in LexTokenInternal()
3780 if (SkipLineComment(Result, CurPtr+2, TokAtPhysicalStartOfLine)) in LexTokenInternal()
3783 } else if (CurPtr[0] == '/' && CurPtr[1] == '*' && !inKeepCommentMode()) { in LexTokenInternal()
3784 if (SkipBlockComment(Result, CurPtr+2, TokAtPhysicalStartOfLine)) in LexTokenInternal()
3787 } else if (isHorizontalWhitespace(*CurPtr)) { in LexTokenInternal()
3800 return LexNumericConstant(Result, CurPtr); in LexTokenInternal()
3810 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
3814 return LexStringLiteral(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3819 return LexCharConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3824 getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') in LexTokenInternal()
3826 ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3831 char Char2 = getCharAndSize(CurPtr + SizeTmp, SizeTmp2); in LexTokenInternal()
3836 ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3841 Result, ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3847 char Char3 = getCharAndSize(CurPtr + SizeTmp + SizeTmp2, SizeTmp3); in LexTokenInternal()
3851 ConsumeChar(ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3861 return LexIdentifierContinue(Result, CurPtr); in LexTokenInternal()
3868 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
3872 return LexStringLiteral(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3877 return LexCharConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3882 getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') in LexTokenInternal()
3884 ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3890 return LexIdentifierContinue(Result, CurPtr); in LexTokenInternal()
3897 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
3901 ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3906 return LexIdentifierContinue(Result, CurPtr); in LexTokenInternal()
3911 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
3915 return LexStringLiteral(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3920 getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') in LexTokenInternal()
3922 ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3928 return LexCharConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
3945 return LexIdentifierContinue(Result, CurPtr); in LexTokenInternal()
3950 Diag(CurPtr-1, diag::ext_dollar_in_identifier); in LexTokenInternal()
3953 return LexIdentifierContinue(Result, CurPtr); in LexTokenInternal()
3963 return LexCharConstant(Result, CurPtr, tok::char_constant); in LexTokenInternal()
3969 return LexStringLiteral(Result, CurPtr, in LexTokenInternal()
3996 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4001 return LexNumericConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result)); in LexTokenInternal()
4004 CurPtr += SizeTmp; in LexTokenInternal()
4006 getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == '.') { in LexTokenInternal()
4008 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4015 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4018 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4021 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4027 if (getCharAndSize(CurPtr, SizeTmp) == '=') { in LexTokenInternal()
4029 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4035 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4037 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4040 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4047 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4049 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4052 getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == '*') { // C++ ->* in LexTokenInternal()
4053 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4057 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4060 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4070 if (getCharAndSize(CurPtr, SizeTmp) == '=') { in LexTokenInternal()
4072 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4079 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4093 TreatAsComment = getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*'; in LexTokenInternal()
4096 if (SkipLineComment(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4108 if (SkipBlockComment(Result, ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4118 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4125 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4128 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4131 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4133 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4134 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4135 if (Char == '%' && getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == ':') { in LexTokenInternal()
4137 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4140 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4159 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4161 return LexAngledStringLiteral(Result, CurPtr); in LexTokenInternal()
4163 char After = getCharAndSize(CurPtr+SizeTmp, SizeTmp2); in LexTokenInternal()
4166 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4168 } else if (After == '<' && IsStartOfConflictMarker(CurPtr-1)) { in LexTokenInternal()
4172 } else if (After == '<' && HandleEndOfConflictMarker(CurPtr-1)) { in LexTokenInternal()
4178 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4181 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4185 char After = getCharAndSize(CurPtr+SizeTmp, SizeTmp2); in LexTokenInternal()
4190 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4200 getSourceLocation(CurPtr + SizeTmp, SizeTmp2), " "); in LexTokenInternal()
4203 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4207 getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == ':') { in LexTokenInternal()
4214 char After = getCharAndSize(CurPtr + SizeTmp + SizeTmp2, SizeTmp3); in LexTokenInternal()
4223 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4226 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4229 lexEditorPlaceholder(Result, CurPtr)) { in LexTokenInternal()
4236 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4238 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4241 char After = getCharAndSize(CurPtr+SizeTmp, SizeTmp2); in LexTokenInternal()
4243 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4246 } else if (After == '>' && IsStartOfConflictMarker(CurPtr-1)) { in LexTokenInternal()
4250 } else if (After == '>' && HandleEndOfConflictMarker(CurPtr-1)) { in LexTokenInternal()
4255 CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), in LexTokenInternal()
4258 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4266 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4268 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4271 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4278 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4281 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4284 if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1)) in LexTokenInternal()
4287 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4293 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4296 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4299 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4308 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4311 if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr-1)) in LexTokenInternal()
4315 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4324 Char = getCharAndSize(CurPtr, SizeTmp); in LexTokenInternal()
4327 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4332 CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); in LexTokenInternal()
4347 if (CurPtr[-1] == '@' && LangOpts.ObjC) in LexTokenInternal()
4356 if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { in LexTokenInternal()
4357 if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { in LexTokenInternal()
4358 if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) in LexTokenInternal()
4366 return LexUnicodeIdentifierStart(Result, CodePoint, CurPtr); in LexTokenInternal()
4383 --CurPtr; in LexTokenInternal()
4385 llvm::convertUTF8Sequence((const llvm::UTF8 **)&CurPtr, in LexTokenInternal()
4390 if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { in LexTokenInternal()
4391 if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) in LexTokenInternal()
4398 return LexUnicodeIdentifierStart(Result, CodePoint, CurPtr); in LexTokenInternal()
4403 ++CurPtr; in LexTokenInternal()
4411 Diag(CurPtr, diag::err_invalid_utf8); in LexTokenInternal()
4413 BufferPtr = CurPtr+1; in LexTokenInternal()
4425 FormTokenWithChars(Result, CurPtr, Kind); in LexTokenInternal()
4431 FormTokenWithChars(Result, CurPtr, tok::hash); in LexTokenInternal()