15#ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
16#define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
109 llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
115 enum class IfStmtKind {
124 bool precededByCommentOrPPDirective()
const;
125 bool parseLevel(
const FormatToken *OpeningBrace =
nullptr,
126 IfStmtKind *IfKind =
nullptr,
130 FormatToken *parseBlock(
bool MustBeDeclaration =
false,
131 unsigned AddLevels = 1u,
bool MunchSemi =
true,
132 bool KeepBraces =
true, IfStmtKind *IfKind =
nullptr,
133 bool UnindentWhitesmithsBraces =
false);
134 void parseChildBlock();
135 void parsePPDirective();
136 void parsePPDefine();
137 void parsePPIf(
bool IfDef);
140 void parsePPPragma();
141 void parsePPUnknown();
142 void readTokenWithJavaScriptASI();
143 void parseStructuralElement(
const FormatToken *OpeningBrace =
nullptr,
144 IfStmtKind *IfKind =
nullptr,
146 bool *HasDoWhile =
nullptr,
147 bool *HasLabel =
nullptr);
148 bool tryToParseBracedList();
149 bool parseBracedList(
bool IsAngleBracket =
false,
bool IsEnum =
false);
150 bool parseParens(
TokenType StarAndAmpTokenType = TT_Unknown,
151 bool InMacroCall =
false);
153 void keepAncestorBraces();
154 void parseUnbracedBody(
bool CheckEOF =
false);
155 void handleAttributes();
156 bool handleCppAttributes();
158 FormatToken *parseIfThenElse(IfStmtKind *IfKind,
bool KeepBraces =
false,
159 bool IsVerilogAssert =
false);
160 void parseTryCatch();
161 void parseLoopBody(
bool KeepBraces,
bool WrapRightBrace);
162 void parseForOrWhileLoop(
bool HasParens =
true);
164 void parseLabel(FormatStyle::IndentGotoLabelStyle IndentGotoLabels =
165 FormatStyle::IGLS_OuterIndent);
166 void parseCaseLabel();
167 void parseSwitch(
bool IsExpr);
168 void parseNamespace();
169 bool parseModuleDecl();
170 bool parseImportDecl();
172 void parseAccessSpecifier();
174 bool parseStructLike();
175 bool parseRequires(
bool SeenEqual);
176 void parseRequiresClause();
177 void parseRequiresExpression();
178 void parseConstraintExpression();
179 void parseCppExportBlock();
180 void parseNamespaceOrExportBlock(
unsigned AddLevels);
181 void parseJavaEnumBody();
185 void parseRecord(
bool ParseAsExpr =
false,
bool IsJavaRecord =
false);
186 void parseObjCLightweightGenerics();
187 void parseObjCMethod();
188 void parseObjCProtocolList();
189 void parseObjCUntilAtEnd();
190 void parseObjCInterfaceOrImplementation();
191 bool parseObjCProtocol();
192 void parseJavaScriptEs6ImportExport();
193 void parseStatementMacro();
194 void parseCSharpAttribute();
198 void parseCSharpGenericTypeConstraint();
199 bool tryToParseLambda();
200 bool tryToParseChildBlock();
201 bool tryToParseLambdaIntroducer();
202 bool tryToParsePropertyAccessor();
203 void tryToParseJSFunction();
204 bool tryToParseSimpleAttribute();
205 void parseVerilogHierarchyIdentifier();
206 void parseVerilogSensitivityList();
209 unsigned parseVerilogHierarchyHeader();
210 void parseVerilogTable();
211 void parseVerilogCaseLabel();
213 void parseVerilogExtern();
215 void skipVerilogQualifiers();
216 std::optional<llvm::SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
221 enum class LineLevel { Remove, Keep };
223 void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::Remove);
229 void nextToken(
int LevelDifference = 0);
230 void readToken(
int LevelDifference = 0);
246 void flushComments(
bool NewlineBeforeNext);
248 void calculateBraceTypes(
bool ExpectClassBody =
false);
255 void conditionalCompilationCondition(
bool Unreachable);
256 void conditionalCompilationStart(
bool Unreachable);
257 void conditionalCompilationAlternative();
258 void conditionalCompilationEnd();
269 size_t computePPHash()
const;
271 bool parsingPPDirective()
const {
return CurrentLines != &Lines; }
276 std::unique_ptr<UnwrappedLine> Line;
290 llvm::DenseMap<FormatToken *, SmallVector<UnwrappedLine, 8>> ExpandedLines;
294 llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>> Unexpanded;
298 bool InExpansion =
false;
303 std::optional<MacroCallReconstructor> Reconstruct;
332 llvm::BitVector DeclarationScopeStack;
334 const FormatStyle &Style;
339 llvm::Regex CommentPragmasRegex;
356 bool IsDecltypeAutoFunction =
false;
366 PPBranch(PPBranchKind Kind,
size_t Line) : Kind(Kind),
Line(Line) {}
393 std::stack<int> PPChainBranchIndex;
397 enum IncludeGuardState {
406 IncludeGuardState IncludeGuard;
409 getIncludeGuardState(FormatStyle::PPDirectiveIndentStyle Style)
const {
410 return Style == FormatStyle::PPDIS_None || Style == FormatStyle::PPDIS_Leave
422 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.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Encapsulates keywords that are context sensitive or for languages not properly supported by Clang's l...
Represents a complete lambda introducer.