diff options
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/Lexer.cpp | 120 | ||||
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 12 | ||||
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 34 | ||||
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 8 | ||||
-rw-r--r-- | lib/Lex/PPMacroExpansion.cpp | 10 | ||||
-rw-r--r-- | lib/Lex/Pragma.cpp | 2 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 10 | ||||
-rw-r--r-- | lib/Lex/TokenConcatenation.cpp | 14 | ||||
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 8 |
9 files changed, 109 insertions, 109 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 0b342389a0..a49ab048f6 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -117,7 +117,7 @@ void Lexer::InitLexer(const char *BufStart, const char *BufPtr, Lexer::Lexer(FileID FID, const llvm::MemoryBuffer *InputFile, Preprocessor &PP) : PreprocessorLexer(&PP, FID), FileLoc(PP.getSourceManager().getLocForStartOfFile(FID)), - Features(PP.getLangOptions()) { + LangOpts(PP.getLangOpts()) { InitLexer(InputFile->getBufferStart(), InputFile->getBufferStart(), InputFile->getBufferEnd()); @@ -129,9 +129,9 @@ Lexer::Lexer(FileID FID, const llvm::MemoryBuffer *InputFile, Preprocessor &PP) /// Lexer constructor - Create a new raw lexer object. This object is only /// suitable for calls to 'LexRawToken'. This lexer assumes that the text /// range will outlive it, so it doesn't take ownership of it. -Lexer::Lexer(SourceLocation fileloc, const LangOptions &features, +Lexer::Lexer(SourceLocation fileloc, const LangOptions &langOpts, const char *BufStart, const char *BufPtr, const char *BufEnd) - : FileLoc(fileloc), Features(features) { + : FileLoc(fileloc), LangOpts(langOpts) { InitLexer(BufStart, BufPtr, BufEnd); @@ -143,8 +143,8 @@ Lexer::Lexer(SourceLocation fileloc, const LangOptions &features, /// suitable for calls to 'LexRawToken'. This lexer assumes that the text /// range will outlive it, so it doesn't take ownership of it. Lexer::Lexer(FileID FID, const llvm::MemoryBuffer *FromFile, - const SourceManager &SM, const LangOptions &features) - : FileLoc(SM.getLocForStartOfFile(FID)), Features(features) { + const SourceManager &SM, const LangOptions &langOpts) + : FileLoc(SM.getLocForStartOfFile(FID)), LangOpts(langOpts) { InitLexer(FromFile->getBufferStart(), FromFile->getBufferStart(), FromFile->getBufferEnd()); @@ -287,7 +287,7 @@ StringRef Lexer::getSpelling(SourceLocation loc, /// wants to get the true, uncanonicalized, spelling of things like digraphs /// UCNs, etc. std::string Lexer::getSpelling(const Token &Tok, const SourceManager &SourceMgr, - const LangOptions &Features, bool *Invalid) { + const LangOptions &LangOpts, bool *Invalid) { assert((int)Tok.getLength() >= 0 && "Token character range is bogus!"); // If this token contains nothing interesting, return it directly. @@ -309,7 +309,7 @@ std::string Lexer::getSpelling(const Token &Tok, const SourceManager &SourceMgr, for (const char *Ptr = TokStart, *End = TokStart+Tok.getLength(); Ptr != End; ) { unsigned CharSize; - Result.push_back(Lexer::getCharAndSizeNoWarn(Ptr, CharSize, Features)); + Result.push_back(Lexer::getCharAndSizeNoWarn(Ptr, CharSize, LangOpts)); Ptr += CharSize; } assert(Result.size() != unsigned(Tok.getLength()) && @@ -329,7 +329,7 @@ std::string Lexer::getSpelling(const Token &Tok, const SourceManager &SourceMgr, /// if an internal buffer is returned. unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer, const SourceManager &SourceMgr, - const LangOptions &Features, bool *Invalid) { + const LangOptions &LangOpts, bool *Invalid) { assert((int)Tok.getLength() >= 0 && "Token character range is bogus!"); const char *TokStart = 0; @@ -369,7 +369,7 @@ unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer, for (const char *Ptr = TokStart, *End = TokStart+Tok.getLength(); Ptr != End; ) { unsigned CharSize; - *OutBuf++ = Lexer::getCharAndSizeNoWarn(Ptr, CharSize, Features); + *OutBuf++ = Lexer::getCharAndSizeNoWarn(Ptr, CharSize, LangOpts); Ptr += CharSize; } assert(unsigned(OutBuf-Buffer) != Tok.getLength() && @@ -508,13 +508,13 @@ namespace { std::pair<unsigned, bool> Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer, - const LangOptions &Features, unsigned MaxLines) { + const LangOptions &LangOpts, unsigned MaxLines) { // Create a lexer starting at the beginning of the file. Note that we use a // "fake" file source location at offset 1 so that the lexer will track our // position within the file. const unsigned StartOffset = 1; SourceLocation StartLoc = SourceLocation::getFromRawEncoding(StartOffset); - Lexer TheLexer(StartLoc, Features, Buffer->getBufferStart(), + Lexer TheLexer(StartLoc, LangOpts, Buffer->getBufferStart(), Buffer->getBufferStart(), Buffer->getBufferEnd()); bool InPreprocessorDirective = false; @@ -658,7 +658,7 @@ Lexer::ComputePreamble(const llvm::MemoryBuffer *Buffer, SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart, unsigned CharNo, const SourceManager &SM, - const LangOptions &Features) { + const LangOptions &LangOpts) { // Figure out how many physical characters away the specified expansion // character is. This needs to take into consideration newlines and // trigraphs. @@ -684,7 +684,7 @@ SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart, // lexer to parse it correctly. for (; CharNo; --CharNo) { unsigned Size; - Lexer::getCharAndSizeNoWarn(TokPtr, Size, Features); + Lexer::getCharAndSizeNoWarn(TokPtr, Size, LangOpts); TokPtr += Size; PhysOffset += Size; } @@ -716,16 +716,16 @@ SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart, /// a source location pointing to the last character in the token, etc. SourceLocation Lexer::getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, - const LangOptions &Features) { + const LangOptions &LangOpts) { if (Loc.isInvalid()) return SourceLocation(); if (Loc.isMacroID()) { - if (Offset > 0 || !isAtEndOfMacroExpansion(Loc, SM, Features, &Loc)) + if (Offset > 0 || !isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc)) return SourceLocation(); // Points inside the macro expansion. } - unsigned Len = Lexer::MeasureTokenLength(Loc, SM, Features); + unsigned Len = Lexer::MeasureTokenLength(Loc, SM, LangOpts); if (Len > Offset) Len = Len - Offset; else @@ -1212,7 +1212,7 @@ static char DecodeTrigraphChar(const char *CP, Lexer *L) { char Res = GetTrigraphCharForLetter(*CP); if (!Res || !L) return Res; - if (!L->getFeatures().Trigraphs) { + if (!L->getLangOpts().Trigraphs) { if (!L->isLexingRawMode()) L->Diag(CP-2, diag::trigraph_ignored); return 0; @@ -1405,7 +1405,7 @@ Slash: /// NOTE: When this method is updated, getCharAndSizeSlow (above) should /// be updated to match. char Lexer::getCharAndSizeSlowNoWarn(const char *Ptr, unsigned &Size, - const LangOptions &Features) { + const LangOptions &LangOpts) { // If we have a slash, look for an escaped newline. if (Ptr[0] == '\\') { ++Size; @@ -1427,7 +1427,7 @@ Slash: return ' '; // Use slow version to accumulate a correct size field. - return getCharAndSizeSlowNoWarn(Ptr, Size, Features); + return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts); } // Otherwise, this is not an escaped newline, just return the slash. @@ -1435,7 +1435,7 @@ Slash: } // If this is a trigraph, process it. - if (Features.Trigraphs && Ptr[0] == '?' && Ptr[1] == '?') { + if (LangOpts.Trigraphs && Ptr[0] == '?' && Ptr[1] == '?') { // If this is actually a legal trigraph (not something like "??x"), return // it. if (char C = GetTrigraphCharForLetter(Ptr[2])) { @@ -1478,7 +1478,7 @@ void Lexer::LexIdentifier(Token &Result, const char *CurPtr) { // // TODO: Could merge these checks into a CharInfo flag to make the comparison // cheaper - if (C != '\\' && C != '?' && (C != '$' || !Features.DollarIdents)) { + if (C != '\\' && C != '?' && (C != '$' || !LangOpts.DollarIdents)) { FinishIdentifier: const char *IdStart = BufferPtr; FormTokenWithChars(Result, CurPtr, tok::raw_identifier); @@ -1507,7 +1507,7 @@ FinishIdentifier: while (1) { if (C == '$') { // If we hit a $ and they are not supported in identifiers, we are done. - if (!Features.DollarIdents) goto FinishIdentifier; + if (!LangOpts.DollarIdents) goto FinishIdentifier; // Otherwise, emit a diagnostic and continue. if (!isLexingRawMode()) @@ -1533,12 +1533,12 @@ FinishIdentifier: /// isHexaLiteral - Return true if Start points to a hex constant. /// in microsoft mode (where this is supposed to be several different tokens). -static bool isHexaLiteral(const char *Start, const LangOptions &Features) { +static bool isHexaLiteral(const char *Start, const LangOptions &LangOpts) { unsigned Size; - char C1 = Lexer::getCharAndSizeNoWarn(Start, Size, Features); + char C1 = Lexer::getCharAndSizeNoWarn(Start, Size, LangOpts); if (C1 != '0') return false; - char C2 = Lexer::getCharAndSizeNoWarn(Start + Size, Size, Features); + char C2 = Lexer::getCharAndSizeNoWarn(Start + Size, Size, LangOpts); return (C2 == 'x' || C2 == 'X'); } @@ -1559,7 +1559,7 @@ void Lexer::LexNumericConstant(Token &Result, const char *CurPtr) { if ((C == '-' || C == '+') && (PrevCh == 'E' || PrevCh == 'e')) { // If we are in Microsoft mode, don't continue if the constant is hex. // For example, MSVC will accept the following as 3 tokens: 0x1234567e+1 - if (!Features.MicrosoftExt || !isHexaLiteral(BufferPtr, Features)) + if (!LangOpts.MicrosoftExt || !isHexaLiteral(BufferPtr, LangOpts)) return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result)); } @@ -1576,13 +1576,13 @@ void Lexer::LexNumericConstant(Token &Result, const char *CurPtr) { /// LexUDSuffix - Lex the ud-suffix production for user-defined literal suffixes /// in C++11, or warn on a ud-suffix in C++98. const char *Lexer::LexUDSuffix(Token &Result, const char *CurPtr) { - assert(getFeatures().CPlusPlus); + assert(getLangOpts().CPlusPlus); // Maximally munch an identifier. FIXME: UCNs. unsigned Size; char C = getCharAndSize(CurPtr, Size); if (isIdentifierHead(C)) { - if (!getFeatures().CPlusPlus0x) { + if (!getLangOpts().CPlusPlus0x) { if (!isLexingRawMode()) Diag(CurPtr, C == '_' ? diag::warn_cxx11_compat_user_defined_literal @@ -1632,7 +1632,7 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, if (C == '\n' || C == '\r' || // Newline. (C == 0 && CurPtr-1 == BufferEnd)) { // End of file. - if (!isLexingRawMode() && !Features.AsmPreprocessor) + if (!isLexingRawMode() && !LangOpts.AsmPreprocessor) Diag(BufferPtr, diag::warn_unterminated_string); FormTokenWithChars(Result, CurPtr-1, tok::unknown); return; @@ -1651,7 +1651,7 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, } // If we are in C++11, lex the optional ud-suffix. - if (getFeatures().CPlusPlus) + if (getLangOpts().CPlusPlus) CurPtr = LexUDSuffix(Result, CurPtr); // If a nul character existed in the string, warn about it. @@ -1734,7 +1734,7 @@ void Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, } // If we are in C++11, lex the optional ud-suffix. - if (getFeatures().CPlusPlus) + if (getLangOpts().CPlusPlus) CurPtr = LexUDSuffix(Result, CurPtr); // Update the location of token as well as BufferPtr. @@ -1790,7 +1790,7 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr, char C = getAndAdvanceChar(CurPtr, Result); if (C == '\'') { - if (!isLexingRawMode() && !Features.AsmPreprocessor) + if (!isLexingRawMode() && !LangOpts.AsmPreprocessor) Diag(BufferPtr, diag::err_empty_character); FormTokenWithChars(Result, CurPtr, tok::unknown); return; @@ -1804,7 +1804,7 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr, C = getAndAdvanceChar(CurPtr, Result); } else if (C == '\n' || C == '\r' || // Newline. (C == 0 && CurPtr-1 == BufferEnd)) { // End of file. - if (!isLexingRawMode() && !Features.AsmPreprocessor) + if (!isLexingRawMode() && !LangOpts.AsmPreprocessor) Diag(BufferPtr, diag::warn_unterminated_char); FormTokenWithChars(Result, CurPtr-1, tok::unknown); return; @@ -1821,7 +1821,7 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr, } // If we are in C++11, lex the optional ud-suffix. - if (getFeatures().CPlusPlus) + if (getLangOpts().CPlusPlus) CurPtr = LexUDSuffix(Result, CurPtr); // If a nul character existed in the character, warn about it. @@ -1889,12 +1889,12 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr) { bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { // If BCPL comments aren't explicitly enabled for this language, emit an // extension warning. - if (!Features.BCPLComment && !isLexingRawMode()) { + if (!LangOpts.BCPLComment && !isLexingRawMode()) { Diag(BufferPtr, diag::ext_bcpl_comment); // Mark them enabled so we only emit one warning for this translation // unit. - Features.BCPLComment = true; + LangOpts.BCPLComment = true; } // Scan over the body of the comment. The common case, when scanning, is that @@ -2081,7 +2081,7 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr, // If no trigraphs are enabled, warn that we ignored this trigraph and // ignore this * character. - if (!L->getFeatures().Trigraphs) { + if (!L->getLangOpts().Trigraphs) { if (!L->isLexingRawMode()) L->Diag(CurPtr, diag::trigraph_ignored_block_comment); return false; @@ -2600,7 +2600,7 @@ LexNextToken: case 26: // DOS & CP/M EOF: "^Z". // If we're in Microsoft extensions mode, treat this as end of file. - if (Features.MicrosoftExt) { + if (LangOpts.MicrosoftExt) { // Read the PP instance variable into an automatic variable, because // LexEndOfFile will often delete 'this'. Preprocessor *PPCache = PP; @@ -2653,7 +2653,7 @@ LexNextToken: // If the next token is obviously a // or /* */ comment, skip it efficiently // too (without going through the big switch stmt). if (CurPtr[0] == '/' && CurPtr[1] == '/' && !inKeepCommentMode() && - Features.BCPLComment && !Features.TraditionalCPP) { + LangOpts.BCPLComment && !LangOpts.TraditionalCPP) { if (SkipBCPLComment(Result, CurPtr+2)) return; // There is a token to return. goto SkipIgnoredUnits; @@ -2678,7 +2678,7 @@ LexNextToken: // Notify MIOpt that we read a non-whitespace/non-comment token. MIOpt.ReadToken(); - if (Features.CPlusPlus0x) { + if (LangOpts.CPlusPlus0x) { Char = getCharAndSize(CurPtr, SizeTmp); // UTF-16 string literal @@ -2730,7 +2730,7 @@ LexNextToken: // Notify MIOpt that we read a non-whitespace/non-comment token. MIOpt.ReadToken(); - if (Features.CPlusPlus0x) { + if (LangOpts.CPlusPlus0x) { Char = getCharAndSize(CurPtr, SizeTmp); // UTF-32 string literal @@ -2758,7 +2758,7 @@ LexNextToken: // Notify MIOpt that we read a non-whitespace/non-comment token. MIOpt.ReadToken(); - if (Features.CPlusPlus0x) { + if (LangOpts.CPlusPlus0x) { Char = getCharAndSize(CurPtr, SizeTmp); if (Char == '"') @@ -2781,7 +2781,7 @@ LexNextToken: tok::wide_string_literal); // Wide raw string literal. - if (Features.CPlusPlus0x && Char == 'R' && + if (LangOpts.CPlusPlus0x && Char == 'R' && getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') return LexRawStringLiteral(Result, ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), @@ -2809,7 +2809,7 @@ LexNextToken: return LexIdentifier(Result, CurPtr); case '$': // $ in identifiers. - if (Features.DollarIdents) { + if (LangOpts.DollarIdents) { if (!isLexingRawMode()) Diag(CurPtr-1, diag::ext_dollar_in_identifier); // Notify MIOpt that we read a non-whitespace/non-comment token. @@ -2861,7 +2861,7 @@ LexNextToken: MIOpt.ReadToken(); return LexNumericConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result)); - } else if (Features.CPlusPlus && Char == '*') { + } else if (LangOpts.CPlusPlus && Char == '*') { Kind = tok::periodstar; CurPtr += SizeTmp; } else if (Char == '.' && @@ -2910,7 +2910,7 @@ LexNextToken: if (Char == '-') { // -- CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Kind = tok::minusminus; - } else if (Char == '>' && Features.CPlusPlus && + } else if (Char == '>' && LangOpts.CPlusPlus && getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == '*') { // C++ ->* CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result); @@ -2948,9 +2948,9 @@ LexNextToken: // "foo". Check to see if the character after the second slash is a '*'. // If so, we will lex that as a "/" instead of the start of a comment. // However, we never do this in -traditional-cpp mode. - if ((Features.BCPLComment || + if ((LangOpts.BCPLComment || getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') && - !Features.TraditionalCPP) { + !LangOpts.TraditionalCPP) { if (SkipBCPLComment(Result, ConsumeChar(CurPtr, SizeTmp, Result))) return; // There is a token to return. @@ -2979,17 +2979,17 @@ LexNextToken: if (Char == '=') { Kind = tok::percentequal; CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); - } else if (Features.Digraphs && Char == '>') { + } else if (LangOpts.Digraphs && Char == '>') { Kind = tok::r_brace; // '%>' -> '}' CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); - } else if (Features.Digraphs && Char == ':') { + } else if (LangOpts.Digraphs && Char == ':') { CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Char = getCharAndSize(CurPtr, SizeTmp); if (Char == '%' && getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == ':') { Kind = tok::hashhash; // '%:%:' -> '##' CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result); - } else if (Char == '@' && Features.MicrosoftExt) {// %:@ -> #@ -> Charize + } else if (Char == '@' && LangOpts.MicrosoftExt) {// %:@ -> #@ -> Charize CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); if (!isLexingRawMode()) Diag(BufferPtr, diag::ext_charize_microsoft); @@ -3044,7 +3044,7 @@ LexNextToken: // If this is '<<<<' and we're in a Perforce-style conflict marker, // ignore it. goto LexNextToken; - } else if (Features.CUDA && After == '<') { + } else if (LangOpts.CUDA && After == '<') { Kind = tok::lesslessless; CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result); @@ -3055,8 +3055,8 @@ LexNextToken: } else if (Char == '=') { CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Kind = tok::lessequal; - } else if (Features.Digraphs && Char == ':') { // '<:' -> '[' - if (Features.CPlusPlus0x && + } else if (LangOpts.Digraphs && Char == ':') { // '<:' -> '[' + if (LangOpts.CPlusPlus0x && getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == ':') { // C++0x [lex.pptoken]p3: // Otherwise, if the next three characters are <:: and the subsequent @@ -3075,7 +3075,7 @@ LexNextToken: CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Kind = tok::l_square; - } else if (Features.Digraphs && Char == '%') { // '<%' -> '{' + } else if (LangOpts.Digraphs && Char == '%') { // '<%' -> '{' CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Kind = tok::l_brace; } else { @@ -3100,7 +3100,7 @@ LexNextToken: } else if (After == '>' && HandleEndOfConflictMarker(CurPtr-1)) { // If this is '>>>>>>>' and we're in a conflict marker, ignore it. goto LexNextToken; - } else if (Features.CUDA && After == '>') { + } else if (LangOpts.CUDA && After == '>') { Kind = tok::greatergreatergreater; CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result); @@ -3139,10 +3139,10 @@ LexNextToken: break; case ':': Char = getCharAndSize(CurPtr, SizeTmp); - if (Features.Digraphs && Char == '>') { + if (LangOpts.Digraphs && Char == '>') { Kind = tok::r_square; // ':>' -> ']' CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); - } else if (Features.CPlusPlus && Char == ':') { + } else if (LangOpts.CPlusPlus && Char == ':') { Kind = tok::coloncolon; CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); } else { @@ -3173,7 +3173,7 @@ LexNextToken: if (Char == '#') { Kind = tok::hashhash; CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); - } else if (Char == '@' && Features.MicrosoftExt) { // #@ -> Charize + } else if (Char == '@' && LangOpts.MicrosoftExt) { // #@ -> Charize Kind = tok::hashat; if (!isLexingRawMode()) Diag(BufferPtr, diag::ext_charize_microsoft); @@ -3209,7 +3209,7 @@ LexNextToken: case '@': // Objective C support. - if (CurPtr[-1] == '@' && Features.ObjC1) + if (CurPtr[-1] == '@' && LangOpts.ObjC1) Kind = tok::at; else Kind = tok::unknown; diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index ae8157dabf..c1d228b879 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -482,7 +482,7 @@ NumericLiteralParser(const char *begin, const char *end, continue; // Success. case 'i': case 'I': - if (PP.getLangOptions().MicrosoftExt) { + if (PP.getLangOpts().MicrosoftExt) { if (isFPConstant || isLong || isLongLong) break; // Allow i8, i16, i32, i64, and i128. @@ -542,7 +542,7 @@ NumericLiteralParser(const char *begin, const char *end, } if (s != ThisTokEnd) { - if (PP.getLangOptions().CPlusPlus0x && s == SuffixBegin && *s == '_') { + if (PP.getLangOpts().CPlusPlus0x && s == SuffixBegin && *s == '_') { // We have a ud-suffix! By C++11 [lex.ext]p10, ud-suffixes not starting // with an '_' are ill-formed. saw_ud_suffix = true; @@ -608,7 +608,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { } s = first_non_digit; - if (!PP.getLangOptions().HexFloats) + if (!PP.getLangOpts().HexFloats) PP.Diag(TokLoc, diag::ext_hexconstant_invalid); } else if (saw_period) { PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin), @@ -902,7 +902,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end, unsigned short UcnLen = 0; if (!ProcessUCNEscape(TokBegin, begin, end, *buffer_begin, UcnLen, FullSourceLoc(Loc, PP.getSourceManager()), - &PP.getDiagnostics(), PP.getLangOptions(), + &PP.getDiagnostics(), PP.getLangOpts(), true)) { HadError = true; @@ -967,7 +967,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end, // character constants are not sign extended in the this implementation: // '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC. if (isAscii() && NumCharsSoFar == 1 && (Value & 128) && - PP.getLangOptions().CharIsSigned) + PP.getLangOpts().CharIsSigned) Value = (signed char)Value; } @@ -1027,7 +1027,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end, StringLiteralParser:: StringLiteralParser(const Token *StringToks, unsigned NumStringToks, Preprocessor &PP, bool Complain) - : SM(PP.getSourceManager()), Features(PP.getLangOptions()), + : SM(PP.getSourceManager()), Features(PP.getLangOpts()), Target(PP.getTargetInfo()), Diags(Complain ? &PP.getDiagnostics() : 0), MaxTokenLength(0), SizeBound(0), CharByteWidth(0), Kind(tok::unknown), ResultPtr(ResultBuf.data()), hadError(false), Pascal(false) { diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 7345ef2197..53bb5c354e 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -124,7 +124,7 @@ void Preprocessor::ReadMacroName(Token &MacroNameTok, char isDefineUndef) { const IdentifierInfo &Info = Identifiers.get(Spelling); // Allow #defining |and| and friends in microsoft mode. - if (Info.isCPlusPlusOperatorKeyword() && getLangOptions().MicrosoftMode) { + if (Info.isCPlusPlusOperatorKeyword() && getLangOpts().MicrosoftMode) { MacroNameTok.setIdentifierInfo(getIdentifierInfo(Spelling)); return; } @@ -181,7 +181,7 @@ void Preprocessor::CheckEndOfDirective(const char *DirType, bool EnableMacros) { // trouble than it is worth to insert /**/ and check that there is no /**/ // in the range also. FixItHint Hint; - if ((Features.GNUMode || Features.C99 || Features.CPlusPlus) && + if ((LangOpts.GNUMode || LangOpts.C99 || LangOpts.CPlusPlus) && !CurTokenLexer) Hint = FixItHint::CreateInsertion(Tmp.getLocation(),"//"); Diag(Tmp, diag::ext_pp_extra_tokens_at_eol) << DirType << Hint; @@ -619,7 +619,7 @@ TryAgain: setCodeCompletionReached(); return; case tok::numeric_constant: // # 7 GNU line marker directive. - if (getLangOptions().AsmPreprocessor) + if (getLangOpts().AsmPreprocessor) break; // # 4 is not a preprocessor directive in .S files. return HandleDigitDirective(Result); default: @@ -690,12 +690,12 @@ TryAgain: break; case tok::pp___public_macro: - if (getLangOptions().Modules) + if (getLangOpts().Modules) return HandleMacroPublicDirective(Result); break; case tok::pp___private_macro: - if (getLangOptions().Modules) + if (getLangOpts().Modules) return HandleMacroPrivateDirective(Result); break; } @@ -706,7 +706,7 @@ TryAgain: // directives. This is important because # may be a comment or introduce // various pseudo-ops. Just return the # token and push back the following // token to be lexed next time. - if (getLangOptions().AsmPreprocessor) { + if (getLangOpts().AsmPreprocessor) { Token *Toks = new Token[2]; // Return the # and the token after it. Toks[0] = SavedHash; @@ -805,11 +805,11 @@ void Preprocessor::HandleLineDirective(Token &Tok) { // Enforce C99 6.10.4p3: "The digit sequence shall not specify ... a // number greater than 2147483647". C90 requires that the line # be <= 32767. unsigned LineLimit = 32768U; - if (Features.C99 || Features.CPlusPlus0x) + if (LangOpts.C99 || LangOpts.CPlusPlus0x) LineLimit = 2147483648U; if (LineNo >= LineLimit) Diag(DigitTok, diag::ext_pp_line_too_big) << LineLimit; - else if (Features.CPlusPlus0x && LineNo >= 32768U) + else if (LangOpts.CPlusPlus0x && LineNo >= 32768U) Diag(DigitTok, diag::warn_cxx98_compat_pp_line_too_big); int FilenameID = -1; @@ -1334,7 +1334,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, const FileEntry *File = LookupFile( Filename, isAngled, LookupFrom, CurDir, Callbacks ? &SearchPath : NULL, Callbacks ? &RelativePath : NULL, - getLangOptions().Modules? &SuggestedModule : 0); + getLangOpts().Modules? &SuggestedModule : 0); if (Callbacks) { if (!File) { @@ -1348,7 +1348,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // Try the lookup again, skipping the cache. File = LookupFile(Filename, isAngled, LookupFrom, CurDir, 0, 0, - getLangOptions().Modules? &SuggestedModule : 0, + getLangOpts().Modules? &SuggestedModule : 0, /*SkipCache*/true); } } @@ -1410,9 +1410,9 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // Determine whether we are actually building the module that this // include directive maps to. bool BuildingImportedModule - = Path[0].first->getName() == getLangOptions().CurrentModule; + = Path[0].first->getName() == getLangOpts().CurrentModule; - if (!BuildingImportedModule && getLangOptions().ObjC2) { + if (!BuildingImportedModule && getLangOpts().ObjC2) { // If we're not building the imported module, warn that we're going // to automatically turn this inclusion directive into a module import. // We only do this in Objective-C, where we have a module-import syntax. @@ -1488,7 +1488,7 @@ void Preprocessor::HandleIncludeNextDirective(SourceLocation HashLoc, /// void Preprocessor::HandleImportDirective(SourceLocation HashLoc, Token &ImportTok) { - if (!Features.ObjC1) // #import is standard for ObjC. + if (!LangOpts.ObjC1) // #import is standard for ObjC. Diag(ImportTok, diag::ext_pp_import_directive); return HandleIncludeDirective(HashLoc, ImportTok, 0, true); @@ -1544,8 +1544,8 @@ bool Preprocessor::ReadMacroDefinitionArgList(MacroInfo *MI) { Diag(Tok, diag::err_pp_expected_ident_in_arg_list); return true; case tok::ellipsis: // #define X(... -> C99 varargs - if (!Features.C99) - Diag(Tok, Features.CPlusPlus0x ? + if (!LangOpts.C99) + Diag(Tok, LangOpts.CPlusPlus0x ? diag::warn_cxx98_compat_variadic_macro : diag::ext_variadic_macro); @@ -1671,7 +1671,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { // Read the first token after the arg list for down below. LexUnexpandedToken(Tok); - } else if (Features.C99 || Features.CPlusPlus0x) { + } else if (LangOpts.C99 || LangOpts.CPlusPlus0x) { // C99 requires whitespace between the macro definition and the body. Emit // a diagnostic for something like "#define X+". Diag(Tok, diag::ext_c99_whitespace_required_after_macro_name); @@ -1736,7 +1736,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { // the '#' because '#' is often a comment character. However, change // the kind of the token to tok::unknown so that the preprocessor isn't // confused. - if (getLangOptions().AsmPreprocessor && Tok.isNot(tok::eod)) { + if (getLangOpts().AsmPreprocessor && Tok.isNot(tok::eod)) { LastTok.setKind(tok::unknown); } else { Diag(Tok, diag::err_pp_stringize_not_parameter); diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index ae2f5c1ab2..7cac63eb0f 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -220,8 +220,8 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, PP.Diag(PeekTok, diag::err_pp_invalid_udl) << /*integer*/1; // long long is a C99 feature. - if (!PP.getLangOptions().C99 && Literal.isLongLong) - PP.Diag(PeekTok, PP.getLangOptions().CPlusPlus0x ? + if (!PP.getLangOpts().C99 && Literal.isLongLong) + PP.Diag(PeekTok, PP.getLangOpts().CPlusPlus0x ? diag::warn_cxx98_compat_longlong : diag::ext_longlong); // Parse the integer literal into Result. @@ -290,7 +290,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, Val = Literal.getValue(); // Set the signedness. UTF-16 and UTF-32 are always unsigned if (!Literal.isUTF16() && !Literal.isUTF32()) - Val.setIsUnsigned(!PP.getLangOptions().CharIsSigned); + Val.setIsUnsigned(!PP.getLangOpts().CharIsSigned); if (Result.Val.getBitWidth() > Val.getBitWidth()) { Result.Val = Val.extend(Result.Val.getBitWidth()); @@ -654,7 +654,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, case tok::comma: // Comma is invalid in pp expressions in c89/c++ mode, but is valid in C99 // if not being evaluated. - if (!PP.getLangOptions().C99 || ValueLive) + if (!PP.getLangOpts().C99 || ValueLive) PP.Diag(OpLoc, diag::ext_pp_comma_expr) << LHS.getRange() << RHS.getRange(); Res = RHS.Val; // LHS = LHS,RHS -> RHS. diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 26e0ffb5d4..bc04bc95a7 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -101,7 +101,7 @@ void Preprocessor::RegisterBuiltinMacros() { Ident__has_warning = RegisterBuiltinMacro(*this, "__has_warning"); // Microsoft Extensions. - if (Features.MicrosoftExt) + if (LangOpts.MicrosoftExt) Ident__pragma = RegisterBuiltinMacro(*this, "__pragma"); else Ident__pragma = 0; @@ -433,8 +433,8 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // Empty arguments are standard in C99 and C++0x, and are supported as an extension in // other modes. - if (ArgTokens.size() == ArgTokenStart && !Features.C99) - Diag(Tok, Features.CPlusPlus0x ? + if (ArgTokens.size() == ArgTokenStart && !LangOpts.C99) + Diag(Tok, LangOpts.CPlusPlus0x ? diag::warn_cxx98_compat_empty_fnmacro_arg : diag::ext_empty_fnmacro_arg); @@ -588,7 +588,7 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, /// HasFeature - Return true if we recognize and implement the feature /// specified by the identifier as a standard language feature. static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { - const LangOptions &LangOpts = PP.getLangOptions(); + const LangOptions &LangOpts = PP.getLangOpts(); StringRef Feature = II->getName(); // Normalize the feature name, __foo__ becomes foo. @@ -732,7 +732,7 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) { DiagnosticsEngine::Ext_Error) return false; - const LangOptions &LangOpts = PP.getLangOptions(); + const LangOptions &LangOpts = PP.getLangOpts(); StringRef Extension = II->getName(); // Normalize the extension name, __foo__ becomes foo. diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 404feaab46..5d65cc4f23 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -1230,7 +1230,7 @@ void Preprocessor::RegisterBuiltinPragmas() { AddPragmaHandler("STDC", new PragmaSTDC_UnknownHandler()); // MS extensions. - if (Features.MicrosoftExt) { + if (LangOpts.MicrosoftExt) { AddPragmaHandler(new PragmaCommentHandler()); AddPragmaHandler(new PragmaIncludeAliasHandler()); } diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 06914c7cdc..6142436e6d 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -55,7 +55,7 @@ Preprocessor::Preprocessor(DiagnosticsEngine &diags, LangOptions &opts, IdentifierInfoLookup* IILookup, bool OwnsHeaders, bool DelayInitialization) - : Diags(&diags), Features(opts), Target(target),FileMgr(Headers.getFileMgr()), + : Diags(&diags), LangOpts(opts), Target(target),FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), ExternalSource(0), Identifiers(opts, IILookup), CodeComplete(0), @@ -153,7 +153,7 @@ void Preprocessor::Initialize(const TargetInfo &Target) { // Initialize builtin macros like __LINE__ and friends. RegisterBuiltinMacros(); - if(Features.Borland) { + if(LangOpts.Borland) { Ident__exception_info = getIdentifierInfo("_exception_info"); Ident___exception_info = getIdentifierInfo("__exception_info"); Ident_GetExceptionInfo = getIdentifierInfo("GetExceptionInformation"); @@ -382,10 +382,10 @@ void Preprocessor::CreateString(const char *Buf, unsigned Len, Token &Tok, } |