aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/FormatTokenLexer.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.h')
-rw-r--r--clang/lib/Format/FormatTokenLexer.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.h b/clang/lib/Format/FormatTokenLexer.h
index 611211be055a..6b08677e3369 100644
--- a/clang/lib/Format/FormatTokenLexer.h
+++ b/clang/lib/Format/FormatTokenLexer.h
@@ -21,6 +21,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Format/Format.h"
#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Regex.h"
#include <stack>
@@ -37,7 +38,9 @@ enum LexerState {
class FormatTokenLexer {
public:
FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, unsigned Column,
- const FormatStyle &Style, encoding::Encoding Encoding);
+ const FormatStyle &Style, encoding::Encoding Encoding,
+ llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
+ IdentifierTable &IdentTable);
ArrayRef<FormatToken *> lex();
@@ -49,11 +52,13 @@ private:
bool tryMergeLessLess();
bool tryMergeNSStringLiteral();
bool tryMergeJSPrivateIdentifier();
- bool tryMergeCSharpVerbatimStringLiteral();
+ bool tryMergeCSharpStringLiteral();
bool tryMergeCSharpKeywordVariables();
- bool tryMergeCSharpNullConditionals();
bool tryMergeCSharpDoubleQuestion();
+ bool tryMergeCSharpNullConditional();
bool tryTransformCSharpForEach();
+ bool tryMergeForEach();
+ bool tryTransformTryUsageForC();
bool tryMergeTokens(ArrayRef<tok::TokenKind> Kinds, TokenType NewType);
@@ -79,6 +84,8 @@ private:
// nested template parts by balancing curly braces.
void handleTemplateStrings();
+ void handleCSharpVerbatimAndInterpolatedStrings();
+
void tryParsePythonComment();
bool tryMerge_TMacro();
@@ -98,10 +105,10 @@ private:
const SourceManager &SourceMgr;
FileID ID;
const FormatStyle &Style;
- IdentifierTable IdentTable;
+ IdentifierTable &IdentTable;
AdditionalKeywords Keywords;
encoding::Encoding Encoding;
- llvm::SpecificBumpPtrAllocator<FormatToken> Allocator;
+ llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator;
// Index (in 'Tokens') of the last token that starts a new line.
unsigned FirstInLineIndex;
SmallVector<FormatToken *, 16> Tokens;
@@ -113,6 +120,9 @@ private:
llvm::Regex MacroBlockBeginRegex;
llvm::Regex MacroBlockEndRegex;
+ // Targets that may appear inside a C# attribute.
+ static const llvm::StringSet<> CSharpAttributeTargets;
+
void readRawToken(FormatToken &Tok);
void resetLexer(unsigned Offset);