15#ifndef LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
16#define LLVM_CLANG_LIB_FORMAT_UNWRAPPEDLINEPARSER_H
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,
149 bool InMacroCall =
false);
151 void keepAncestorBraces();
152 void parseUnbracedBody(
bool CheckEOF =
false);
153 void handleAttributes();
154 bool handleCppAttributes();
156 FormatToken *parseIfThenElse(IfStmtKind *IfKind,
bool KeepBraces =
false,
157 bool IsVerilogAssert =
false);
158 void parseTryCatch();
159 void parseLoopBody(
bool KeepBraces,
bool WrapRightBrace);
160 void parseForOrWhileLoop(
bool HasParens =
true);
162 void parseLabel(
bool LeftAlignLabel =
false);
163 void parseCaseLabel();
164 void parseSwitch(
bool IsExpr);
165 void parseNamespace();
166 bool parseModuleImport();
168 void parseAccessSpecifier();
170 bool parseStructLike();
171 bool parseRequires(
bool SeenEqual);
172 void parseRequiresClause(
FormatToken *RequiresToken);
173 void parseRequiresExpression(
FormatToken *RequiresToken);
174 void parseConstraintExpression();
175 void parseCppExportBlock();
176 void parseNamespaceOrExportBlock(
unsigned AddLevels);
177 void parseJavaEnumBody();
181 void parseRecord(
bool ParseAsExpr =
false,
bool IsJavaRecord =
false);
182 void parseObjCLightweightGenerics();
183 void parseObjCMethod();
184 void parseObjCProtocolList();
185 void parseObjCUntilAtEnd();
186 void parseObjCInterfaceOrImplementation();
187 bool parseObjCProtocol();
188 void parseJavaScriptEs6ImportExport();
189 void parseStatementMacro();
190 void parseCSharpAttribute();
194 void parseCSharpGenericTypeConstraint();
195 bool tryToParseLambda();
196 bool tryToParseChildBlock();
197 bool tryToParseLambdaIntroducer();
198 bool tryToParsePropertyAccessor();
199 void tryToParseJSFunction();
200 bool tryToParseSimpleAttribute();
201 void parseVerilogHierarchyIdentifier();
202 void parseVerilogSensitivityList();
205 unsigned parseVerilogHierarchyHeader();
206 void parseVerilogTable();
207 void parseVerilogCaseLabel();
209 void parseVerilogExtern();
210 std::optional<llvm::SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
215 enum class LineLevel { Remove, Keep };
217 void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::Remove);
223 void nextToken(
int LevelDifference = 0);
224 void readToken(
int LevelDifference = 0);
240 void flushComments(
bool NewlineBeforeNext);
242 void calculateBraceTypes(
bool ExpectClassBody =
false);
249 void conditionalCompilationCondition(
bool Unreachable);
250 void conditionalCompilationStart(
bool Unreachable);
251 void conditionalCompilationAlternative();
252 void conditionalCompilationEnd();
263 size_t computePPHash()
const;
265 bool parsingPPDirective()
const {
return CurrentLines != &Lines; }
270 std::unique_ptr<UnwrappedLine> Line;
284 llvm::DenseMap<FormatToken *, SmallVector<UnwrappedLine, 8>> ExpandedLines;
288 llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>> Unexpanded;
292 bool InExpansion =
false;
297 std::optional<MacroCallReconstructor> Reconstruct;
326 llvm::BitVector DeclarationScopeStack;
328 const FormatStyle &Style;
333 llvm::Regex CommentPragmasRegex;
350 bool IsDecltypeAutoFunction =
false;
360 PPBranch(PPBranchKind Kind,
size_t Line) : Kind(Kind),
Line(Line) {}
387 std::stack<int> PPChainBranchIndex;
391 enum IncludeGuardState {
400 IncludeGuardState IncludeGuard;
403 getIncludeGuardState(FormatStyle::PPDirectiveIndentStyle Style)
const {
404 return Style == FormatStyle::PPDIS_None || Style == FormatStyle::PPDIS_Leave
416 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.