15#ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
16#define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
24struct UnwrappedLineNode;
107 llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
113 enum class IfStmtKind {
122 bool precededByCommentOrPPDirective()
const;
123 bool parseLevel(
const FormatToken *OpeningBrace =
nullptr,
124 IfStmtKind *IfKind =
nullptr,
128 FormatToken *parseBlock(
bool MustBeDeclaration =
false,
129 unsigned AddLevels = 1u,
bool MunchSemi =
true,
130 bool KeepBraces =
true, IfStmtKind *IfKind =
nullptr,
131 bool UnindentWhitesmithsBraces =
false);
132 void parseChildBlock();
133 void parsePPDirective();
134 void parsePPDefine();
135 void parsePPIf(
bool IfDef);
138 void parsePPPragma();
139 void parsePPUnknown();
140 void readTokenWithJavaScriptASI();
141 void parseStructuralElement(
const FormatToken *OpeningBrace =
nullptr,
142 IfStmtKind *IfKind =
nullptr,
144 bool *HasDoWhile =
nullptr,
145 bool *HasLabel =
nullptr);
146 bool tryToParseBracedList();
147 bool parseBracedList(
bool IsAngleBracket =
false,
bool IsEnum =
false);
148 bool parseParens(
TokenType AmpAmpTokenType = TT_Unknown);
150 void keepAncestorBraces();
151 void parseUnbracedBody(
bool CheckEOF =
false);
152 void handleAttributes();
153 bool handleCppAttributes();
155 FormatToken *parseIfThenElse(IfStmtKind *IfKind,
bool KeepBraces =
false,
156 bool IsVerilogAssert =
false);
157 void parseTryCatch();
158 void parseLoopBody(
bool KeepBraces,
bool WrapRightBrace);
159 void parseForOrWhileLoop(
bool HasParens =
true);
161 void parseLabel(
bool LeftAlignLabel =
false);
162 void parseCaseLabel();
163 void parseSwitch(
bool IsExpr);
164 void parseNamespace();
165 bool parseModuleImport();
167 void parseAccessSpecifier();
169 bool parseStructLike();
170 bool parseRequires();
171 void parseRequiresClause(
FormatToken *RequiresToken);
172 void parseRequiresExpression(
FormatToken *RequiresToken);
173 void parseConstraintExpression();
174 void parseJavaEnumBody();
178 void parseRecord(
bool ParseAsExpr =
false);
179 void parseObjCLightweightGenerics();
180 void parseObjCMethod();
181 void parseObjCProtocolList();
182 void parseObjCUntilAtEnd();
183 void parseObjCInterfaceOrImplementation();
184 bool parseObjCProtocol();
185 void parseJavaScriptEs6ImportExport();
186 void parseStatementMacro();
187 void parseCSharpAttribute();
191 void parseCSharpGenericTypeConstraint();
192 bool tryToParseLambda();
193 bool tryToParseChildBlock();
194 bool tryToParseLambdaIntroducer();
195 bool tryToParsePropertyAccessor();
196 void tryToParseJSFunction();
197 bool tryToParseSimpleAttribute();
198 void parseVerilogHierarchyIdentifier();
199 void parseVerilogSensitivityList();
202 unsigned parseVerilogHierarchyHeader();
203 void parseVerilogTable();
204 void parseVerilogCaseLabel();
205 std::optional<llvm::SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
210 enum class LineLevel { Remove, Keep };
212 void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::Remove);
218 void nextToken(
int LevelDifference = 0);
219 void readToken(
int LevelDifference = 0);
235 void flushComments(
bool NewlineBeforeNext);
237 void calculateBraceTypes(
bool ExpectClassBody =
false);
244 void conditionalCompilationCondition(
bool Unreachable);
245 void conditionalCompilationStart(
bool Unreachable);
246 void conditionalCompilationAlternative();
247 void conditionalCompilationEnd();
258 size_t computePPHash()
const;
260 bool parsingPPDirective()
const {
return CurrentLines != &Lines; }
265 std::unique_ptr<UnwrappedLine> Line;
279 llvm::DenseMap<FormatToken *, SmallVector<UnwrappedLine, 8>> ExpandedLines;
283 llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>> Unexpanded;
287 bool InExpansion =
false;
292 std::optional<MacroCallReconstructor> Reconstruct;
300 bool MustBreakBeforeNextToken;
318 llvm::BitVector DeclarationScopeStack;
325 llvm::Regex CommentPragmasRegex;
342 bool IsDecltypeAutoFunction =
false;
352 PPBranch(PPBranchKind Kind,
size_t Line) : Kind(Kind), Line(Line) {}
379 std::stack<int> PPChainBranchIndex;
383 enum IncludeGuardState {
392 IncludeGuardState IncludeGuard;
401 unsigned FirstStartColumn;
This file contains the main building blocks of macro support in clang-format.
Implements an efficient mapping from strings to IdentifierInfo nodes.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.