diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h --- a/clang/include/clang/Lex/Lexer.h +++ b/clang/include/clang/Lex/Lexer.h @@ -183,10 +183,6 @@ SourceLocation ExpansionLocEnd, unsigned TokLen, Preprocessor &PP); - /// getLangOpts - Return the language features currently enabled. - /// NOTE: this lexer modifies features as a file is parsed! - const LangOptions &getLangOpts() const { return LangOpts; } - /// getFileLoc - Return the File Location for the file we are lexing out of. /// The physical location encodes the location where the characters come from, /// the virtual location encodes where we should *claim* the characters came 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 @@ -1194,11 +1194,11 @@ /// prefixed with ??, emit a trigraph warning. If trigraphs are enabled, /// return the result character. Finally, emit a warning about trigraph use /// whether trigraphs are enabled or not. -static char DecodeTrigraphChar(const char *CP, Lexer *L) { +static char DecodeTrigraphChar(const char *CP, Lexer *L, bool Trigraphs) { char Res = GetTrigraphCharForLetter(*CP); if (!Res || !L) return Res; - if (!L->getLangOpts().Trigraphs) { + if (!Trigraphs) { if (!L->isLexingRawMode()) L->Diag(CP-2, diag::trigraph_ignored); return 0; @@ -1372,7 +1372,8 @@ if (Ptr[0] == '?' && Ptr[1] == '?') { // If this is actually a legal trigraph (not something like "??x"), emit // a trigraph warning. If so, and if trigraphs are enabled, return it. - if (char C = DecodeTrigraphChar(Ptr+2, Tok ? this : nullptr)) { + if (char C = DecodeTrigraphChar(Ptr + 2, Tok ? this : nullptr, + LangOpts.Trigraphs)) { // Remember that this token needs to be cleaned. if (Tok) Tok->setFlag(Token::NeedsCleaning); @@ -2543,8 +2544,8 @@ /// isBlockCommentEndOfEscapedNewLine - Return true if the specified newline /// character (either \\n or \\r) is part of an escaped newline sequence. Issue /// a diagnostic if so. We know that the newline is inside of a block comment. -static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr, - Lexer *L) { +static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr, Lexer *L, + bool Trigraphs) { assert(CurPtr[0] == '\n' || CurPtr[0] == '\r'); // Position of the first trigraph in the ending sequence. @@ -2595,7 +2596,7 @@ if (TrigraphPos) { // If no trigraphs are enabled, warn that we ignored this trigraph and // ignore this * character. - if (!L->getLangOpts().Trigraphs) { + if (!Trigraphs) { if (!L->isLexingRawMode()) L->Diag(TrigraphPos, diag::trigraph_ignored_block_comment); return false; @@ -2725,7 +2726,8 @@ break; if ((CurPtr[-2] == '\n' || CurPtr[-2] == '\r')) { - if (isEndOfBlockCommentWithEscapedNewLine(CurPtr-2, this)) { + if (isEndOfBlockCommentWithEscapedNewLine(CurPtr - 2, this, + LangOpts.Trigraphs)) { // We found the final */, though it had an escaped newline between the // * and /. We're done! break; diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1625,7 +1625,7 @@ SpellingBuffer.resize(LToken.getLength() + 1); const char *Start = SpellingBuffer.data(); unsigned Length = - Lexer::getSpelling(LToken, Start, SourceMgr, L.getLangOpts()); + Lexer::getSpelling(LToken, Start, SourceMgr, Map.LangOpts); uint64_t Value; if (StringRef(Start, Length).getAsInteger(0, Value)) { Diags.Report(Tok.getLocation(), diag::err_mmap_unknown_token);