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(FormatStyle::IndentGotoLabelStyle IndentGotoLabels =
163 FormatStyle::IGLS_OuterIndent);
164 void parseCaseLabel();
165 void parseSwitch(
bool IsExpr);
166 void parseNamespace();
167 bool parseModuleImport();
169 void parseAccessSpecifier();
171 bool parseStructLike();
172 bool parseRequires(
bool SeenEqual);
173 void parseRequiresClause();
174 void parseRequiresExpression();
175 void parseConstraintExpression();
176 void parseCppExportBlock();
177 void parseNamespaceOrExportBlock(
unsigned AddLevels);
178 void parseJavaEnumBody();
182 void parseRecord(
bool ParseAsExpr =
false,
bool IsJavaRecord =
false);
183 void parseObjCLightweightGenerics();
184 void parseObjCMethod();
185 void parseObjCProtocolList();
186 void parseObjCUntilAtEnd();
187 void parseObjCInterfaceOrImplementation();
188 bool parseObjCProtocol();
189 void parseJavaScriptEs6ImportExport();
190 void parseStatementMacro();
191 void parseCSharpAttribute();
195 void parseCSharpGenericTypeConstraint();
196 bool tryToParseLambda();
197 bool tryToParseChildBlock();
198 bool tryToParseLambdaIntroducer();
199 bool tryToParsePropertyAccessor();
200 void tryToParseJSFunction();
201 bool tryToParseSimpleAttribute();
202 void parseVerilogHierarchyIdentifier();
203 void parseVerilogSensitivityList();
206 unsigned parseVerilogHierarchyHeader();
207 void parseVerilogTable();
208 void parseVerilogCaseLabel();
210 void parseVerilogExtern();
211 std::optional<llvm::SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
216 enum class LineLevel { Remove, Keep };
218 void addUnwrappedLine(LineLevel AdjustLevel = LineLevel::Remove);
224 void nextToken(
int LevelDifference = 0);
225 void readToken(
int LevelDifference = 0);
241 void flushComments(
bool NewlineBeforeNext);
243 void calculateBraceTypes(
bool ExpectClassBody =
false);
250 void conditionalCompilationCondition(
bool Unreachable);
251 void conditionalCompilationStart(
bool Unreachable);
252 void conditionalCompilationAlternative();
253 void conditionalCompilationEnd();
264 size_t computePPHash()
const;
266 bool parsingPPDirective()
const {
return CurrentLines != &Lines; }
271 std::unique_ptr<UnwrappedLine> Line;
285 llvm::DenseMap<FormatToken *, SmallVector<UnwrappedLine, 8>> ExpandedLines;
289 llvm::DenseMap<FormatToken *, std::unique_ptr<UnwrappedLine>> Unexpanded;
293 bool InExpansion =
false;
298 std::optional<MacroCallReconstructor> Reconstruct;
327 llvm::BitVector DeclarationScopeStack;
329 const FormatStyle &Style;
334 llvm::Regex CommentPragmasRegex;
351 bool IsDecltypeAutoFunction =
false;
361 PPBranch(PPBranchKind Kind,
size_t Line) : Kind(Kind),
Line(Line) {}
388 std::stack<int> PPChainBranchIndex;
392 enum IncludeGuardState {
401 IncludeGuardState IncludeGuard;
404 getIncludeGuardState(FormatStyle::PPDirectiveIndentStyle Style)
const {
405 return Style == FormatStyle::PPDIS_None || Style == FormatStyle::PPDIS_Leave
417 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.