clang
7.0.0
|
Namespaces | |
encoding | |
internal | |
Classes | |
struct | AdditionalKeywords |
Encapsulates keywords that are context sensitive or for languages not properly supported by Clang's lexer. More... | |
class | AffectedRangeManager |
class | AnnotatedLine |
class | BreakableBlockComment |
class | BreakableComment |
class | BreakableLineCommentSection |
class | BreakableStringLiteral |
class | CommaSeparatedList |
class | CompoundStatementIndenter |
class | ContinuationIndenter |
class | Environment |
struct | FormatStyle |
The FormatStyle is used to configure the formatting to follow specific guidelines. More... | |
struct | FormattingAttemptStatus |
Represents the status of a formatting attempt. More... | |
struct | FormatToken |
A wrapper around a Token storing information about the whitespace characters preceding it. More... | |
class | FormatTokenLexer |
class | FormatTokenSource |
class | JavaScriptImportSorter |
struct | JsImportedSymbol |
struct | JsModuleReference |
struct | LineState |
The current state when indenting a unwrapped line. More... | |
class | NamespaceEndCommentsFixer |
struct | ParenState |
class | ParseErrorCategory |
struct | RawStringFormatStyleManager |
class | ScopedLineState |
class | TokenAnalyzer |
class | TokenAnnotator |
Determines extra information about the tokens comprising an UnwrappedLine . More... | |
class | TokenRole |
struct | UnwrappedLine |
An unwrapped line is a sequence of Token , that we would like to put on a single line if there was no column limit. More... | |
class | UnwrappedLineConsumer |
class | UnwrappedLineFormatter |
struct | UnwrappedLineNode |
class | UnwrappedLineParser |
class | UsingDeclarationsSorter |
class | WhitespaceManager |
Manages the whitespaces around tokens and their replacements. More... | |
Enumerations | |
enum | ParseError { ParseError::Success = 0, ParseError::Error, ParseError::Unsuitable } |
enum | TokenType { NUM_TOKEN_TYPES } |
enum | BraceBlockKind { BK_Unknown, BK_Block, BK_BracedInit } |
enum | ParameterPackingKind { PPK_BinPacked, PPK_OnePerLine, PPK_Inconclusive } |
enum | FormatDecision { FD_Unformatted, FD_Continue, FD_Break } |
enum | LexerState { NORMAL, TEMPLATE_STRING, TOKEN_STASHED } |
enum | LineType { LT_Invalid, LT_ImportStatement, LT_ObjCDecl, LT_ObjCMethodDecl, LT_ObjCProperty, LT_Other, LT_PreprocessorDirective, LT_VirtualFunctionDecl } |
Functions | |
const std::error_category & | getParseCategory () |
std::error_code | make_error_code (ParseError e) |
FormatStyle | getLLVMStyle () |
Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards.html. More... | |
FormatStyle | getGoogleStyle (FormatStyle::LanguageKind Language) |
Returns a format style complying with one of Google's style guides: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml. More... | |
FormatStyle | getChromiumStyle (FormatStyle::LanguageKind Language) |
Returns a format style complying with Chromium's style guide: http://www.chromium.org/developers/coding-style. More... | |
FormatStyle | getMozillaStyle () |
Returns a format style complying with Mozilla's style guide: https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style. More... | |
FormatStyle | getWebKitStyle () |
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style.html. More... | |
FormatStyle | getGNUStyle () |
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standards.html. More... | |
FormatStyle | getNoStyle () |
Returns style indicating formatting should be not applied at all. More... | |
bool | getPredefinedStyle (StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style) |
Gets a predefined style for the specified language by name. More... | |
std::error_code | parseConfiguration (StringRef Text, FormatStyle *Style) |
Parse configuration from YAML-formatted text. More... | |
std::string | configurationAsText (const FormatStyle &Style) |
Gets configuration in a YAML string. More... | |
tooling::Replacements | sortIncludes (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, unsigned *Cursor=nullptr) |
Returns the replacements necessary to sort all #include blocks that are affected by Ranges . More... | |
llvm::Expected< tooling::Replacements > | formatReplacements (StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
Returns the replacements corresponding to applying and formatting Replaces on success; otheriwse, return an llvm::Error carrying llvm::StringError. More... | |
llvm::Expected< tooling::Replacements > | cleanupAroundReplacements (StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
Returns the replacements corresponding to applying Replaces and cleaning up the code after that on success; otherwise, return an llvm::Error carrying llvm::StringError. More... | |
tooling::Replacements | reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>", FormattingAttemptStatus *Status=nullptr) |
Reformats the given Ranges in Code . More... | |
tooling::Replacements | reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, bool *IncompleteFormat) |
Same as above, except if IncompleteFormat is non-null, its value will be set to true if any of the affected ranges were not formatted due to a non-recoverable syntax error. More... | |
tooling::Replacements | cleanup (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Clean up any erroneous/redundant code in the given Ranges in Code . More... | |
tooling::Replacements | fixNamespaceEndComments (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Fix namespace end comments in the given Ranges in Code . More... | |
tooling::Replacements | sortUsingDeclarations (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Sort consecutive using declarations in the given Ranges in Code . More... | |
LangOptions | getFormattingLangOpts (const FormatStyle &Style=getLLVMStyle()) |
Returns the LangOpts that the formatter expects you to set. More... | |
llvm::Expected< FormatStyle > | getStyle (StringRef StyleName, StringRef FileName, StringRef FallbackStyle, StringRef Code="", vfs::FileSystem *FS=nullptr) |
Construct a FormatStyle based on StyleName . More... | |
FormatStyle::LanguageKind | guessLanguage (StringRef FileName, StringRef Code) |
StringRef | getLanguageName (FormatStyle::LanguageKind Language) |
static bool | IsBlank (char C) |
static StringRef | getLineCommentIndentPrefix (StringRef Comment, const FormatStyle &Style) |
static BreakableToken::Split | getCommentSplit (StringRef Text, unsigned ContentStartColumn, unsigned ColumnLimit, unsigned TabWidth, encoding::Encoding Encoding) |
static BreakableToken::Split | getStringSplit (StringRef Text, unsigned UsedColumns, unsigned ColumnLimit, unsigned TabWidth, encoding::Encoding Encoding) |
bool | switchesFormatting (const FormatToken &Token) |
Checks if Token switches formatting, like /* clang-format off. More... | |
static bool | mayReflowContent (StringRef Content) |
virtual | ~BreakableToken () |
virtual unsigned | getLineCount () const =0 |
Returns the number of lines in this token in the original code. More... | |
virtual unsigned | getRangeLength (unsigned LineIndex, unsigned Offset, StringRef::size_type Length, unsigned StartColumn) const =0 |
Returns the number of columns required to format the text in the byte range [Offset , Offset + Length ). More... | |
virtual unsigned | getRemainingLength (unsigned LineIndex, unsigned Offset, unsigned StartColumn) const |
Returns the number of columns required to format the text following the byte Offset in the line LineIndex , including potentially unbreakable sequences of tokens following after the end of the token. More... | |
virtual unsigned | getContentStartColumn (unsigned LineIndex, bool Break) const =0 |
Returns the column at which content in line LineIndex starts, assuming no reflow. More... | |
virtual unsigned | getContentIndent (unsigned LineIndex) const |
Returns additional content indent required for the second line after the content at line LineIndex is broken. More... | |
virtual Split | getSplit (unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit, unsigned ContentStartColumn, llvm::Regex &CommentPragmasRegex) const =0 |
Returns a range (offset, length) at which to break the line at LineIndex , if previously broken at TailOffset . More... | |
virtual void | insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, unsigned ContentIndent, WhitespaceManager &Whitespaces) const =0 |
Emits the previously retrieved Split via Whitespaces . More... | |
unsigned | getLengthAfterCompression (unsigned RemainingTokenColumns, Split Split) const |
Returns the number of columns needed to format RemainingTokenColumns , assuming that Split is within the range measured by RemainingTokenColumns , and that the whitespace in Split is reduced to a single space. More... | |
virtual void | compressWhitespace (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces) const =0 |
Replaces the whitespace range described by Split with a single space. More... | |
virtual bool | supportsReflow () const |
Returns whether the token supports reflowing text. More... | |
virtual Split | getReflowSplit (unsigned LineIndex, llvm::Regex &CommentPragmasRegex) const |
Returns a whitespace range (offset, length) of the content at LineIndex such that the content of that line is reflown to the end of the previous one. More... | |
virtual void | reflow (unsigned LineIndex, WhitespaceManager &Whitespaces) const |
Reflows the current line into the end of the previous one. More... | |
virtual bool | introducesBreakBeforeToken () const |
Returns whether there will be a line break at the start of the token. More... | |
virtual void | adaptStartOfLine (unsigned LineIndex, WhitespaceManager &Whitespaces) const |
Replaces the whitespace between LineIndex-1 and LineIndex . More... | |
virtual Split | getSplitAfterLastLine (unsigned TailOffset) const |
Returns a whitespace range (offset, length) of the content at the last line that needs to be reformatted after the last line has been reformatted. More... | |
void | replaceWhitespaceAfterLastLine (unsigned TailOffset, Split SplitAfterLastLine, WhitespaceManager &Whitespaces) const |
Replaces the whitespace from SplitAfterLastLine on the last line after the last line has been formatted by performing a reformatting. More... | |
virtual void | updateNextToken (LineState &State) const |
Updates the next token of State to the next token after this one. More... | |
BreakableToken (const FormatToken &Tok, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) | |
static bool | shouldIndentWrappedSelectorName (const FormatStyle &Style, LineType LineType) |
static unsigned | getLengthToMatchingParen (const FormatToken &Tok, const std::vector< ParenState > &Stack) |
static unsigned | getLengthToNextOperator (const FormatToken &Tok) |
static bool | startsSegmentOfBuilderTypeCall (const FormatToken &Tok) |
static bool | startsNextParameter (const FormatToken &Current, const FormatStyle &Style) |
static bool | opensProtoMessageField (const FormatToken &LessTok, const FormatStyle &Style) |
static llvm::Optional< StringRef > | getRawStringDelimiter (StringRef TokenText) |
static StringRef | getCanonicalRawStringDelimiter (const FormatStyle &Style, FormatStyle::LanguageKind Language) |
static unsigned | getLastLineEndColumn (StringRef Text, unsigned StartColumn, unsigned TabWidth, encoding::Encoding Encoding) |
static StringRef | getEnclosingFunctionName (const FormatToken &Current) |
llvm::Error | make_string_error (const llvm::Twine &Message) |
static FormatStyle | expandPresets (const FormatStyle &Style) |
static bool | affectsRange (ArrayRef< tooling::Range > Ranges, unsigned Start, unsigned End) |
static std::pair< unsigned, unsigned > | FindCursorIndex (const SmallVectorImpl< IncludeDirective > &Includes, const SmallVectorImpl< unsigned > &Indices, unsigned Cursor) |
static void | sortCppIncludes (const FormatStyle &Style, const SmallVectorImpl< IncludeDirective > &Includes, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) |
tooling::Replacements | sortCppIncludes (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) |
bool | isMpegTS (StringRef Code) |
bool | isLikelyXml (StringRef Code) |
template<typename T > | |
static llvm::Expected< tooling::Replacements > | processReplacements (T ProcessFunc, StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
static FormatStyle::LanguageKind | getLanguageByFileName (StringRef FileName) |
const char * | getTokenTypeName (TokenType Type) |
Determines the name of a token type. More... | |
static unsigned | CodePointsBetween (const FormatToken *Begin, const FormatToken *End) |
const FormatToken * | getNamespaceToken (const AnnotatedLine *Line, const SmallVectorImpl< AnnotatedLine *> &AnnotatedLines) |
bool | operator< (const JsModuleReference &LHS, const JsModuleReference &RHS) |
tooling::Replacements | sortJavaScriptImports (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName) |
static unsigned | maxNestingDepth (const AnnotatedLine &Line) |
static bool | isFunctionDeclarationName (const FormatToken &Current, const AnnotatedLine &Line) |
static bool | isAllmanBrace (const FormatToken &Tok) |
template<class T > | |
static void | hash_combine (std::size_t &seed, const T &v) |
static bool | isGoogScope (const UnwrappedLine &Line) |
static bool | isIIFE (const UnwrappedLine &Line, const AdditionalKeywords &Keywords) |
static bool | ShouldBreakBeforeBrace (const FormatStyle &Style, const FormatToken &InitialToken) |
static bool | tokenCanStartNewLine (const clang::Token &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 LLVM_ATTRIBUTE_UNUSED void | printDebugInfo (const UnwrappedLine &Line, StringRef Prefix="") |
static bool | continuesLineCommentSection (const FormatToken &FormatTok, const UnwrappedLine &Line, llvm::Regex &CommentPragmasRegex) |
template<typename F > | |
static void | AlignTokenSequence (unsigned Start, unsigned End, unsigned Column, F &&Matches, SmallVector< WhitespaceManager::Change, 16 > &Changes) |
template<typename F > | |
static unsigned | AlignTokens (const FormatStyle &Style, F &&Matches, SmallVector< WhitespaceManager::Change, 16 > &Changes, unsigned StartAt) |
Variables | |
const char * | StyleOptionHelpDescription |
Description to be used for help text for a llvm::cl option for specifying format style. More... | |
const char * | DefaultFormatStyle = "file" |
The suggested format style to use by default. More... | |
const char * | DefaultFallbackStyle = "LLVM" |
The suggested predefined style to use as the fallback style in getStyle . More... | |
static const char *const | Blanks = " \t\v\f\r" |
to be on a line of | itself |
Base class for tokens / ranges of tokens that can allow breaking within the tokens - for example, to avoid whitespace beyond the column limit, or to reflow text. More... | |
to be on a line of there are analogous operations *that might be executed after the last line has been | reformatted |
to be on a line of there are analogous operations *that might be executed after the last line has been for finding a split after the last line that needs *to be | reflown |
to be on a line of there are analogous operations *that might be executed after the last line has been for finding a split after the last line that needs *to be * | replaceWhitespaceAfterLastLine |
const FormatToken & | Tok |
const bool | InPPDirective |
const encoding::Encoding | Encoding |
const FormatStyle & | Style |
Enumerator | |
---|---|
BK_Unknown | |
BK_Block | |
BK_BracedInit |
Definition at line 111 of file FormatToken.h.
Enumerator | |
---|---|
FD_Unformatted | |
FD_Continue | |
FD_Break |
Definition at line 116 of file FormatToken.h.
Enumerator | |
---|---|
NORMAL | |
TEMPLATE_STRING | |
TOKEN_STASHED |
Definition at line 31 of file FormatTokenLexer.h.
Enumerator | |
---|---|
LT_Invalid | |
LT_ImportStatement | |
LT_ObjCDecl | |
LT_ObjCMethodDecl | |
LT_ObjCProperty | |
LT_Other | |
LT_PreprocessorDirective | |
LT_VirtualFunctionDecl |
Definition at line 27 of file TokenAnnotator.h.
Enumerator | |
---|---|
PPK_BinPacked | |
PPK_OnePerLine | |
PPK_Inconclusive |
Definition at line 114 of file FormatToken.h.
|
strong |
Enumerator | |
---|---|
NUM_TOKEN_TYPES |
Definition at line 100 of file FormatToken.h.
|
virtual |
Replaces the whitespace between LineIndex-1
and LineIndex
.
Definition at line 211 of file BreakableToken.h.
|
static |
Definition at line 1614 of file Format.cpp.
Referenced by sortCppIncludes().
|
static |
Definition at line 323 of file WhitespaceManager.cpp.
|
static |
Definition at line 234 of file WhitespaceManager.cpp.
|
protected |
Definition at line 239 of file BreakableToken.h.
tooling::Replacements clang::format::cleanup | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName = "<stdin>" |
||
) |
Clean up any erroneous/redundant code in the given Ranges
in Code
.
Returns the Replacements
that clean up all Ranges
in Code
.
Definition at line 2050 of file Format.cpp.
References clang::format::FormatStyle::Language.
Referenced by cleanupAroundReplacements(), clang::CodeGen::EHScopeStack::containsOnlyLifetimeMarkers(), clang::CodeGen::CodeGenFunction::EmitAnyExprToExn(), clang::CodeGen::EHScopeStack::getInnermostActiveNormalCleanup(), clang::CodeGen::CodeGenFunction::initFullExprCleanupWithFlag(), isTrivialFiller(), IsUsedAsEHCleanup(), clang::CodeGen::EHScopeStack::requiresLandingPad(), and clang::CodeGen::CGBlockInfo::Capture::setCleanup().
llvm::Expected< tooling::Replacements > clang::format::cleanupAroundReplacements | ( | StringRef | Code, |
const tooling::Replacements & | Replaces, | ||
const FormatStyle & | Style | ||
) |
Returns the replacements corresponding to applying Replaces
and cleaning up the code after that on success; otherwise, return an llvm::Error carrying llvm::StringError.
This also supports inserting/deleting C++ #include directives:
Code
.Code
if it exists. The include manipulation is done via tooling::HeaderInclude
, see its documentation for more details on how include insertion points are found and what edits are produced. Definition at line 1956 of file Format.cpp.
References cleanup(), processReplacements(), and Style.
Referenced by clang::tooling::applyAtomicChanges(), and llvm::yaml::MappingTraits< clang::tooling::AtomicChange >::mapping().
|
static |
Definition at line 146 of file FormatToken.cpp.
References clang::format::FormatToken::ColumnWidth, and clang::format::FormatToken::TotalLength.
Referenced by clang::format::CommaSeparatedList::precomputeFormattingInfos().
|
pure virtual |
Replaces the whitespace range described by Split
with a single space.
Referenced by clang::format::BreakableComment::supportsReflow().
std::string clang::format::configurationAsText | ( | const FormatStyle & | Style | ) |
Gets configuration in a YAML string.
Definition at line 1011 of file Format.cpp.
References expandPresets(), and Text.
|
static |
Definition at line 2379 of file UnwrappedLineParser.cpp.
References clang::format::UnwrappedLine::Tokens, and clang::format::FormatToken::TokenText.
|
static |
Definition at line 567 of file Format.cpp.
References clang::format::FormatStyle::BraceWrappingFlags::AfterClass, clang::format::FormatStyle::BraceWrappingFlags::AfterControlStatement, clang::format::FormatStyle::BraceWrappingFlags::AfterEnum, clang::format::FormatStyle::BraceWrappingFlags::AfterExternBlock, clang::format::FormatStyle::BraceWrappingFlags::AfterFunction, clang::format::FormatStyle::BraceWrappingFlags::AfterNamespace, clang::format::FormatStyle::BraceWrappingFlags::AfterObjCDeclaration, clang::format::FormatStyle::BraceWrappingFlags::AfterStruct, clang::format::FormatStyle::BraceWrappingFlags::AfterUnion, clang::format::FormatStyle::BraceWrappingFlags::BeforeCatch, clang::format::FormatStyle::BraceWrappingFlags::BeforeElse, clang::format::FormatStyle::BraceWrapping, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BraceWrappingFlags::SplitEmptyFunction, clang::format::FormatStyle::BraceWrappingFlags::SplitEmptyRecord, and Style.
Referenced by configurationAsText().
|
static |
Definition at line 1632 of file Format.cpp.
References End, Text, and UINT_MAX.
Referenced by sortCppIncludes().
tooling::Replacements clang::format::fixNamespaceEndComments | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName = "<stdin>" |
||
) |
Fix namespace end comments in the given Ranges
in Code
.
Returns the Replacements
that fix the namespace comments in all Ranges
in Code
.
Definition at line 2069 of file Format.cpp.
References clang::format::TokenAnalyzer::process().
llvm::Expected< tooling::Replacements > clang::format::formatReplacements | ( | StringRef | Code, |
const tooling::Replacements & | Replaces, | ||
const FormatStyle & | Style | ||
) |
Returns the replacements corresponding to applying and formatting Replaces
on success; otheriwse, return an llvm::Error carrying llvm::StringError.
Definition at line 1847 of file Format.cpp.
References clang::tooling::Replacements::add(), clang::tooling::Replacements::empty(), clang::tooling::Replacement::getLength(), clang::tooling::Replacement::getOffset(), clang::tooling::Replacement::getReplacementText(), clang::format::FormatStyle::IncludeStyle, clang::format::FormatStyle::isCpp(), processReplacements(), clang::format::internal::reformat(), clang::tooling::HeaderIncludes::remove(), sortIncludes(), Style, clang::threadSafety::sx::toString(), and UINT_MAX.
Referenced by clang::tooling::formatAndApplyAllReplacements().
|
static |
Definition at line 175 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::RawStringFormats.
FormatStyle clang::format::getChromiumStyle | ( | FormatStyle::LanguageKind | Language | ) |
Returns a format style complying with Chromium's style guide: http://www.chromium.org/developers/coding-style.
Definition at line 840 of file Format.cpp.
References clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLine, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine, clang::format::FormatStyle::AllowShortLoopsOnASingleLine, clang::format::FormatStyle::BinPackParameters, clang::format::FormatStyle::BreakAfterJavaFieldAnnotations, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::ContinuationIndentWidth, clang::format::FormatStyle::DerivePointerAlignment, getGoogleStyle(), and clang::format::FormatStyle::IndentWidth.
|
static |
Definition at line 66 of file BreakableToken.cpp.
References clang::format::encoding::columnWidthWithTabs(), Encoding, and clang::format::encoding::getCodePointNumBytes().
Referenced by clang::format::BreakableComment::getSplit().
|
virtual |
Returns additional content indent required for the second line after the content at line LineIndex
is broken.
loooooooooooooong | line continuation |
Definition at line 150 of file BreakableToken.h.
References getSplit(), and insertBreak().
|
pure virtual |
Returns the column at which content in line LineIndex
starts, assuming no reflow.
If Break
is true, returns the column at which the line should start after the line break. If Break
is false, returns the column at which the line itself will start.
Referenced by clang::format::BreakableStringLiteral::compressWhitespace(), and getRemainingLength().
|
static |
Definition at line 1651 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::BreakStringLiterals, clang::format::ContinuationIndenter::canBreak(), clang::format::LineState::Column, clang::format::FormatStyle::ColumnLimit, clang::format::FormatToken::ColumnWidth, clang::format::ContinuationIndenter::getColumnLimit(), clang::format::RawStringFormatStyleManager::getDelimiterStyle(), clang::format::RawStringFormatStyleManager::getEnclosingFunctionStyle(), clang::format::FormatToken::getPreviousNonComment(), getRawStringDelimiter(), clang::format::AnnotatedLine::InPPDirective, clang::format::FormatToken::is(), clang::format::FormatToken::isStringLiteral(), clang::format::FormatToken::IsUnterminatedLiteral, clang::format::FormatStyle::Language, clang::format::LineState::Line, clang::format::FormatStyle::LK_Java, clang::format::FormatStyle::LK_JavaScript, LT_PreprocessorDirective, clang::format::FormatToken::MatchingParen, clang::format::LineState::NextToken, clang::format::FormatStyle::ReflowComments, clang::format::LineState::Stack, switchesFormatting(), Text, Tok, clang::format::FormatToken::TokenText, clang::format::AnnotatedLine::Type, and clang::format::FormatToken::UnbreakableTailLength.
LangOptions clang::format::getFormattingLangOpts | ( | const FormatStyle & | Style = getLLVMStyle() | ) |
Returns the LangOpts
that the formatter expects you to set.
Style | determines specific settings for lexing mode. |
Definition at line 2087 of file Format.cpp.
References clang::format::FormatStyle::isCpp(), and clang::format::FormatStyle::Standard.
Referenced by clang::format::FormatTokenLexer::FormatTokenLexer().
FormatStyle clang::format::getGNUStyle | ( | ) |
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standards.html.
Definition at line 910 of file Format.cpp.
References clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::FormatStyle::AlwaysBreakAfterReturnType, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::FixNamespaceComments, getLLVMStyle(), clang::format::FormatStyle::SpaceBeforeParens, clang::format::FormatStyle::Standard, and Style.
FormatStyle clang::format::getGoogleStyle | ( | FormatStyle::LanguageKind | Language | ) |
Returns a format style complying with one of Google's style guides: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml. https://developers.google.com/protocol-buffers/docs/style.
Definition at line 721 of file Format.cpp.
References clang::format::FormatStyle::AccessModifierOffset, clang::format::FormatStyle::AlignAfterOpenBracket, clang::format::FormatStyle::AlignEscapedNewlines, clang::format::FormatStyle::AlignOperands, clang::format::FormatStyle::AlignTrailingComments, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine, clang::format::FormatStyle::AllowShortLoopsOnASingleLine, clang::format::FormatStyle::AlwaysBreakBeforeMultilineStrings, clang::format::FormatStyle::AlwaysBreakTemplateDeclarations, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::BreakStringLiterals, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::CommentPragmas, clang::format::FormatStyle::ConstructorInitializerAllOnOneLineOrOnePerLine, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::DerivePointerAlignment, getLLVMStyle(), clang::tooling::IncludeStyle::IncludeCategories, clang::tooling::IncludeStyle::IncludeIsMainRegex, clang::format::FormatStyle::IncludeStyle, clang::format::FormatStyle::IndentCaseLabels, clang::format::FormatStyle::JavaScriptQuotes, clang::format::FormatStyle::JavaScriptWrapImports, clang::format::FormatStyle::KeepEmptyLinesAtTheStartOfBlocks, clang::format::FormatStyle::Language, clang::format::FormatStyle::MaxEmptyLinesToKeep, clang::format::FormatStyle::NamespaceIndentation, clang::format::FormatStyle::ObjCBinPackProtocolList, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::ObjCSpaceBeforeProtocolList, clang::format::FormatStyle::PenaltyBreakBeforeFirstCallParameter, clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::RawStringFormats, clang::format::FormatStyle::SpaceAfterCStyleCast, clang::format::FormatStyle::SpacesBeforeTrailingComments, clang::format::FormatStyle::SpacesInContainerLiterals, and clang::format::FormatStyle::Standard.
Referenced by getChromiumStyle().
|
static |
Definition at line 2116 of file Format.cpp.
Referenced by guessLanguage().
|
inline |
Definition at line 2009 of file Format.h.
Referenced by clang::format::TokenAnalyzer::TokenAnalyzer().
|
static |
Definition at line 1448 of file ContinuationIndenter.cpp.
References clang::format::encoding::columnWidthWithTabs().
unsigned clang::format::BreakableToken::getLengthAfterCompression | ( | unsigned | RemainingTokenColumns, |
Split | Split | ||
) | const |
Returns the number of columns needed to format RemainingTokenColumns
, assuming that Split is within the range measured by RemainingTokenColumns
, and that the whitespace in Split is reduced to a single space.
Definition at line 178 of file BreakableToken.cpp.
|
static |
Definition at line 38 of file ContinuationIndenter.cpp.
|
static |
Definition at line 108 of file ContinuationIndenter.cpp.
References clang::format::FormatToken::NextOperator, and clang::format::FormatToken::TotalLength.
|
static |
Definition at line 43 of file BreakableToken.cpp.
References clang::format::FormatStyle::Language, and clang::format::FormatStyle::LK_TextProto.
Referenced by clang::format::BreakableLineCommentSection::BreakableLineCommentSection().
|
pure virtual |
Returns the number of lines in this token in the original code.
Referenced by clang::format::BreakableStringLiteral::compressWhitespace(), replaceWhitespaceAfterLastLine(), clang::format::BreakableComment::supportsReflow(), and ~BreakableToken().
FormatStyle clang::format::getLLVMStyle | ( | ) |
Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards.html.
Definition at line 620 of file Format.cpp.
References clang::format::FormatStyle::AccessModifierOffset, clang::format::FormatStyle::AlignAfterOpenBracket, clang::format::FormatStyle::AlignConsecutiveAssignments, clang::format::FormatStyle::AlignConsecutiveDeclarations, clang::format::FormatStyle::AlignEscapedNewlines, clang::format::FormatStyle::AlignOperands, clang::format::FormatStyle::AlignTrailingComments, clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLine, clang::format::FormatStyle::AllowShortBlocksOnASingleLine, clang::format::FormatStyle::AllowShortCaseLabelsOnASingleLine, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine, clang::format::FormatStyle::AllowShortLoopsOnASingleLine, clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::FormatStyle::AlwaysBreakAfterReturnType, clang::format::FormatStyle::AlwaysBreakBeforeMultilineStrings, clang::format::FormatStyle::AlwaysBreakTemplateDeclarations, clang::prec::Assignment, clang::format::FormatStyle::BinPackArguments, clang::format::FormatStyle::BinPackParameters, clang::format::FormatStyle::BraceWrapping, clang::format::FormatStyle::BreakAfterJavaFieldAnnotations, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::BreakConstructorInitializers, clang::format::FormatStyle::BreakInheritanceList, clang::format::FormatStyle::BreakStringLiterals, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::CommentPragmas, clang::format::FormatStyle::CompactNamespaces, clang::format::FormatStyle::ConstructorInitializerAllOnOneLineOrOnePerLine, clang::format::FormatStyle::ConstructorInitializerIndentWidth, clang::format::FormatStyle::ContinuationIndentWidth, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::DerivePointerAlignment, clang::format::FormatStyle::DisableFormat, clang::format::FormatStyle::ExperimentalAutoDetectBinPacking, clang::format::FormatStyle::FixNamespaceComments, clang::format::FormatStyle::ForEachMacros, clang::tooling::IncludeStyle::IncludeBlocks, clang::tooling::IncludeStyle::IncludeCategories, clang::tooling::IncludeStyle::IncludeIsMainRegex, clang::format::FormatStyle::IncludeStyle, clang::format::FormatStyle::IndentCaseLabels, clang::format::FormatStyle::IndentPPDirectives, clang::format::FormatStyle::IndentWidth, clang::format::FormatStyle::IndentWrappedFunctionNames, clang::format::FormatStyle::JavaScriptQuotes, clang::format::FormatStyle::JavaScriptWrapImports, clang::format::FormatStyle::KeepEmptyLinesAtTheStartOfBlocks, clang::format::FormatStyle::Language, clang::format::FormatStyle::MaxEmptyLinesToKeep, clang::format::FormatStyle::NamespaceIndentation, clang::format::FormatStyle::ObjCBinPackProtocolList, clang::format::FormatStyle::ObjCBlockIndentWidth, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::ObjCSpaceBeforeProtocolList, clang::format::FormatStyle::PenaltyBreakAssignment, clang::format::FormatStyle::PenaltyBreakBeforeFirstCallParameter, clang::format::FormatStyle::PenaltyBreakComment, clang::format::FormatStyle::PenaltyBreakFirstLessLess, clang::format::FormatStyle::PenaltyBreakString, clang::format::FormatStyle::PenaltyBreakTemplateDeclaration, clang::format::FormatStyle::PenaltyExcessCharacter, clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::ReflowComments, clang::prec::Relational, clang::format::FormatStyle::SortIncludes, clang::format::FormatStyle::SortUsingDeclarations, clang::format::FormatStyle::SpaceAfterCStyleCast, clang::format::FormatStyle::SpaceAfterTemplateKeyword, clang::format::FormatStyle::SpaceBeforeAssignmentOperators, clang::format::FormatStyle::SpaceBeforeCpp11BracedList, clang::format::FormatStyle::SpaceBeforeCtorInitializerColon, clang::format::FormatStyle::SpaceBeforeInheritanceColon, clang::format::FormatStyle::SpaceBeforeParens, clang::format::FormatStyle::SpaceBeforeRangeBasedForLoopColon, clang::format::FormatStyle::SpaceInEmptyParentheses, clang::format::FormatStyle::SpacesBeforeTrailingComments, clang::format::FormatStyle::SpacesInAngles, clang::format::FormatStyle::SpacesInContainerLiterals, clang::format::FormatStyle::SpacesInCStyleCastParentheses, clang::format::FormatStyle::SpacesInParentheses, clang::format::FormatStyle::SpacesInSquareBrackets, clang::format::FormatStyle::Standard, clang::format::FormatStyle::TabWidth, and clang::format::FormatStyle::UseTab.
Referenced by getGNUStyle(), getGoogleStyle(), getMozillaStyle(), getNoStyle(), getStyle(), getWebKitStyle(), guessLanguage(), and clang::format::RawStringFormatStyleManager::RawStringFormatStyleManager().
FormatStyle clang::format::getMozillaStyle | ( | ) |
Returns a format style complying with Mozilla's style guide: https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style.
Definition at line 863 of file Format.cpp.
References clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLine, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::FormatStyle::AlwaysBreakAfterReturnType, clang::format::FormatStyle::AlwaysBreakTemplateDeclarations, clang::format::FormatStyle::BinPackArguments, clang::format::FormatStyle::BinPackParameters, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakConstructorInitializers, clang::format::FormatStyle::BreakInheritanceList, clang::format::FormatStyle::ConstructorInitializerIndentWidth, clang::format::FormatStyle::ContinuationIndentWidth, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::FixNamespaceComments, getLLVMStyle(), clang::format::FormatStyle::IndentCaseLabels, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::ObjCSpaceBeforeProtocolList, clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine, clang::format::FormatStyle::PointerAlignment, and clang::format::FormatStyle::SpaceAfterTemplateKeyword.
const FormatToken * clang::format::getNamespaceToken | ( | const AnnotatedLine * | Line, |
const SmallVectorImpl< AnnotatedLine *> & | AnnotatedLines | ||
) |
Definition at line 113 of file NamespaceEndCommentsFixer.cpp.
FormatStyle clang::format::getNoStyle | ( | ) |
Returns style indicating formatting should be not applied at all.
Definition at line 925 of file Format.cpp.
References clang::format::FormatStyle::DisableFormat, getLLVMStyle(), clang::format::FormatStyle::SortIncludes, and clang::format::FormatStyle::SortUsingDeclarations.
Referenced by getStyle().
const std::error_category & clang::format::getParseCategory | ( | ) |
Definition at line 538 of file Format.cpp.
Referenced by make_error_code().
bool clang::format::getPredefinedStyle | ( | StringRef | Name, |
FormatStyle::LanguageKind | Language, | ||
FormatStyle * | Style | ||
) |
Gets a predefined style for the specified language by name.
Currently supported names: LLVM, Google, Chromium, Mozilla. Names are compared case-insensitively.
Returns true
if the Style has been set.
Definition at line 933 of file Format.cpp.
Referenced by getStyle(), llvm::yaml::MappingTraits< FormatStyle >::mapping(), and clang::format::RawStringFormatStyleManager::RawStringFormatStyleManager().
|
pure virtual |
Returns the number of columns required to format the text in the byte range [Offset
, Offset
+
Length
).
Offset
is the byte offset from the start of the content of the line at LineIndex
.
StartColumn
is the column at which the text starts in the formatted file, needed to compute tab stops correctly.
Referenced by clang::format::BreakableStringLiteral::compressWhitespace(), getRemainingLength(), and ~BreakableToken().
|
static |
Definition at line 150 of file ContinuationIndenter.cpp.
Referenced by getEnclosingFunctionName().
|
virtual |
Returns a whitespace range (offset, length) of the content at LineIndex
such that the content of that line is reflown to the end of the previous one.
Returning (StringRef::npos, 0) indicates reflowing is not possible.
The range will include any whitespace preceding the specified line's content.
If the split is not contained within one token, for example when reflowing line comments, returns (0, <length>).
Definition at line 195 of file BreakableToken.h.
|
virtual |
Returns the number of columns required to format the text following the byte Offset
in the line LineIndex
, including potentially unbreakable sequences of tokens following after the end of the token.
Offset
is the byte offset from the start of the content of the line at LineIndex
.
StartColumn
is the column at which the text starts in the formatted file, needed to compute tab stops correctly.
For breakable tokens that never use extra space at the end of a line, this is equivalent to getRangeLength with a Length of StringRef::npos.
Definition at line 124 of file BreakableToken.h.
References getContentStartColumn(), and getRangeLength().
Referenced by clang::format::BreakableStringLiteral::compressWhitespace().
|
pure virtual |
Returns a range (offset, length) at which to break the line at LineIndex
, if previously broken at TailOffset
.
If possible, do not violate ColumnLimit
, assuming the text starting at TailOffset
in the token is formatted starting at ContentStartColumn in the reformatted file.
Referenced by getContentIndent(), and clang::format::BreakableComment::supportsReflow().
|
virtual |
Returns a whitespace range (offset, length) of the content at the last line that needs to be reformatted after the last line has been reformatted.
A result having offset == StringRef::npos means that no reformat is necessary.
Definition at line 220 of file BreakableToken.h.
|
static |
Definition at line 121 of file BreakableToken.cpp.
References clang::format::encoding::columnWidthWithTabs(), Encoding, clang::format::encoding::getCodePointNumBytes(), clang::format::encoding::getEscapeSequenceLength(), clang::isAlphanumeric(), and IsBlank().
Referenced by clang::format::BreakableStringLiteral::getSplit().
llvm::Expected< FormatStyle > clang::format::getStyle | ( | StringRef | StyleName, |
StringRef | FileName, | ||
StringRef | FallbackStyle, | ||
StringRef | Code = "" , |
||
vfs::FileSystem * | FS = nullptr |
||
) |
Construct a FormatStyle based on StyleName
.
StyleName
can take several forms:
.clang-format
located in one of the parent directories of FileName
or the current directory if FileName
is empty.[in] | StyleName | Style name to interpret according to the description above. |
[in] | FileName | Path to start search for .clang-format if StyleName == "file". |
[in] | FallbackStyle | The name of a predefined style used to fallback to in case StyleName is "file" and no file can be found. |
[in] | Code | The actual code to be formatted. Used to determine the language if the filename isn't sufficient. |
[in] | FS | The underlying file system, in which the file resides. By default, the file system is the real file system. |
StyleName
. If StyleName
is "file" and no file is found, returns FallbackStyle
. If no style could be determined, returns an Error. Definition at line 2158 of file Format.cpp.
References getLLVMStyle(), getNoStyle(), getPredefinedStyle(), clang::vfs::getRealFileSystem(), guessLanguage(), clang::format::FormatStyle::Language, make_string_error(), clang::vfs::FileSystem::makeAbsolute(), parseConfiguration(), and Style.
Referenced by clang::tooling::formatAndApplyAllReplacements().
const char * clang::format::getTokenTypeName | ( | TokenType | Type | ) |
Determines the name of a token type.
Definition at line 25 of file FormatToken.cpp.
References LIST_TOKEN_TYPES, NUM_TOKEN_TYPES, and TokNames.
FormatStyle clang::format::getWebKitStyle | ( | ) |
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style.html.
Definition at line 889 of file Format.cpp.
References clang::format::FormatStyle::AccessModifierOffset, clang::format::FormatStyle::AlignAfterOpenBracket, clang::format::FormatStyle::AlignOperands, clang::format::FormatStyle::AlignTrailingComments, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakConstructorInitializers, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::FixNamespaceComments, getLLVMStyle(), clang::format::FormatStyle::IndentWidth, clang::format::FormatStyle::NamespaceIndentation, clang::format::FormatStyle::ObjCBlockIndentWidth, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::SpaceBeforeCpp11BracedList, and Style.
FormatStyle::LanguageKind clang::format::guessLanguage | ( | StringRef | FileName, |
StringRef | Code | ||
) |
Definition at line 2136 of file Format.cpp.
References getLanguageByFileName(), and getLLVMStyle().
Referenced by getStyle().
|
inlinestatic |
Definition at line 508 of file UnwrappedLineParser.cpp.
References BK_Block, clang::format::FormatToken::BlockKind, clang::Token::is(), clang::format::FormatToken::is(), clang::format::FormatToken::isOneOf(), clang::format::UnwrappedLine::kInvalidIndex, and clang::format::FormatToken::Tok.
Referenced by clang::serialization::reader::HeaderFileInfoTrait::ComputeHash(), CreateSLocExpansionAbbrev(), clang::HeaderSearch::getCachedModuleFileName(), clang::ast_type_traits::DynTypedNode::DenseMapInfo::getHashValue(), llvm::DenseMapInfo< clang::Sema::FunctionDeclAndLoc >::getHashValue(), clang::CompilerInvocation::getModuleHash(), and clang::TestModuleFileExtension::hashExtension().
|
pure virtual |
Emits the previously retrieved Split
via Whitespaces
.
Referenced by getContentIndent(), and replaceWhitespaceAfterLastLine().
|
virtual |
Returns whether there will be a line break at the start of the token.
Definition at line 206 of file BreakableToken.h.
|
static |
Definition at line 2820 of file TokenAnnotator.cpp.
References BK_Block, clang::format::FormatToken::BlockKind, clang::format::AnnotatedLine::First, clang::format::FormatToken::is(), clang::format::FormatToken::isOneOf(), clang::format::FormatStyle::Language, clang::format::AnnotatedLine::Level, clang::format::FormatStyle::LK_JavaScript, clang::format::FormatStyle::MaxEmptyLinesToKeep, clang::format::FormatToken::NewlinesBefore, clang::format::FormatToken::Previous, and Style.
|
static |
Definition at line 30 of file BreakableToken.cpp.
Referenced by getStringSplit().
|
static |
Definition at line 1967 of file TokenAnnotator.cpp.
|
static |
Definition at line 583 of file UnwrappedLineParser.cpp.
References clang::format::UnwrappedLine::Tokens.
|
static |
Definition at line 601 of file UnwrappedLineParser.cpp.
References clang::format::UnwrappedLine::Tokens.
|
static |
Definition at line 895 of file UnwrappedLineParser.cpp.
References clang::format::FormatToken::isOneOf(), clang::format::AdditionalKeywords::kw_async, clang::format::AdditionalKeywords::kw_finally, clang::format::AdditionalKeywords::kw_function, clang::format::AdditionalKeywords::kw_import, clang::format::AdditionalKeywords::kw_let, clang::format::AdditionalKeywords::kw_var, clang::format::AdditionalKeywords::kw_yield, and Previous.
bool clang::format::isLikelyXml | ( | StringRef | Code | ) |
Definition at line 1807 of file Format.cpp.
Referenced by sortIncludes().
bool clang::format::isMpegTS | ( | StringRef | Code | ) |
Definition at line 1800 of file Format.cpp.
Referenced by sortIncludes().
std::error_code clang::format::make_error_code | ( | ParseError | e | ) |
Definition at line 542 of file Format.cpp.
References getParseCategory().
Referenced by parseConfiguration().
|
inline |
Definition at line 546 of file Format.cpp.
Referenced by clang::tooling::applyAtomicChanges(), getStyle(), and llvm::yaml::MappingTraits< clang::tooling::AtomicChange >::mapping().
|
static |
Definition at line 1925 of file TokenAnnotator.cpp.
References clang::format::AnnotatedLine::First, max(), clang::format::FormatToken::NestingLevel, clang::format::FormatToken::Next, and Tok.
|
static |
Definition at line 286 of file BreakableToken.cpp.
References clang::isPunctuation().
Referenced by clang::format::BreakableBlockComment::mayReflow(), and clang::format::BreakableLineCommentSection::mayReflow().
|
static |
Definition at line 871 of file UnwrappedLineParser.cpp.
References clang::Token::getIdentifierInfo(), clang::format::FormatToken::is(), clang::format::FormatToken::isOneOf(), clang::format::AdditionalKeywords::kw_abstract, clang::format::AdditionalKeywords::kw_as, clang::format::AdditionalKeywords::kw_async, clang::format::AdditionalKeywords::kw_await, clang::format::AdditionalKeywords::kw_extends, clang::format::AdditionalKeywords::kw_finally, clang::format::AdditionalKeywords::kw_from, clang::format::AdditionalKeywords::kw_function, clang::format::AdditionalKeywords::kw_implements, clang::format::AdditionalKeywords::kw_import, clang::format::AdditionalKeywords::kw_in, clang::format::AdditionalKeywords::kw_instanceof, clang::format::AdditionalKeywords::kw_interface, clang::format::AdditionalKeywords::kw_is, clang::format::AdditionalKeywords::kw_let, clang::format::AdditionalKeywords::kw_of, clang::format::AdditionalKeywords::kw_throws, clang::format::AdditionalKeywords::kw_var, clang::format::AdditionalKeywords::kw_yield, and clang::format::FormatToken::Tok.
Referenced by mustBeJSIdentOrValue().
|
static |
Definition at line 886 of file UnwrappedLineParser.cpp.
References clang::Token::isLiteral(), clang::format::FormatToken::isOneOf(), mustBeJSIdent(), and clang::format::FormatToken::Tok.
|
static |
Definition at line 137 of file ContinuationIndenter.cpp.
References clang::format::FormatToken::is(), clang::format::FormatToken::isNot(), clang::format::FormatStyle::Language, clang::format::FormatStyle::LK_Proto, clang::format::FormatStyle::LK_TextProto, clang::format::FormatToken::NestingLevel, and clang::format::FormatToken::Previous.
bool clang::format::operator< | ( | const JsModuleReference & | LHS, |
const JsModuleReference & | RHS | ||
) |
Definition at line 94 of file SortJavaScriptImports.cpp.
References clang::format::JsModuleReference::Category, clang::format::JsModuleReference::IsExport, clang::format::JsModuleReference::Prefix, and clang::format::JsModuleReference::URL.
std::error_code clang::format::parseConfiguration | ( | StringRef | Text, |
FormatStyle * | Style | ||
) |
Parse configuration from YAML-formatted text.
Style->Language is used to get the base style, if the BasedOnStyle
option is present.
The FormatStyleSet of Style is reset.
When BasedOnStyle
is not present, options not present in the YAML document, are retained in Style
.
Definition at line 957 of file Format.cpp.
References clang::format::FormatStyle::FormatStyleSet::Add(), clang::format::FormatStyle::FormatStyleSet::Clear(), clang::serialized_diags::Error, clang::format::FormatStyle::FormatStyleSet::Get(), clang::format::FormatStyle::Language, and make_error_code().
Referenced by getStyle().
|
static |
Definition at line 2323 of file UnwrappedLineParser.cpp.
References clang::format::UnwrappedLine::FirstStartColumn, clang::format::UnwrappedLine::InPPDirective, and clang::format::UnwrappedLine::Level.
|
static |
Definition at line 1828 of file Format.cpp.
References clang::tooling::applyAllReplacements(), clang::tooling::Replacements::begin(), clang::tooling::Replacements::empty(), clang::tooling::Replacements::getAffectedRanges(), and clang::tooling::Replacements::merge().
Referenced by cleanupAroundReplacements(), and formatReplacements().
|
virtual |
Reflows the current line into the end of the previous one.
Definition at line 201 of file BreakableToken.h.
tooling::Replacements clang::format::reformat | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName = "<stdin>" , |
||
FormattingAttemptStatus * | Status = nullptr |
||
) |
Reformats the given Ranges
in Code
.
Each range is extended on either end to its next bigger logic unit, i.e. everything that might influence its formatting or might be influenced by its formatting.
Returns the Replacements
necessary to make all Ranges
comply with Style
.
If Status
is non-null, its value will be populated with the status of this formatting attempt. See FormattingAttemptStatus
.
Definition at line 2039 of file Format.cpp.
Referenced by clang::tooling::applyAtomicChanges().
tooling::Replacements clang::format::reformat | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName, | ||
bool * | IncompleteFormat | ||
) |
Same as above, except if IncompleteFormat
is non-null, its value will be set to true if any of the affected ranges were not formatted due to a non-recoverable syntax error.
Definition at line 2059 of file Format.cpp.
void clang::format::replaceWhitespaceAfterLastLine | ( | unsigned | TailOffset, |
Split | SplitAfterLastLine, | ||
WhitespaceManager & | Whitespaces | ||
) | const |
Replaces the whitespace from SplitAfterLastLine
on the last line after the last line has been formatted by performing a reformatting.
Definition at line 226 of file BreakableToken.h.
References getLineCount(), and insertBreak().
|
static |
Definition at line 619 of file UnwrappedLineParser.cpp.
References clang::format::FormatStyle::BraceWrappingFlags::AfterClass, clang::format::FormatStyle::BraceWrappingFlags::AfterNamespace, clang::format::FormatStyle::BraceWrappingFlags::AfterStruct, clang::format::FormatStyle::BraceWrappingFlags::AfterUnion, clang::format::FormatStyle::BraceWrapping, clang::if(), and clang::format::FormatToken::is().
|
static |
Definition at line 31 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::IndentWrappedFunctionNames, and LT_ObjCMethodDecl.
|
static |
Definition at line 1659 of file Format.cpp.
References affectsRange(), Category, Filename, FindCursorIndex(), clang::tooling::IncludeStyle::IncludeBlocks, and clang::format::FormatStyle::IncludeStyle.
tooling::Replacements clang::format::sortCppIncludes | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName, | ||
tooling::Replacements & | Replaces, | ||
unsigned * | Cursor | ||
) |
Definition at line 1734 of file Format.cpp.
Referenced by sortIncludes().
tooling::Replacements clang::format::sortIncludes | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName, | ||
unsigned * | Cursor = nullptr |
||
) |
Returns the replacements necessary to sort all #include
blocks that are affected by Ranges
.
Definition at line 1809 of file Format.cpp.
References isLikelyXml(), isMpegTS(), clang::format::FormatStyle::Language, sortCppIncludes(), clang::format::FormatStyle::SortIncludes, and sortJavaScriptImports().
Referenced by clang::tooling::applyAtomicChanges(), and formatReplacements().
tooling::Replacements clang::format::sortJavaScriptImports | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName | ||
) |
Definition at line 443 of file SortJavaScriptImports.cpp.
References clang::format::TokenAnalyzer::process().
Referenced by sortIncludes().
tooling::Replacements clang::format::sortUsingDeclarations | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName = "<stdin>" |
||
) |
Sort consecutive using declarations in the given Ranges
in Code
.
Returns the Replacements
that sort the using declarations in all Ranges
in Code
.
Definition at line 2078 of file Format.cpp.
References clang::format::TokenAnalyzer::process().
|
static |
Definition at line 121 of file ContinuationIndenter.cpp.
|
static |
Definition at line 116 of file ContinuationIndenter.cpp.
References clang::format::FormatToken::closesScope(), clang::format::FormatToken::isMemberAccess(), and clang::format::FormatToken::Previous.
|
virtual |
Returns whether the token supports reflowing text.
Definition at line 182 of file BreakableToken.h.
*p Token must be a comment *bool clang::format::switchesFormatting | ( | const FormatToken & | Token | ) |
Checks if Token
switches formatting, like /* clang-format off.
Definition at line 169 of file BreakableToken.cpp.
References clang::format::FormatToken::is(), and clang::format::FormatToken::TokenText.
Referenced by getEnclosingFunctionName(), clang::format::BreakableBlockComment::mayReflow(), and clang::format::BreakableLineCommentSection::mayReflow().
|
static |
Definition at line 845 of file UnwrappedLineParser.cpp.
References clang::Token::isNot().
|
virtual |
Updates the next token of State
to the next token after this one.
This can be used when this token manages a set of underlying tokens as a unit and is responsible for the formatting of the them.
Definition at line 236 of file BreakableToken.h.
|
virtual |
Definition at line 95 of file BreakableToken.h.
References getLineCount(), and getRangeLength().
|
static |
Definition at line 29 of file BreakableToken.cpp.
const char * clang::format::DefaultFallbackStyle = "LLVM" |
The suggested predefined style to use as the fallback style in getStyle
.
Different builds can modify the value to the preferred styles.
Definition at line 2156 of file Format.cpp.
const char * clang::format::DefaultFormatStyle = "file" |
The suggested format style to use by default.
This allows tools using getStyle
to have a consistent default style. Different builds can modify the value to the preferred styles.
Definition at line 2154 of file Format.cpp.
|
protected |
Definition at line 246 of file BreakableToken.h.
Referenced by clang::format::BreakableBlockComment::BreakableBlockComment(), getCommentSplit(), clang::format::BreakableBlockComment::getRangeLength(), clang::format::BreakableLineCommentSection::getRangeLength(), clang::format::BreakableStringLiteral::getRemainingLength(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableComment::getSplit(), and getStringSplit().
|
protected |
Definition at line 245 of file BreakableToken.h.
Referenced by clang::format::BreakableBlockComment::BreakableBlockComment(), and clang::format::WhitespaceManager::WhitespaceManager().
to be on a line of clang::format::itself |
Base class for tokens / ranges of tokens that can allow breaking within the tokens - for example, to avoid whitespace beyond the column limit, or to reflow text.
Generally, a breakable token consists of logical lines, addressed by a line index. For example, in a sequence of line comments, each line comment is its own logical line; similarly, for a block comment, each line in the block comment is on its own logical line.
There are two methods to compute the layout of the token:
The mechanism to adapt the layout of the breakable token is organised around the concept of a Split
, which is a whitespace range that signifies a position of the content of a token where a reformatting might be done.
Operating with splits is divided into two operations:
There is a pair of operations that are used to compress a long whitespace range with a single space if that will bring the line length under the column limit:
For tokens where the whitespace before each line needs to be also reformatted, for example for tokens supporting reflow, there are analogous operations that might be executed before the main line breaking occurs:
For tokens that require the whitespace after the last line to be reformatted, for example in multiline jsdoc comments that require the trailing '
Definition at line 35 of file BreakableToken.h.
to be on a line of there are analogous operations* that might be executed after the last line has been for finding a split after the last line that needs* to be clang::format::reflown |
Definition at line 35 of file BreakableToken.h.
to be on a line of there are analogous operations* that might be executed after the last line has been clang::format::reformatted |
Definition at line 35 of file BreakableToken.h.
to be on a line of there are analogous operations* that might be executed after the last line has been for finding a split after the last line that needs* to be * clang::format::replaceWhitespaceAfterLastLine |
Definition at line 35 of file BreakableToken.h.
|
protected |
Definition at line 247 of file BreakableToken.h.
Referenced by clang::format::BreakableBlockComment::BreakableBlockComment(), cleanupAroundReplacements(), expandPresets(), clang::format::CommaSeparatedList::formatAfterToken(), formatReplacements(), clang::format::FormatStyle::FormatStyleSet::Get(), clang::format::BreakableBlockComment::getContentIndent(), getGNUStyle(), clang::format::FormatStyle::GetLanguageStyle(), clang::format::BreakableBlockComment::getRangeLength(), clang::format::BreakableLineCommentSection::getRangeLength(), clang::format::BreakableStringLiteral::getRemainingLength(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableComment::getSplit(), getStyle(), getWebKitStyle(), clang::format::WhitespaceManager::Change::indentAndNestingLevel(), isAllmanBrace(), llvm::yaml::MappingTraits< clang::tooling::AtomicChange >::mapping(), clang::format::CommaSeparatedList::precomputeFormattingInfos(), and clang::VarDecl::setInitStyle().
const char * clang::format::StyleOptionHelpDescription |
Description to be used for help text for a llvm::cl
option for specifying format style.
The description is closely related to the operation of getStyle()
.
Definition at line 2105 of file Format.cpp.
|
protected |
Definition at line 244 of file BreakableToken.h.
Referenced by clang::Sema::ActOnStringLiteral(), clang::format::AffectedRangeManager::AffectedRangeManager(), AuditedType(), clang::format::BreakableBlockComment::BreakableBlockComment(), clang::format::BreakableLineCommentSection::BreakableLineCommentSection(), clang::CacheTokens(), clang::Preprocessor::CheckEndOfDirective(), compareModuleHeaders(), DoPrintMacros(), clang::DoPrintPreprocessedInput(), clang::Preprocessor::EnterMacro(), clang::Preprocessor::EnterToken(), EvaluateDirectiveSubExpr(), EvaluateFeatureLikeBuiltinMacro(), clang::DumpTokensAction::ExecuteAction(), clang::PreprocessOnlyAction::ExecuteAction(), findDirectives(), clang::Lexer::findLocationAfterToken(), clang::Lexer::findNextToken(), clang::Lexer::getBufferLocation(), getEnclosingFunctionName(), clang::format::FormatTokenLexer::getKeywords(), clang::ModuleMapParser::getLocation(), clang::MacroInfo::getReplacementToken(), clang::StringLiteralParser::getUDSuffixOffset(), clang::PragmaNamespace::HandlePragma(), clang::Preprocessor::HandlePragmaPoison(), clang::html::HighlightMacros(), isConfigurationPattern(), IsStringPrefix(), isTargetEnvironment(), clang::format::FormatTokenLexer::lex(), clang::PTHLexer::Lex(), clang::TokenLexer::Lex(), clang::Preprocessor::LexOnOffSwitch(), clang::Preprocessor::LexUnexpandedNonComment(), LocPropertyAttribute(), maxNestingDepth(), clang::format::BreakableBlockComment::mayReflow(), clang::format::BreakableLineCommentSection::mayReflow(), ParseAlignPragma(), parseDeclareSimdClauses(), ParseLoopHintValue(), clang::ModuleMapParser::parseModuleMapFile(), parseOpenMPDirectiveKind(), clang::Parser::ParseOpenMPParensExpr(), parseOpenMPReductionId(), clang::Parser::ParseOpenMPVarList(), clang::Preprocessor::ParsePragmaPushOrPopMacro(), ReadLineMarkerFlags(), clang::Lexer::ReadToEndOfLine(), clang::ASTReader::ReadToken(), resyncUTF8(), clang::RewriteIncludesInInput(), shouldAddRequirement(), clang::Preprocessor::SkipTokensUntilPCHThroughHeader(), clang::MacroArgs::StringifyArgument(), clang::html::SyntaxHighlight(), clang::format::BreakableComment::tokenAt(), clang::TokenRewriter::TokenRewriter(), UseNSOptionsMacro(), clang::format::WhitespaceManager::WhitespaceManager(), and clang::TokenLexer::~TokenLexer().