[PATCH] D120404: [NFC][Lexer] Remove getLangOpts function from Lexer
Dawid Jurczak via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 2 02:18:04 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd813116c9dea: [NFC][Lexer] Remove getLangOpts function from Lexer (authored by yurai007).
Herald added a project: All.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120404/new/
https://reviews.llvm.org/D120404
Files:
clang/include/clang/Lex/Lexer.h
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/ModuleMap.cpp
Index: clang/lib/Lex/ModuleMap.cpp
===================================================================
--- clang/lib/Lex/ModuleMap.cpp
+++ 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);
Index: clang/lib/Lex/Lexer.cpp
===================================================================
--- clang/lib/Lex/Lexer.cpp
+++ 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;
Index: clang/include/clang/Lex/Lexer.h
===================================================================
--- clang/include/clang/Lex/Lexer.h
+++ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120404.412359.patch
Type: text/x-patch
Size: 4098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220302/f9afbdd7/attachment.bin>
More information about the cfe-commits
mailing list