diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1881,7 +1881,7 @@ if (!LangOpts.C99) { if (!isHexaLiteral(BufferPtr, LangOpts)) IsHexFloat = false; - else if (!getLangOpts().CPlusPlus17 && + else if (!LangOpts.CPlusPlus17 && std::find(BufferPtr, CurPtr, '_') != CurPtr) IsHexFloat = false; } @@ -1890,12 +1890,12 @@ } // If we have a digit separator, continue. - if (C == '\'' && (getLangOpts().CPlusPlus14 || getLangOpts().C2x)) { + if (C == '\'' && (LangOpts.CPlusPlus14 || LangOpts.C2x)) { unsigned NextSize; - char Next = getCharAndSizeNoWarn(CurPtr + Size, NextSize, getLangOpts()); + char Next = getCharAndSizeNoWarn(CurPtr + Size, NextSize, LangOpts); if (isAsciiIdentifierContinue(Next)) { if (!isLexingRawMode()) - Diag(CurPtr, getLangOpts().CPlusPlus + Diag(CurPtr, LangOpts.CPlusPlus ? diag::warn_cxx11_compat_digit_separator : diag::warn_c2x_compat_digit_separator); CurPtr = ConsumeChar(CurPtr, Size, Result); @@ -1921,7 +1921,7 @@ /// in C++11, or warn on a ud-suffix in C++98. const char *Lexer::LexUDSuffix(Token &Result, const char *CurPtr, bool IsStringLiteral) { - assert(getLangOpts().CPlusPlus); + assert(LangOpts.CPlusPlus); // Maximally munch an identifier. unsigned Size; @@ -1937,7 +1937,7 @@ return CurPtr; } - if (!getLangOpts().CPlusPlus11) { + if (!LangOpts.CPlusPlus11) { if (!isLexingRawMode()) Diag(CurPtr, C == '_' ? diag::warn_cxx11_compat_user_defined_literal @@ -1955,7 +1955,7 @@ bool IsUDSuffix = false; if (C == '_') IsUDSuffix = true; - else if (IsStringLiteral && getLangOpts().CPlusPlus14) { + else if (IsStringLiteral && LangOpts.CPlusPlus14) { // In C++1y, we need to look ahead a few characters to see if this is a // valid suffix for a string literal or a numeric literal (this could be // the 'operator""if' defining a numeric literal operator). @@ -1965,13 +1965,12 @@ unsigned Chars = 1; while (true) { unsigned NextSize; - char Next = getCharAndSizeNoWarn(CurPtr + Consumed, NextSize, - getLangOpts()); + char Next = getCharAndSizeNoWarn(CurPtr + Consumed, NextSize, LangOpts); if (!isAsciiIdentifierContinue(Next)) { // End of suffix. Check whether this is on the allowed list. const StringRef CompleteSuffix(Buffer, Chars); - IsUDSuffix = StringLiteralParser::isValidUDSuffix(getLangOpts(), - CompleteSuffix); + IsUDSuffix = + StringLiteralParser::isValidUDSuffix(LangOpts, CompleteSuffix); break; } @@ -1986,10 +1985,10 @@ if (!IsUDSuffix) { if (!isLexingRawMode()) - Diag(CurPtr, getLangOpts().MSVCCompat + Diag(CurPtr, LangOpts.MSVCCompat ? diag::ext_ms_reserved_user_defined_literal : diag::ext_reserved_user_defined_literal) - << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " "); + << FixItHint::CreateInsertion(getSourceLocation(CurPtr), " "); return CurPtr; } @@ -2022,9 +2021,8 @@ (Kind == tok::utf8_string_literal || Kind == tok::utf16_string_literal || Kind == tok::utf32_string_literal)) - Diag(BufferPtr, getLangOpts().CPlusPlus - ? diag::warn_cxx98_compat_unicode_literal - : diag::warn_c99_compat_unicode_literal); + Diag(BufferPtr, LangOpts.CPlusPlus ? diag::warn_cxx98_compat_unicode_literal + : diag::warn_c99_compat_unicode_literal); char C = getAndAdvanceChar(CurPtr, Result); while (C != '"') { @@ -2058,7 +2056,7 @@ } // If we are in C++11, lex the optional ud-suffix. - if (getLangOpts().CPlusPlus) + if (LangOpts.CPlusPlus) CurPtr = LexUDSuffix(Result, CurPtr, true); // If a nul character existed in the string, warn about it. @@ -2142,7 +2140,7 @@ } // If we are in C++11, lex the optional ud-suffix. - if (getLangOpts().CPlusPlus) + if (LangOpts.CPlusPlus) CurPtr = LexUDSuffix(Result, CurPtr, true); // Update the location of token as well as BufferPtr. @@ -2238,7 +2236,7 @@ if (!isLexingRawMode()) { if (Kind == tok::utf16_char_constant || Kind == tok::utf32_char_constant) - Diag(BufferPtr, getLangOpts().CPlusPlus + Diag(BufferPtr, LangOpts.CPlusPlus ? diag::warn_cxx98_compat_unicode_literal : diag::warn_c99_compat_unicode_literal); else if (Kind == tok::utf8_char_constant) @@ -2280,7 +2278,7 @@ } // If we are in C++11, lex the optional ud-suffix. - if (getLangOpts().CPlusPlus) + if (LangOpts.CPlusPlus) CurPtr = LexUDSuffix(Result, CurPtr, false); // If a nul character existed in the character, warn about it. @@ -3841,7 +3839,7 @@ } else if (Char == '=') { char After = getCharAndSize(CurPtr+SizeTmp, SizeTmp2); if (After == '>') { - if (getLangOpts().CPlusPlus20) { + if (LangOpts.CPlusPlus20) { if (!isLexingRawMode()) Diag(BufferPtr, diag::warn_cxx17_compat_spaceship); CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), @@ -3851,7 +3849,7 @@ } // Suggest adding a space between the '<=' and the '>' to avoid a // change in semantics if this turns up in C++ <=17 mode. - if (getLangOpts().CPlusPlus && !isLexingRawMode()) { + if (LangOpts.CPlusPlus && !isLexingRawMode()) { Diag(BufferPtr, diag::warn_cxx20_compat_spaceship) << FixItHint::CreateInsertion( getSourceLocation(CurPtr + SizeTmp, SizeTmp2), " ");