15#ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
16#define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
110 llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
116 enum class IfStmtKind {
125 bool precededByCommentOrPPDirective()
const;
126 bool parseLevel(
const FormatToken *OpeningBrace =
nullptr,
127 IfStmtKind *IfKind =
nullptr,
131 FormatToken *parseBlock(
bool MustBeDeclaration =
false,
132 unsigned AddLevels = 1u,
bool MunchSemi =
true,
133 bool KeepBraces =
true, IfStmtKind *IfKind =
nullptr,
134 bool UnindentWhitesmithsBraces =
false);
135 void parseChildBlock();
136 void parsePPDirective();
137 void parsePPDefine();
138 void parsePPIf(
bool IfDef);
141 void parsePPPragma();
142 void parsePPUnknown();
143 void readTokenWithJavaScriptASI();
144 void parseStructuralElement(
const FormatToken *OpeningBrace =
nullptr,
145 IfStmtKind *IfKind =
nullptr,
147 bool *HasDoWhile =
nullptr,
148 bool *HasLabel =
nullptr);
149 bool tryToParseBracedList();
150 bool parseBracedList(
bool IsAngleBracket =
false,
bool IsEnum =
false);
151 bool parseParens(
TokenType StarAndAmpTokenType = TT_Unknown,
152 bool InMacroCall =
false);
154 void keepAncestorBraces();
155 void parseUnbracedBody(
bool CheckEOF =
false);
156 void handleAttributes();
157 bool handleCppAttributes();
159 FormatToken *parseIfThenElse(IfStmtKind *IfKind,
bool KeepBraces =
false,
160 bool IsVerilogAssert =
false);
161 void parseTryCatch();
162 void parseLoopBody(
bool KeepBraces,
bool WrapRightBrace);
163 void parseForOrWhileLoop(
bool HasParens =
true);
165 void parseLabel(
bool IsGotoLabel =
false);
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.