#include "UnwrappedLineParser.h"
#include "FormatToken.h"
#include "FormatTokenLexer.h"
#include "FormatTokenSource.h"
#include "Macros.h"
#include "TokenAnnotator.h"
#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <utility>
#define DEBUG_TYPE …
namespace clang {
namespace format {
namespace {
void printLine(llvm::raw_ostream &OS, const UnwrappedLine &Line,
StringRef Prefix = "", bool PrintText = false) { … }
LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line) { … }
class ScopedDeclarationState { … };
}
std::ostream &operator<<(std::ostream &Stream, const UnwrappedLine &Line) { … }
class ScopedLineState { … };
class CompoundStatementIndenter { … };
UnwrappedLineParser::UnwrappedLineParser(
SourceManager &SourceMgr, const FormatStyle &Style,
const AdditionalKeywords &Keywords, unsigned FirstStartColumn,
ArrayRef<FormatToken *> Tokens, UnwrappedLineConsumer &Callback,
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
IdentifierTable &IdentTable)
: … { … }
void UnwrappedLineParser::reset() { … }
void UnwrappedLineParser::parse() { … }
void UnwrappedLineParser::parseFile() { … }
void UnwrappedLineParser::parseCSharpGenericTypeConstraint() { … }
void UnwrappedLineParser::parseCSharpAttribute() { … }
bool UnwrappedLineParser::precededByCommentOrPPDirective() const { … }
bool UnwrappedLineParser::parseLevel(const FormatToken *OpeningBrace,
IfStmtKind *IfKind,
FormatToken **IfLeftBrace) { … }
void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { … }
void UnwrappedLineParser::setPreviousRBraceType(TokenType Type) { … }
template <class T>
static inline void hash_combine(std::size_t &seed, const T &v) { … }
size_t UnwrappedLineParser::computePPHash() const { … }
bool UnwrappedLineParser::mightFitOnOneLine(
UnwrappedLine &ParsedLine, const FormatToken *OpeningBrace) const { … }
FormatToken *UnwrappedLineParser::parseBlock(bool MustBeDeclaration,
unsigned AddLevels, bool MunchSemi,
bool KeepBraces,
IfStmtKind *IfKind,
bool UnindentWhitesmithsBraces) { … }
static bool isGoogScope(const UnwrappedLine &Line) { … }
static bool isIIFE(const UnwrappedLine &Line,
const AdditionalKeywords &Keywords) { … }
static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) { … }
void UnwrappedLineParser::parseChildBlock() { … }
void UnwrappedLineParser::parsePPDirective() { … }
void UnwrappedLineParser::conditionalCompilationCondition(bool Unreachable) { … }
void UnwrappedLineParser::conditionalCompilationStart(bool Unreachable) { … }
void UnwrappedLineParser::conditionalCompilationAlternative() { … }
void UnwrappedLineParser::conditionalCompilationEnd() { … }
void UnwrappedLineParser::parsePPIf(bool IfDef) { … }
void UnwrappedLineParser::parsePPElse() { … }
void UnwrappedLineParser::parsePPEndIf() { … }
void UnwrappedLineParser::parsePPDefine() { … }
void UnwrappedLineParser::parsePPPragma() { … }
void UnwrappedLineParser::parsePPUnknown() { … }
static bool tokenCanStartNewLine(const FormatToken &Tok) { … }
static bool mustBeJSIdent(const AdditionalKeywords &Keywords,
const FormatToken *FormatTok) { … }
static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
const FormatToken *FormatTok) { … }
static bool isJSDeclOrStmt(const AdditionalKeywords &Keywords,
const FormatToken *FormatTok) { … }
static bool isC78Type(const FormatToken &Tok) { … }
static bool isC78ParameterDecl(const FormatToken *Tok, const FormatToken *Next,
const FormatToken *FuncName) { … }
bool UnwrappedLineParser::parseModuleImport() { … }
void UnwrappedLineParser::readTokenWithJavaScriptASI() { … }
void UnwrappedLineParser::parseStructuralElement(
const FormatToken *OpeningBrace, IfStmtKind *IfKind,
FormatToken **IfLeftBrace, bool *HasDoWhile, bool *HasLabel) { … }
bool UnwrappedLineParser::tryToParsePropertyAccessor() { … }
bool UnwrappedLineParser::tryToParseLambda() { … }
bool UnwrappedLineParser::tryToParseLambdaIntroducer() { … }
void UnwrappedLineParser::tryToParseJSFunction() { … }
bool UnwrappedLineParser::tryToParseBracedList() { … }
bool UnwrappedLineParser::tryToParseChildBlock() { … }
bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) { … }
bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) { … }
void UnwrappedLineParser::parseSquare(bool LambdaIntroducer) { … }
void UnwrappedLineParser::keepAncestorBraces() { … }
static FormatToken *getLastNonComment(const UnwrappedLine &Line) { … }
void UnwrappedLineParser::parseUnbracedBody(bool CheckEOF) { … }
static void markOptionalBraces(FormatToken *LeftBrace) { … }
void UnwrappedLineParser::handleAttributes() { … }
bool UnwrappedLineParser::handleCppAttributes() { … }
bool UnwrappedLineParser::isBlockBegin(const FormatToken &Tok) const { … }
FormatToken *UnwrappedLineParser::parseIfThenElse(IfStmtKind *IfKind,
bool KeepBraces,
bool IsVerilogAssert) { … }
void UnwrappedLineParser::parseTryCatch() { … }
void UnwrappedLineParser::parseNamespace() { … }
void UnwrappedLineParser::parseNew() { … }
void UnwrappedLineParser::parseLoopBody(bool KeepBraces, bool WrapRightBrace) { … }
void UnwrappedLineParser::parseForOrWhileLoop(bool HasParens) { … }
void UnwrappedLineParser::parseDoWhile() { … }
void UnwrappedLineParser::parseLabel(bool LeftAlignLabel) { … }
void UnwrappedLineParser::parseCaseLabel() { … }
void UnwrappedLineParser::parseSwitch(bool IsExpr) { … }
static bool isCOperatorFollowingVar(tok::TokenKind Kind) { … }
void UnwrappedLineParser::parseAccessSpecifier() { … }
bool UnwrappedLineParser::parseRequires() { … }
void UnwrappedLineParser::parseRequiresClause(FormatToken *RequiresToken) { … }
void UnwrappedLineParser::parseRequiresExpression(FormatToken *RequiresToken) { … }
void UnwrappedLineParser::parseConstraintExpression() { … }
bool UnwrappedLineParser::parseEnum() { … }
bool UnwrappedLineParser::parseStructLike() { … }
namespace {
class ScopedTokenPosition { … };
}
bool UnwrappedLineParser::tryToParseSimpleAttribute() { … }
void UnwrappedLineParser::parseJavaEnumBody() { … }
void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { … }
void UnwrappedLineParser::parseObjCMethod() { … }
void UnwrappedLineParser::parseObjCProtocolList() { … }
void UnwrappedLineParser::parseObjCUntilAtEnd() { … }
void UnwrappedLineParser::parseObjCInterfaceOrImplementation() { … }
void UnwrappedLineParser::parseObjCLightweightGenerics() { … }
bool UnwrappedLineParser::parseObjCProtocol() { … }
void UnwrappedLineParser::parseJavaScriptEs6ImportExport() { … }
void UnwrappedLineParser::parseStatementMacro() { … }
void UnwrappedLineParser::parseVerilogHierarchyIdentifier() { … }
void UnwrappedLineParser::parseVerilogSensitivityList() { … }
unsigned UnwrappedLineParser::parseVerilogHierarchyHeader() { … }
void UnwrappedLineParser::parseVerilogTable() { … }
void UnwrappedLineParser::parseVerilogCaseLabel() { … }
bool UnwrappedLineParser::containsExpansion(const UnwrappedLine &Line) const { … }
void UnwrappedLineParser::addUnwrappedLine(LineLevel AdjustLevel) { … }
bool UnwrappedLineParser::eof() const { … }
bool UnwrappedLineParser::isOnNewLine(const FormatToken &FormatTok) { … }
static bool
continuesLineCommentSection(const FormatToken &FormatTok,
const UnwrappedLine &Line,
const llvm::Regex &CommentPragmasRegex) { … }
void UnwrappedLineParser::flushComments(bool NewlineBeforeNext) { … }
void UnwrappedLineParser::nextToken(int LevelDifference) { … }
void UnwrappedLineParser::distributeComments(
const SmallVectorImpl<FormatToken *> &Comments,
const FormatToken *NextTok) { … }
void UnwrappedLineParser::readToken(int LevelDifference) { … }
namespace {
template <typename Iterator>
void pushTokens(Iterator Begin, Iterator End,
llvm::SmallVectorImpl<FormatToken *> &Into) { … }
}
std::optional<llvm::SmallVector<llvm::SmallVector<FormatToken *, 8>, 1>>
UnwrappedLineParser::parseMacroCall() { … }
void UnwrappedLineParser::pushToken(FormatToken *Tok) { … }
}
}