diff options
author | Dawid Jurczak <dawid_jurek@vp.pl> | 2022-03-01 17:24:13 +0100 |
---|---|---|
committer | Dawid Jurczak <dawid_jurek@vp.pl> | 2022-03-02 11:17:05 +0100 |
commit | d813116c9deaa960ddcce5b4b161ea589d6e9a34 (patch) | |
tree | c3efbbc9609c36a32a2acb059347adebc48acaf5 /clang/lib | |
parent | 83fd2071f0d4033f75234b13398b1de1f6b4c4f3 (diff) | |
download | llvm-d813116c9deaa960ddcce5b4b161ea589d6e9a34.zip llvm-d813116c9deaa960ddcce5b4b161ea589d6e9a34.tar.gz llvm-d813116c9deaa960ddcce5b4b161ea589d6e9a34.tar.bz2 |
[NFC][Lexer] Remove getLangOpts function from Lexer
Given that there is only one external user of Lexer::getLangOpts
we can remove getter entirely without much pain.
Differential Revision: https://reviews.llvm.org/D120404
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 63ad438..6e8072f 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1194,11 +1194,11 @@ static char GetTrigraphCharForLetter(char Letter) { /// 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 @@ Slash: 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 @@ bool Lexer::SaveLineComment(Token &Result, const char *CurPtr) { /// 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 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr, 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 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr, 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 index 824b2bb..a5eca40 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1625,7 +1625,7 @@ retry: 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); |