15#ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
16#define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
24struct UnwrappedLineNode;
104 llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
110 enum class IfStmtKind {
119 bool precededByCommentOrPPDirective()
const;
120 bool parseLevel(
const FormatToken *OpeningBrace =
nullptr,
121 IfStmtKind *IfKind =
nullptr,
125 FormatToken *parseBlock(
bool MustBeDeclaration =
false,
126 unsigned AddLevels = 1u,
bool MunchSemi =
true,
127 bool KeepBraces =
true, IfStmtKind *IfKind =
nullptr,
128 bool UnindentWhitesmithsBraces =
false);
129 void parseChildBlock();
130 void parsePPDirective();
131 void parsePPDefine();
132 void parsePPIf(
bool IfDef);
135 void parsePPPragma();
136 void parsePPUnknown();
137 void readTokenWithJavaScriptASI();
138 void parseStructuralElement(
const FormatToken *OpeningBrace =
nullptr,
139 IfStmtKind *IfKind =
nullptr,
141 bool *HasDoWhile =
nullptr,
142 bool *HasLabel =
nullptr);
143 bool tryToParseBracedList();
144 bool parseBracedList(
bool IsAngleBracket =
false,
bool IsEnum =
false);
145 bool parseParens(
TokenType AmpAmpTokenType = TT_Unknown);
147 void keepAncestorBraces();
148 void parseUnbracedBody(
bool CheckEOF =
false);
149 void handleAttributes();
150 bool handleCppAttributes();
152 FormatToken *parseIfThenElse(IfStmtKind *IfKind,
bool KeepBraces =
false,
153 bool IsVerilogAssert =
false);
154 void parseTryCatch();
155 void parseLoopBody(
bool KeepBraces,
bool WrapRightBrace);
156 void parseForOrWhileLoop(
bool HasParens =
true);
158 void parseLabel(
bool LeftAlignLabel =
false);
159 void parseCaseLabel();
161 void parseNamespace();
162 bool parseModuleImport();
164 void parseAccessSpecifier();
166 bool parseStructLike();
167 bool parseRequires();
168 void parseRequiresClause(
FormatToken *RequiresToken);
169 void parseRequiresExpression(
FormatToken *RequiresToken);
170 void parseConstraintExpression();
171 void parseJavaEnumBody();
175 void parseRecord(
bool ParseAsExpr =
false);
176 void parseObjCLightweightGenerics();
177 void parseObjCMethod();
178 void parseObjCProtocolList();
179 void parseObjCUntilAtEnd();
180 void parseObjCInterfaceOrImplementation();
181 bool parseObjCProtocol();
182 void parseJavaScriptEs6ImportExport();
183 void parseStatementMacro();
184 void parseCSharpAttribute();
188 void parseCSharpGenericTypeConstraint();
189 bool tryToParseLambda();
190 bool tryToParseChildBlock();
191 bool tryToParseLambdaIntroducer();
192 bool tryToParsePropertyAccessor();
193 void tryToParseJSFunction();
194 bool tryToParseSimpleAttribute();
195 void parseVerilogHierarchyIdentifier();
196 void parseVerilogSensitivityList();
199 unsigned parseVerilogHierarchyHeader();
200 void parseVerilogTable();
201 void parseVerilogCaseLabel();
202 std::optional<llvm::SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
207 enum class LineLevel { Remove, Keep };
209 void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::Remove);
215 void nextToken(
int LevelDifference = 0);
216 void readToken(
int LevelDifference = 0);
232 void flushComments(
bool NewlineBeforeNext);
234 void calculateBraceTypes(
bool ExpectClassBody =
false);
241 void conditionalCompilationCondition(
bool Unreachable);
242 void conditionalCompilationStart(
bool Unreachable);
243 void conditionalCompilationAlternative();
244 void conditionalCompilationEnd();
255 size_t computePPHash()
const;
257 bool parsingPPDirective()
const {
return CurrentLines != &Lines; }
262 std::unique_ptr<UnwrappedLine> Line;
276 llvm::DenseMap<FormatToken *, SmallVector<UnwrappedLine, 8>> ExpandedLines;
280 llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>> Unexpanded;
284 bool InExpansion =
false;
289 std::optional<MacroCallReconstructor> Reconstruct;
297 bool MustBreakBeforeNextToken;
315 llvm::BitVector DeclarationScopeStack;
320 llvm::Regex CommentPragmasRegex;
337 bool IsDecltypeAutoFunction =
false;
347 PPBranch(PPBranchKind Kind,
size_t Line) : Kind(Kind), Line(Line) {}
374 std::stack<int> PPChainBranchIndex;
378 enum IncludeGuardState {
387 IncludeGuardState IncludeGuard;
396 unsigned FirstStartColumn;
This file contains the main building blocks of macro support in clang-format.
Implements an efficient mapping from strings to IdentifierInfo nodes.
This class handles loading and caching of source files into memory.
The base class of the type hierarchy.
The JSON file list parser is used to communicate input to InstallAPI.
Represents a complete lambda introducer.