diff options
author | Owen Pan <owenpiano@gmail.com> | 2024-02-11 13:08:28 -0800 |
---|---|---|
committer | Owen Pan <owenpiano@gmail.com> | 2024-02-11 13:08:28 -0800 |
commit | 3dc8ef677d7d05116a0bf6524eb38b02ca6ba042 (patch) | |
tree | dfb7d5b693eb69fdf93fdfeb58a5b9d42dd18f76 /clang/lib/Format/FormatTokenLexer.cpp | |
parent | 03f571995b4f0c260254955afd16ec44d0764794 (diff) | |
download | llvm-3dc8ef677d7d05116a0bf6524eb38b02ca6ba042.zip llvm-3dc8ef677d7d05116a0bf6524eb38b02ca6ba042.tar.gz llvm-3dc8ef677d7d05116a0bf6524eb38b02ca6ba042.tar.bz2 |
Revert "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"
This reverts commit 03f571995b4f0c260254955afd16ec44d0764794.
We can't hide getFormattingLangOpts() as it's used by other tools.
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r-- | clang/lib/Format/FormatTokenLexer.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index a57659f..a87d0ba 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -13,7 +13,11 @@ //===----------------------------------------------------------------------===// #include "FormatTokenLexer.h" -#include "TokenAnalyzer.h" +#include "FormatToken.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Format/Format.h" +#include "llvm/Support/Regex.h" namespace clang { namespace format { @@ -24,12 +28,12 @@ FormatTokenLexer::FormatTokenLexer( llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator, IdentifierTable &IdentTable) : FormatTok(nullptr), IsFirstToken(true), StateStack({LexerState::NORMAL}), - Column(Column), TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID), + Column(Column), TrailingWhitespace(0), + LangOpts(getFormattingLangOpts(Style)), 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); @@ -1438,7 +1442,7 @@ void FormatTokenLexer::readRawToken(FormatToken &Tok) { void FormatTokenLexer::resetLexer(unsigned Offset) { StringRef Buffer = SourceMgr.getBufferData(ID); - assert(LangOpts.CPlusPlus); + LangOpts = getFormattingLangOpts(Style); Lex.reset(new Lexer(SourceMgr.getLocForStartOfFile(ID), LangOpts, Buffer.begin(), Buffer.begin() + Offset, Buffer.end())); Lex->SetKeepWhitespaceMode(true); |