aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/FormatTokenLexer.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2024-02-11 21:54:32 -0800
committerOwen Pan <owenpiano@gmail.com>2024-02-11 22:01:23 -0800
commit32e65b0b8a743678974c7ca7913c1d6c41bb0772 (patch)
treede466e119924a7a35f0ff7e104e18dc13df64fa2 /clang/lib/Format/FormatTokenLexer.cpp
parent5da801386c2b820a4596fc6d8da6b5f4a6da94b4 (diff)
downloadllvm-32e65b0b8a743678974c7ca7913c1d6c41bb0772.zip
llvm-32e65b0b8a743678974c7ca7913c1d6c41bb0772.tar.gz
llvm-32e65b0b8a743678974c7ca7913c1d6c41bb0772.tar.bz2
Reland "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"
Restore getFormattingLangOpts().
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r--clang/lib/Format/FormatTokenLexer.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp
index a87d0ba..a57659f 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -13,11 +13,7 @@
//===----------------------------------------------------------------------===//
#include "FormatTokenLexer.h"
-#include "FormatToken.h"
-#include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Format/Format.h"
-#include "llvm/Support/Regex.h"
+#include "TokenAnalyzer.h"
namespace clang {
namespace format {
@@ -28,12 +24,12 @@ FormatTokenLexer::FormatTokenLexer(
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
IdentifierTable &IdentTable)
: FormatTok(nullptr), IsFirstToken(true), StateStack({LexerState::NORMAL}),
- Column(Column), TrailingWhitespace(0),
- LangOpts(getFormattingLangOpts(Style)), SourceMgr(SourceMgr), ID(ID),
+ Column(Column), TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID),
Style(Style), IdentTable(IdentTable), Keywords(IdentTable),
Encoding(Encoding), Allocator(Allocator), FirstInLineIndex(0),
FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin),
MacroBlockEndRegex(Style.MacroBlockEnd) {
+ assert(LangOpts.CPlusPlus);
Lex.reset(new Lexer(ID, SourceMgr.getBufferOrFake(ID), SourceMgr, LangOpts));
Lex->SetKeepWhitespaceMode(true);
@@ -1442,7 +1438,7 @@ void FormatTokenLexer::readRawToken(FormatToken &Tok) {
void FormatTokenLexer::resetLexer(unsigned Offset) {
StringRef Buffer = SourceMgr.getBufferData(ID);
- LangOpts = getFormattingLangOpts(Style);
+ assert(LangOpts.CPlusPlus);
Lex.reset(new Lexer(SourceMgr.getLocForStartOfFile(ID), LangOpts,
Buffer.begin(), Buffer.begin() + Offset, Buffer.end()));
Lex->SetKeepWhitespaceMode(true);