2013-06-04 00:45:03 +08:00
|
|
|
//===--- FormatToken.h - Format C++ code ------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief This file contains the declaration of the FormatToken, a wrapper
|
|
|
|
/// around Token with additional information related to formatting.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:25:19 +08:00
|
|
|
#ifndef LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
|
|
|
|
#define LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2014-11-04 20:41:02 +08:00
|
|
|
#include "clang/Basic/IdentifierTable.h"
|
2013-06-04 00:45:03 +08:00
|
|
|
#include "clang/Basic/OperatorPrecedence.h"
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
#include "clang/Format/Format.h"
|
2013-06-04 00:45:03 +08:00
|
|
|
#include "clang/Lex/Lexer.h"
|
2014-03-09 19:36:40 +08:00
|
|
|
#include <memory>
|
2017-07-04 23:30:21 +08:00
|
|
|
#include <unordered_set>
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace format {
|
|
|
|
|
2017-09-20 17:51:03 +08:00
|
|
|
#define LIST_TOKEN_TYPES \
|
|
|
|
TYPE(ArrayInitializerLSquare) \
|
|
|
|
TYPE(ArraySubscriptLSquare) \
|
|
|
|
TYPE(AttributeParen) \
|
|
|
|
TYPE(BinaryOperator) \
|
|
|
|
TYPE(BitFieldColon) \
|
|
|
|
TYPE(BlockComment) \
|
|
|
|
TYPE(CastRParen) \
|
|
|
|
TYPE(ConditionalExpr) \
|
|
|
|
TYPE(ConflictAlternative) \
|
|
|
|
TYPE(ConflictEnd) \
|
|
|
|
TYPE(ConflictStart) \
|
|
|
|
TYPE(CtorInitializerColon) \
|
|
|
|
TYPE(CtorInitializerComma) \
|
|
|
|
TYPE(DesignatedInitializerLSquare) \
|
|
|
|
TYPE(DesignatedInitializerPeriod) \
|
|
|
|
TYPE(DictLiteral) \
|
|
|
|
TYPE(ForEachMacro) \
|
|
|
|
TYPE(FunctionAnnotationRParen) \
|
|
|
|
TYPE(FunctionDeclarationName) \
|
|
|
|
TYPE(FunctionLBrace) \
|
|
|
|
TYPE(FunctionTypeLParen) \
|
|
|
|
TYPE(ImplicitStringLiteral) \
|
|
|
|
TYPE(InheritanceColon) \
|
|
|
|
TYPE(InheritanceComma) \
|
|
|
|
TYPE(InlineASMBrace) \
|
|
|
|
TYPE(InlineASMColon) \
|
|
|
|
TYPE(JavaAnnotation) \
|
|
|
|
TYPE(JsComputedPropertyName) \
|
|
|
|
TYPE(JsExponentiation) \
|
|
|
|
TYPE(JsExponentiationEqual) \
|
|
|
|
TYPE(JsFatArrow) \
|
|
|
|
TYPE(JsNonNullAssertion) \
|
|
|
|
TYPE(JsTypeColon) \
|
|
|
|
TYPE(JsTypeOperator) \
|
|
|
|
TYPE(JsTypeOptionalQuestion) \
|
|
|
|
TYPE(LambdaArrow) \
|
|
|
|
TYPE(LambdaLSquare) \
|
|
|
|
TYPE(LeadingJavaAnnotation) \
|
|
|
|
TYPE(LineComment) \
|
|
|
|
TYPE(MacroBlockBegin) \
|
|
|
|
TYPE(MacroBlockEnd) \
|
|
|
|
TYPE(ObjCBlockLBrace) \
|
|
|
|
TYPE(ObjCBlockLParen) \
|
|
|
|
TYPE(ObjCDecl) \
|
|
|
|
TYPE(ObjCForIn) \
|
|
|
|
TYPE(ObjCMethodExpr) \
|
|
|
|
TYPE(ObjCMethodSpecifier) \
|
|
|
|
TYPE(ObjCProperty) \
|
|
|
|
TYPE(ObjCStringLiteral) \
|
|
|
|
TYPE(OverloadedOperator) \
|
|
|
|
TYPE(OverloadedOperatorLParen) \
|
|
|
|
TYPE(PointerOrReference) \
|
|
|
|
TYPE(PureVirtualSpecifier) \
|
|
|
|
TYPE(RangeBasedForLoopColon) \
|
|
|
|
TYPE(RegexLiteral) \
|
|
|
|
TYPE(SelectorName) \
|
|
|
|
TYPE(StartOfName) \
|
|
|
|
TYPE(StructuredBindingLSquare) \
|
|
|
|
TYPE(TemplateCloser) \
|
|
|
|
TYPE(TemplateOpener) \
|
|
|
|
TYPE(TemplateString) \
|
|
|
|
TYPE(TrailingAnnotation) \
|
|
|
|
TYPE(TrailingReturnArrow) \
|
|
|
|
TYPE(TrailingUnaryOperator) \
|
|
|
|
TYPE(UnaryOperator) \
|
2015-07-14 00:19:34 +08:00
|
|
|
TYPE(Unknown)
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
enum TokenType {
|
2015-07-14 00:19:34 +08:00
|
|
|
#define TYPE(X) TT_##X,
|
2017-09-20 17:51:03 +08:00
|
|
|
LIST_TOKEN_TYPES
|
2015-07-14 00:19:34 +08:00
|
|
|
#undef TYPE
|
2017-09-20 17:51:03 +08:00
|
|
|
NUM_TOKEN_TYPES
|
2013-06-04 00:45:03 +08:00
|
|
|
};
|
|
|
|
|
2015-07-14 00:19:34 +08:00
|
|
|
/// \brief Determines the name of a token type.
|
|
|
|
const char *getTokenTypeName(TokenType Type);
|
|
|
|
|
2013-07-09 17:06:29 +08:00
|
|
|
// Represents what type of block a set of braces open.
|
2015-06-17 21:08:06 +08:00
|
|
|
enum BraceBlockKind { BK_Unknown, BK_Block, BK_BracedInit };
|
2013-07-09 17:06:29 +08:00
|
|
|
|
2013-07-10 22:02:49 +08:00
|
|
|
// The packing kind of a function's parameters.
|
2015-06-17 21:08:06 +08:00
|
|
|
enum ParameterPackingKind { PPK_BinPacked, PPK_OnePerLine, PPK_Inconclusive };
|
2013-07-10 22:02:49 +08:00
|
|
|
|
2015-06-17 21:08:06 +08:00
|
|
|
enum FormatDecision { FD_Unformatted, FD_Continue, FD_Break };
|
2013-10-12 05:25:45 +08:00
|
|
|
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
class TokenRole;
|
2013-09-05 17:29:45 +08:00
|
|
|
class AnnotatedLine;
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
/// \brief A wrapper around a \c Token storing information about the
|
2013-12-06 00:25:25 +08:00
|
|
|
/// whitespace characters preceding it.
|
2013-06-04 00:45:03 +08:00
|
|
|
struct FormatToken {
|
2015-05-04 16:51:40 +08:00
|
|
|
FormatToken() {}
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief The \c Token.
|
|
|
|
Token Tok;
|
|
|
|
|
|
|
|
/// \brief The number of newlines immediately before the \c Token.
|
|
|
|
///
|
|
|
|
/// This can be used to determine what the user wrote in the original code
|
|
|
|
/// and thereby e.g. leave an empty line between two function definitions.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned NewlinesBefore = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief Whether there is at least one unescaped newline before the \c
|
|
|
|
/// Token.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool HasUnescapedNewline = false;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2013-12-06 00:25:25 +08:00
|
|
|
/// \brief The range of the whitespace immediately preceding the \c Token.
|
2013-06-04 00:45:03 +08:00
|
|
|
SourceRange WhitespaceRange;
|
|
|
|
|
|
|
|
/// \brief The offset just past the last '\n' in this token's leading
|
|
|
|
/// whitespace (relative to \c WhiteSpaceStart). 0 if there is no '\n'.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned LastNewlineOffset = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2013-09-10 17:38:25 +08:00
|
|
|
/// \brief The width of the non-whitespace parts of the token (or its first
|
|
|
|
/// line for multi-line tokens) in columns.
|
2013-06-05 22:09:10 +08:00
|
|
|
/// We need this to correctly measure number of columns a token spans.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned ColumnWidth = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2013-09-10 17:38:25 +08:00
|
|
|
/// \brief Contains the width in columns of the last line of a multi-line
|
2013-09-02 21:58:14 +08:00
|
|
|
/// token.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned LastLineColumnWidth = 0;
|
2013-09-02 21:58:14 +08:00
|
|
|
|
2013-09-10 17:38:25 +08:00
|
|
|
/// \brief Whether the token text contains newlines (escaped or not).
|
2015-05-04 16:51:40 +08:00
|
|
|
bool IsMultiline = false;
|
2013-09-02 21:58:14 +08:00
|
|
|
|
2016-05-29 22:41:36 +08:00
|
|
|
/// \brief Indicates that this is the first token of the file.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool IsFirst = false;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief Whether there must be a line break before this token.
|
|
|
|
///
|
|
|
|
/// This happens for example when a preprocessor directive ended directly
|
|
|
|
/// before the token.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool MustBreakBefore = false;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief The raw text of the token.
|
|
|
|
///
|
|
|
|
/// Contains the raw token text without leading whitespace and without leading
|
|
|
|
/// escaped newlines.
|
|
|
|
StringRef TokenText;
|
|
|
|
|
2013-07-17 04:28:33 +08:00
|
|
|
/// \brief Set to \c true if this token is an unterminated literal.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool IsUnterminatedLiteral = 0;
|
2013-07-17 04:28:33 +08:00
|
|
|
|
2013-07-09 17:06:29 +08:00
|
|
|
/// \brief Contains the kind of block if this token is a brace.
|
2015-05-04 16:51:40 +08:00
|
|
|
BraceBlockKind BlockKind = BK_Unknown;
|
2013-07-09 17:06:29 +08:00
|
|
|
|
2015-05-04 16:51:40 +08:00
|
|
|
TokenType Type = TT_Unknown;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
/// \brief The number of spaces that should be inserted before this token.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned SpacesRequiredBefore = 0;
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
|
|
|
/// \brief \c true if it is allowed to break before this token.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool CanBreakBefore = false;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2015-05-04 16:51:40 +08:00
|
|
|
/// \brief \c true if this is the ">" of "template<..>".
|
|
|
|
bool ClosesTemplateDeclaration = false;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief Number of parameters, if this is "(", "[" or "<".
|
|
|
|
///
|
|
|
|
/// This is initialized to 1 as we don't need to distinguish functions with
|
|
|
|
/// 0 parameters from functions with 1 parameter. Thus, we can simply count
|
|
|
|
/// the number of commas.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned ParameterCount = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2014-06-03 20:02:45 +08:00
|
|
|
/// \brief Number of parameters that are nested blocks,
|
|
|
|
/// if this is "(", "[" or "<".
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned BlockParameterCount = 0;
|
2014-06-03 20:02:45 +08:00
|
|
|
|
2015-05-04 15:39:00 +08:00
|
|
|
/// \brief If this is a bracket ("<", "(", "[" or "{"), contains the kind of
|
|
|
|
/// the surrounding bracket.
|
2015-05-04 16:51:40 +08:00
|
|
|
tok::TokenKind ParentBracket = tok::unknown;
|
2015-05-04 15:39:00 +08:00
|
|
|
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
/// \brief A token can have a special role that can carry extra information
|
|
|
|
/// about the token's formatting.
|
2014-03-08 04:03:18 +08:00
|
|
|
std::unique_ptr<TokenRole> Role;
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
2013-07-10 22:02:49 +08:00
|
|
|
/// \brief If this is an opening parenthesis, how are the parameters packed?
|
2015-05-04 16:51:40 +08:00
|
|
|
ParameterPackingKind PackingKind = PPK_Inconclusive;
|
2013-07-10 22:02:49 +08:00
|
|
|
|
2013-08-29 23:21:40 +08:00
|
|
|
/// \brief The total length of the unwrapped line up to and including this
|
|
|
|
/// token.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned TotalLength = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2013-09-10 17:38:25 +08:00
|
|
|
/// \brief The original 0-based column of this token, including expanded tabs.
|
|
|
|
/// The configured TabWidth is used as tab width.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned OriginalColumn = 0;
|
2013-08-29 23:21:40 +08:00
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
/// \brief The length of following tokens until the next natural split point,
|
|
|
|
/// or the next token that can be broken.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned UnbreakableTailLength = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
// FIXME: Come up with a 'cleaner' concept.
|
|
|
|
/// \brief The binding strength of a token. This is a combined value of
|
|
|
|
/// operator precedence, parenthesis nesting, etc.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned BindingStrength = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
clang-format: Be more conservative about braced list column layout.
Specifically disable it for nested braced lists as it commonly can look
really weird. Eventually, we'll want to become smarter and format some of
the nested lists better.
Before:
SomeStruct my_struct_array = {
{ aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa,
aaaaaaaaaa, aaaaaaaaaa, aaaaaaa, aaa },
{ aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa },
{ aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaa, a, aaaaaaaaaa,
aaaaaaaaa, aaa },
};
After:
SomeStruct my_struct_array = {
{ aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa, aaaaaaaaaa,
aaaaaaaaaaaa, aaaaaaa, aaa },
{ aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa },
{ aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaa, a, aaaaaaaaaa, aaaaaaaaa, aaa },
};
llvm-svn: 196783
2013-12-09 22:40:19 +08:00
|
|
|
/// \brief The nesting level of this token, i.e. the number of surrounding (),
|
|
|
|
/// [], {} or <>.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned NestingLevel = 0;
|
clang-format: Be more conservative about braced list column layout.
Specifically disable it for nested braced lists as it commonly can look
really weird. Eventually, we'll want to become smarter and format some of
the nested lists better.
Before:
SomeStruct my_struct_array = {
{ aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa,
aaaaaaaaaa, aaaaaaaaaa, aaaaaaa, aaa },
{ aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa },
{ aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaa, a, aaaaaaaaaa,
aaaaaaaaa, aaa },
};
After:
SomeStruct my_struct_array = {
{ aaaaaa, aaaaaaaa, aaaaaaaaaa, aaaaaaaaa, aaaaaaaaa, aaaaaaaaaa,
aaaaaaaaaaaa, aaaaaaa, aaa },
{ aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaaa, aaa },
{ aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaa, a, aaaaaaaaaa, aaaaaaaaa, aaa },
};
llvm-svn: 196783
2013-12-09 22:40:19 +08:00
|
|
|
|
2017-01-31 19:25:01 +08:00
|
|
|
/// \brief The indent level of this token. Copied from the surrounding line.
|
|
|
|
unsigned IndentLevel = 0;
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
/// \brief Penalty for inserting a line break before this token.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned SplitPenalty = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief If this is the first ObjC selector name in an ObjC method
|
|
|
|
/// definition or call, this contains the length of the longest name.
|
2013-12-23 15:29:06 +08:00
|
|
|
///
|
|
|
|
/// This being set to 0 means that the selectors should not be colon-aligned,
|
|
|
|
/// e.g. because several of them are block-type.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned LongestObjCSelectorName = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief Stores the number of required fake parentheses and the
|
|
|
|
/// corresponding operator precedence.
|
|
|
|
///
|
|
|
|
/// If multiple fake parentheses start at a token, this vector stores them in
|
|
|
|
/// reverse order, i.e. inner fake parenthesis first.
|
|
|
|
SmallVector<prec::Level, 4> FakeLParens;
|
|
|
|
/// \brief Insert this many fake ) after this token for correct indentation.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned FakeRParens = 0;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2013-09-06 16:08:14 +08:00
|
|
|
/// \brief \c true if this token starts a binary expression, i.e. has at least
|
|
|
|
/// one fake l_paren with a precedence greater than prec::Unknown.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool StartsBinaryExpression = false;
|
2013-09-06 16:08:14 +08:00
|
|
|
/// \brief \c true if this token ends a binary expression.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool EndsBinaryExpression = false;
|
2013-09-06 16:08:14 +08:00
|
|
|
|
2014-04-16 20:26:54 +08:00
|
|
|
/// \brief Is this is an operator (or "."/"->") in a sequence of operators
|
|
|
|
/// with the same precedence, contains the 0-based operator index.
|
2015-05-04 16:51:40 +08:00
|
|
|
unsigned OperatorIndex = 0;
|
2014-04-16 20:26:54 +08:00
|
|
|
|
2016-01-05 21:03:50 +08:00
|
|
|
/// \brief If this is an operator (or "."/"->") in a sequence of operators
|
|
|
|
/// with the same precedence, points to the next operator.
|
|
|
|
FormatToken *NextOperator = nullptr;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
/// \brief Is this token part of a \c DeclStmt defining multiple variables?
|
|
|
|
///
|
|
|
|
/// Only set if \c Type == \c TT_StartOfName.
|
2015-05-04 16:51:40 +08:00
|
|
|
bool PartOfMultiVariableDeclStmt = false;
|
2013-06-04 00:45:03 +08:00
|
|
|
|
2017-02-02 22:36:50 +08:00
|
|
|
/// \brief Does this line comment continue a line comment section?
|
|
|
|
///
|
|
|
|
/// Only set to true if \c Type == \c TT_LineComment.
|
|
|
|
bool ContinuesLineCommentSection = false;
|
|
|
|
|
2015-05-04 16:51:40 +08:00
|
|
|
/// \brief If this is a bracket, this points to the matching one.
|
|
|
|
FormatToken *MatchingParen = nullptr;
|
|
|
|
|
|
|
|
/// \brief The previous token in the unwrapped line.
|
|
|
|
FormatToken *Previous = nullptr;
|
|
|
|
|
|
|
|
/// \brief The next token in the unwrapped line.
|
|
|
|
FormatToken *Next = nullptr;
|
|
|
|
|
|
|
|
/// \brief If this token starts a block, this contains all the unwrapped lines
|
|
|
|
/// in it.
|
|
|
|
SmallVector<AnnotatedLine *, 1> Children;
|
|
|
|
|
|
|
|
/// \brief Stores the formatting decision for the token once it was made.
|
|
|
|
FormatDecision Decision = FD_Unformatted;
|
|
|
|
|
|
|
|
/// \brief If \c true, this token has been fully formatted (indented and
|
|
|
|
/// potentially re-formatted inside), and we do not allow further formatting
|
|
|
|
/// changes.
|
|
|
|
bool Finalized = false;
|
2014-04-01 20:55:11 +08:00
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
bool is(tok::TokenKind Kind) const { return Tok.is(Kind); }
|
2014-11-21 20:14:12 +08:00
|
|
|
bool is(TokenType TT) const { return Type == TT; }
|
2014-11-04 20:41:02 +08:00
|
|
|
bool is(const IdentifierInfo *II) const {
|
|
|
|
return II && II == Tok.getIdentifierInfo();
|
|
|
|
}
|
2015-08-14 20:44:06 +08:00
|
|
|
bool is(tok::PPKeywordKind Kind) const {
|
|
|
|
return Tok.getIdentifierInfo() &&
|
|
|
|
Tok.getIdentifierInfo()->getPPKeywordID() == Kind;
|
|
|
|
}
|
2014-11-25 18:05:17 +08:00
|
|
|
template <typename A, typename B> bool isOneOf(A K1, B K2) const {
|
2014-11-24 03:03:25 +08:00
|
|
|
return is(K1) || is(K2);
|
2013-06-04 00:45:03 +08:00
|
|
|
}
|
2015-02-16 04:11:14 +08:00
|
|
|
template <typename A, typename B, typename... Ts>
|
|
|
|
bool isOneOf(A K1, B K2, Ts... Ks) const {
|
|
|
|
return is(K1) || isOneOf(K2, Ks...);
|
2014-11-24 23:42:34 +08:00
|
|
|
}
|
2014-11-25 18:05:17 +08:00
|
|
|
template <typename T> bool isNot(T Kind) const { return !is(Kind); }
|
2014-11-04 20:41:02 +08:00
|
|
|
|
2016-05-29 22:41:02 +08:00
|
|
|
/// \c true if this token starts a sequence with the given tokens in order,
|
|
|
|
/// following the ``Next`` pointers, ignoring comments.
|
|
|
|
template <typename A, typename... Ts>
|
|
|
|
bool startsSequence(A K1, Ts... Tokens) const {
|
|
|
|
return startsSequenceInternal(K1, Tokens...);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \c true if this token ends a sequence with the given tokens in order,
|
|
|
|
/// following the ``Previous`` pointers, ignoring comments.
|
|
|
|
template <typename A, typename... Ts>
|
|
|
|
bool endsSequence(A K1, Ts... Tokens) const {
|
|
|
|
return endsSequenceInternal(K1, Tokens...);
|
|
|
|
}
|
|
|
|
|
2013-12-20 14:22:01 +08:00
|
|
|
bool isStringLiteral() const { return tok::isStringLiteral(Tok.getKind()); }
|
2013-06-04 00:45:03 +08:00
|
|
|
|
|
|
|
bool isObjCAtKeyword(tok::ObjCKeywordKind Kind) const {
|
|
|
|
return Tok.isObjCAtKeyword(Kind);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAccessSpecifier(bool ColonRequired = true) const {
|
|
|
|
return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private) &&
|
|
|
|
(!ColonRequired || (Next && Next->is(tok::colon)));
|
|
|
|
}
|
|
|
|
|
2014-01-16 17:11:55 +08:00
|
|
|
/// \brief Determine whether the token is a simple-type-specifier.
|
|
|
|
bool isSimpleTypeSpecifier() const;
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
bool isObjCAccessSpecifier() const {
|
2017-09-20 17:51:03 +08:00
|
|
|
return is(tok::at) && Next &&
|
|
|
|
(Next->isObjCAtKeyword(tok::objc_public) ||
|
|
|
|
Next->isObjCAtKeyword(tok::objc_protected) ||
|
|
|
|
Next->isObjCAtKeyword(tok::objc_package) ||
|
|
|
|
Next->isObjCAtKeyword(tok::objc_private));
|
2013-06-04 00:45:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Returns whether \p Tok is ([{ or a template opening <.
|
|
|
|
bool opensScope() const {
|
2017-01-31 21:03:07 +08:00
|
|
|
if (is(TT_TemplateString) && TokenText.endswith("${"))
|
|
|
|
return true;
|
2014-11-25 18:05:17 +08:00
|
|
|
return isOneOf(tok::l_paren, tok::l_brace, tok::l_square,
|
|
|
|
TT_TemplateOpener);
|
2013-06-04 00:45:03 +08:00
|
|
|
}
|
2013-06-26 03:25:12 +08:00
|
|
|
/// \brief Returns whether \p Tok is )]} or a template closing >.
|
2013-06-04 00:45:03 +08:00
|
|
|
bool closesScope() const {
|
2017-01-31 21:03:07 +08:00
|
|
|
if (is(TT_TemplateString) && TokenText.startswith("}"))
|
|
|
|
return true;
|
2014-11-25 18:05:17 +08:00
|
|
|
return isOneOf(tok::r_paren, tok::r_brace, tok::r_square,
|
|
|
|
TT_TemplateCloser);
|
2013-06-04 00:45:03 +08:00
|
|
|
}
|
|
|
|
|
clang-format: Format segments of builder-type calls one per line.
This fixes llvm.org/PR14818.
Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);
llvm-svn: 189353
2013-08-27 22:24:43 +08:00
|
|
|
/// \brief Returns \c true if this is a "." or "->" accessing a member.
|
|
|
|
bool isMemberAccess() const {
|
2014-07-09 21:07:57 +08:00
|
|
|
return isOneOf(tok::arrow, tok::period, tok::arrowstar) &&
|
2015-03-27 02:46:28 +08:00
|
|
|
!isOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow,
|
|
|
|
TT_LambdaArrow);
|
clang-format: Format segments of builder-type calls one per line.
This fixes llvm.org/PR14818.
Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);
llvm-svn: 189353
2013-08-27 22:24:43 +08:00
|
|
|
}
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
bool isUnaryOperator() const {
|
|
|
|
switch (Tok.getKind()) {
|
|
|
|
case tok::plus:
|
|
|
|
case tok::plusplus:
|
|
|
|
case tok::minus:
|
|
|
|
case tok::minusminus:
|
|
|
|
case tok::exclaim:
|
|
|
|
case tok::tilde:
|
|
|
|
case tok::kw_sizeof:
|
|
|
|
case tok::kw_alignof:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
clang-format: Format segments of builder-type calls one per line.
This fixes llvm.org/PR14818.
Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);
llvm-svn: 189353
2013-08-27 22:24:43 +08:00
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
bool isBinaryOperator() const {
|
|
|
|
// Comma is a binary operator, but does not behave as such wrt. formatting.
|
|
|
|
return getPrecedence() > prec::Comma;
|
|
|
|
}
|
clang-format: Format segments of builder-type calls one per line.
This fixes llvm.org/PR14818.
Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);
llvm-svn: 189353
2013-08-27 22:24:43 +08:00
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
bool isTrailingComment() const {
|
2014-08-26 17:37:52 +08:00
|
|
|
return is(tok::comment) &&
|
2014-11-25 18:05:17 +08:00
|
|
|
(is(TT_LineComment) || !Next || Next->NewlinesBefore > 0);
|
2013-06-04 00:45:03 +08:00
|
|
|
}
|
|
|
|
|
2014-08-06 22:15:41 +08:00
|
|
|
/// \brief Returns \c true if this is a keyword that can be used
|
|
|
|
/// like a function call (e.g. sizeof, typeid, ...).
|
|
|
|
bool isFunctionLikeKeyword() const {
|
|
|
|
switch (Tok.getKind()) {
|
|
|
|
case tok::kw_throw:
|
|
|
|
case tok::kw_typeid:
|
|
|
|
case tok::kw_return:
|
|
|
|
case tok::kw_sizeof:
|
|
|
|
case tok::kw_alignof:
|
|
|
|
case tok::kw_alignas:
|
|
|
|
case tok::kw_decltype:
|
|
|
|
case tok::kw_noexcept:
|
|
|
|
case tok::kw_static_assert:
|
|
|
|
case tok::kw___attribute:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
clang-format: Keep string-literal-label + value pairs on a line.
We have previously done that for <<-operators. This patch also adds
this logic for "," and "+".
Before:
string v = "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " +
aaaaaaaaaaaaaaaa + "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa;
string v = StrCat("aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ",
aaaaaaaaaaaaaaaa, "aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa);
After:
string v = "aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa +
"aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa +
"aaaaaaaaaaaaaaaa: " + aaaaaaaaaaaaaaaa;
string v = StrCat("aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa,
"aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa,
"aaaaaaaaaaaaaaaa: ", aaaaaaaaaaaaaaaa);
llvm-svn: 289531
2016-12-13 19:16:42 +08:00
|
|
|
/// \brief Returns \c true if this is a string literal that's like a label,
|
|
|
|
/// e.g. ends with "=" or ":".
|
|
|
|
bool isLabelString() const {
|
|
|
|
if (!is(tok::string_literal))
|
|
|
|
return false;
|
|
|
|
StringRef Content = TokenText;
|
|
|
|
if (Content.startswith("\"") || Content.startswith("'"))
|
|
|
|
Content = Content.drop_front(1);
|
|
|
|
if (Content.endswith("\"") || Content.endswith("'"))
|
|
|
|
Content = Content.drop_back(1);
|
|
|
|
Content = Content.trim();
|
|
|
|
return Content.size() > 1 &&
|
|
|
|
(Content.back() == ':' || Content.back() == '=');
|
|
|
|
}
|
|
|
|
|
2015-05-04 16:51:40 +08:00
|
|
|
/// \brief Returns actual token start location without leading escaped
|
|
|
|
/// newlines and whitespace.
|
|
|
|
///
|
|
|
|
/// This can be different to Tok.getLocation(), which includes leading escaped
|
|
|
|
/// newlines.
|
|
|
|
SourceLocation getStartOfNonWhitespace() const {
|
|
|
|
return WhitespaceRange.getEnd();
|
|
|
|
}
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
prec::Level getPrecedence() const {
|
|
|
|
return getBinOpPrecedence(Tok.getKind(), true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Returns the previous token ignoring comments.
|
2013-07-04 22:47:51 +08:00
|
|
|
FormatToken *getPreviousNonComment() const {
|
2013-06-04 00:45:03 +08:00
|
|
|
FormatToken *Tok = Previous;
|
2014-05-09 16:15:10 +08:00
|
|
|
while (Tok && Tok->is(tok::comment))
|
2013-06-04 00:45:03 +08:00
|
|
|
Tok = Tok->Previous;
|
|
|
|
return Tok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Returns the next token ignoring comments.
|
2013-07-04 22:47:51 +08:00
|
|
|
const FormatToken *getNextNonComment() const {
|
2013-06-04 00:45:03 +08:00
|
|
|
const FormatToken *Tok = Next;
|
2014-05-09 16:15:10 +08:00
|
|
|
while (Tok && Tok->is(tok::comment))
|
2013-06-04 00:45:03 +08:00
|
|
|
Tok = Tok->Next;
|
|
|
|
return Tok;
|
|
|
|
}
|
|
|
|
|
2013-10-22 23:45:58 +08:00
|
|
|
/// \brief Returns \c true if this tokens starts a block-type list, i.e. a
|
|
|
|
/// list that should be indented with a block indent.
|
2015-10-27 21:42:08 +08:00
|
|
|
bool opensBlockOrBlockTypeList(const FormatStyle &Style) const {
|
2017-02-20 22:51:16 +08:00
|
|
|
if (is(TT_TemplateString) && opensScope())
|
|
|
|
return true;
|
2014-11-25 18:05:17 +08:00
|
|
|
return is(TT_ArrayInitializerLSquare) ||
|
2014-12-12 17:40:58 +08:00
|
|
|
(is(tok::l_brace) &&
|
|
|
|
(BlockKind == BK_Block || is(TT_DictLiteral) ||
|
2017-06-27 21:43:07 +08:00
|
|
|
(!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||
|
2017-07-03 23:05:14 +08:00
|
|
|
(is(tok::less) && (Style.Language == FormatStyle::LK_Proto ||
|
|
|
|
Style.Language == FormatStyle::LK_TextProto));
|
2013-10-22 23:45:58 +08:00
|
|
|
}
|
|
|
|
|
2017-09-20 17:29:37 +08:00
|
|
|
/// \brief Returns whether the token is the left square bracket of a C++
|
|
|
|
/// structured binding declaration.
|
|
|
|
bool isCppStructuredBinding(const FormatStyle &Style) const {
|
|
|
|
if (!Style.isCpp() || isNot(tok::l_square))
|
|
|
|
return false;
|
2017-09-20 17:51:03 +08:00
|
|
|
const FormatToken *T = this;
|
2017-09-20 17:29:37 +08:00
|
|
|
do {
|
|
|
|
T = T->getPreviousNonComment();
|
|
|
|
} while (T && T->isOneOf(tok::kw_const, tok::kw_volatile, tok::amp,
|
|
|
|
tok::ampamp));
|
|
|
|
return T && T->is(tok::kw_auto);
|
|
|
|
}
|
|
|
|
|
2015-10-27 21:42:08 +08:00
|
|
|
/// \brief Same as opensBlockOrBlockTypeList, but for the closing token.
|
|
|
|
bool closesBlockOrBlockTypeList(const FormatStyle &Style) const {
|
2017-02-20 22:51:16 +08:00
|
|
|
if (is(TT_TemplateString) && closesScope())
|
|
|
|
return true;
|
2015-10-27 21:42:08 +08:00
|
|
|
return MatchingParen && MatchingParen->opensBlockOrBlockTypeList(Style);
|
2013-10-22 23:30:28 +08:00
|
|
|
}
|
|
|
|
|
clang-format: add options to merge empty record body
Summary:
This patch introduces a few extra BraceWrapping options, similar to
`SplitEmptyFunction`, to allow merging empty 'record' bodies (e.g.
class, struct, union and namespace):
* SplitEmptyClass
* SplitEmptyStruct
* SplitEmptyUnion
* SplitEmptyNamespace
The `SplitEmptyFunction` option name has also been simplified/
shortened (from `SplitEmptyFunctionBody`).
These options are helpful when the correspond AfterXXX option is
enabled, to allow merging the empty record:
class Foo
{};
In addition, this fixes an unexpected merging of short records, when
the AfterXXXX options are used, which caused to be formatted like
this:
class Foo
{ void Foo(); };
This is now properly formatted as:
class Foo
{
void Foo();
};
Reviewers: djasper, krasimir
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D34395
llvm-svn: 306874
2017-07-01 04:25:55 +08:00
|
|
|
/// \brief Return the actual namespace token, if this token starts a namespace
|
|
|
|
/// block.
|
|
|
|
const FormatToken *getNamespaceToken() const {
|
|
|
|
const FormatToken *NamespaceTok = this;
|
|
|
|
if (is(tok::comment))
|
|
|
|
NamespaceTok = NamespaceTok->getNextNonComment();
|
|
|
|
// Detect "(inline)? namespace" in the beginning of a line.
|
|
|
|
if (NamespaceTok && NamespaceTok->is(tok::kw_inline))
|
|
|
|
NamespaceTok = NamespaceTok->getNextNonComment();
|
|
|
|
return NamespaceTok && NamespaceTok->is(tok::kw_namespace) ? NamespaceTok
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
private:
|
|
|
|
// Disallow copying.
|
2015-02-16 06:54:08 +08:00
|
|
|
FormatToken(const FormatToken &) = delete;
|
|
|
|
void operator=(const FormatToken &) = delete;
|
2016-05-29 22:41:02 +08:00
|
|
|
|
|
|
|
template <typename A, typename... Ts>
|
|
|
|
bool startsSequenceInternal(A K1, Ts... Tokens) const {
|
|
|
|
if (is(tok::comment) && Next)
|
|
|
|
return Next->startsSequenceInternal(K1, Tokens...);
|
|
|
|
return is(K1) && Next && Next->startsSequenceInternal(Tokens...);
|
|
|
|
}
|
|
|
|
|
2017-09-20 17:51:03 +08:00
|
|
|
template <typename A> bool startsSequenceInternal(A K1) const {
|
2016-05-29 22:41:02 +08:00
|
|
|
if (is(tok::comment) && Next)
|
|
|
|
return Next->startsSequenceInternal(K1);
|
|
|
|
return is(K1);
|
|
|
|
}
|
|
|
|
|
2017-09-20 17:51:03 +08:00
|
|
|
template <typename A, typename... Ts> bool endsSequenceInternal(A K1) const {
|
2016-05-29 22:41:02 +08:00
|
|
|
if (is(tok::comment) && Previous)
|
|
|
|
return Previous->endsSequenceInternal(K1);
|
|
|
|
return is(K1);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename A, typename... Ts>
|
|
|
|
bool endsSequenceInternal(A K1, Ts... Tokens) const {
|
|
|
|
if (is(tok::comment) && Previous)
|
|
|
|
return Previous->endsSequenceInternal(K1, Tokens...);
|
|
|
|
return is(K1) && Previous && Previous->endsSequenceInternal(Tokens...);
|
|
|
|
}
|
2013-06-04 00:45:03 +08:00
|
|
|
};
|
|
|
|
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
class ContinuationIndenter;
|
|
|
|
struct LineState;
|
|
|
|
|
|
|
|
class TokenRole {
|
|
|
|
public:
|
|
|
|
TokenRole(const FormatStyle &Style) : Style(Style) {}
|
|
|
|
virtual ~TokenRole();
|
|
|
|
|
|
|
|
/// \brief After the \c TokenAnnotator has finished annotating all the tokens,
|
|
|
|
/// this function precomputes required information for formatting.
|
|
|
|
virtual void precomputeFormattingInfos(const FormatToken *Token);
|
|
|
|
|
|
|
|
/// \brief Apply the special formatting that the given role demands.
|
|
|
|
///
|
2014-01-09 21:42:56 +08:00
|
|
|
/// Assumes that the token having this role is already formatted.
|
|
|
|
///
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
/// Continues formatting from \p State leaving indentation to \p Indenter and
|
|
|
|
/// returns the total penalty that this formatting incurs.
|
2014-01-09 21:42:56 +08:00
|
|
|
virtual unsigned formatFromToken(LineState &State,
|
|
|
|
ContinuationIndenter *Indenter,
|
|
|
|
bool DryRun) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Same as \c formatFromToken, but assumes that the first token has
|
|
|
|
/// already been set thereby deciding on the first line break.
|
|
|
|
virtual unsigned formatAfterToken(LineState &State,
|
|
|
|
ContinuationIndenter *Indenter,
|
|
|
|
bool DryRun) {
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Notifies the \c Role that a comma was found.
|
|
|
|
virtual void CommaFound(const FormatToken *Token) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const FormatStyle &Style;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommaSeparatedList : public TokenRole {
|
|
|
|
public:
|
2014-01-09 21:42:56 +08:00
|
|
|
CommaSeparatedList(const FormatStyle &Style)
|
|
|
|
: TokenRole(Style), HasNestedBracedList(false) {}
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
2014-03-15 12:29:04 +08:00
|
|
|
void precomputeFormattingInfos(const FormatToken *Token) override;
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
2014-03-15 12:29:04 +08:00
|
|
|
unsigned formatAfterToken(LineState &State, ContinuationIndenter *Indenter,
|
|
|
|
bool DryRun) override;
|
2014-01-09 21:42:56 +08:00
|
|
|
|
2014-03-15 12:29:04 +08:00
|
|
|
unsigned formatFromToken(LineState &State, ContinuationIndenter *Indenter,
|
|
|
|
bool DryRun) override;
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
|
|
|
/// \brief Adds \p Token as the next comma to the \c CommaSeparated list.
|
2014-05-09 21:11:16 +08:00
|
|
|
void CommaFound(const FormatToken *Token) override {
|
|
|
|
Commas.push_back(Token);
|
|
|
|
}
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// \brief A struct that holds information on how to format a given list with
|
|
|
|
/// a specific number of columns.
|
|
|
|
struct ColumnFormat {
|
|
|
|
/// \brief The number of columns to use.
|
|
|
|
unsigned Columns;
|
|
|
|
|
|
|
|
/// \brief The total width in characters.
|
|
|
|
unsigned TotalWidth;
|
|
|
|
|
|
|
|
/// \brief The number of lines required for this format.
|
|
|
|
unsigned LineCount;
|
|
|
|
|
|
|
|
/// \brief The size of each column in characters.
|
|
|
|
SmallVector<unsigned, 8> ColumnSizes;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Calculate which \c ColumnFormat fits best into
|
|
|
|
/// \p RemainingCharacters.
|
|
|
|
const ColumnFormat *getColumnFormat(unsigned RemainingCharacters) const;
|
|
|
|
|
|
|
|
/// \brief The ordered \c FormatTokens making up the commas of this list.
|
|
|
|
SmallVector<const FormatToken *, 8> Commas;
|
|
|
|
|
|
|
|
/// \brief The length of each of the list's items in characters including the
|
|
|
|
/// trailing comma.
|
|
|
|
SmallVector<unsigned, 8> ItemLengths;
|
|
|
|
|
|
|
|
/// \brief Precomputed formats that can be used for this list.
|
|
|
|
SmallVector<ColumnFormat, 4> Formats;
|
2014-01-09 21:42:56 +08:00
|
|
|
|
|
|
|
bool HasNestedBracedList;
|
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:
static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};
Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).
Review: http://llvm-reviews.chandlerc.com/D1457
llvm-svn: 189018
2013-08-22 23:00:41 +08:00
|
|
|
};
|
|
|
|
|
2014-11-04 20:41:02 +08:00
|
|
|
/// \brief Encapsulates keywords that are context sensitive or for languages not
|
|
|
|
/// properly supported by Clang's lexer.
|
|
|
|
struct AdditionalKeywords {
|
|
|
|
AdditionalKeywords(IdentifierTable &IdentTable) {
|
2015-08-24 22:28:08 +08:00
|
|
|
kw_final = &IdentTable.get("final");
|
|
|
|
kw_override = &IdentTable.get("override");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_in = &IdentTable.get("in");
|
2016-02-11 21:24:15 +08:00
|
|
|
kw_of = &IdentTable.get("of");
|
2014-12-05 18:42:21 +08:00
|
|
|
kw_CF_ENUM = &IdentTable.get("CF_ENUM");
|
|
|
|
kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_NS_ENUM = &IdentTable.get("NS_ENUM");
|
2014-12-05 18:42:21 +08:00
|
|
|
kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
|
2014-11-04 20:41:02 +08:00
|
|
|
|
2016-05-20 19:24:24 +08:00
|
|
|
kw_as = &IdentTable.get("as");
|
2016-04-25 06:05:09 +08:00
|
|
|
kw_async = &IdentTable.get("async");
|
|
|
|
kw_await = &IdentTable.get("await");
|
2016-11-11 00:20:58 +08:00
|
|
|
kw_declare = &IdentTable.get("declare");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_finally = &IdentTable.get("finally");
|
2016-03-22 22:32:20 +08:00
|
|
|
kw_from = &IdentTable.get("from");
|
2016-04-25 06:05:09 +08:00
|
|
|
kw_function = &IdentTable.get("function");
|
2017-04-26 20:34:15 +08:00
|
|
|
kw_get = &IdentTable.get("get");
|
2015-02-20 00:07:32 +08:00
|
|
|
kw_import = &IdentTable.get("import");
|
2015-12-30 16:00:58 +08:00
|
|
|
kw_is = &IdentTable.get("is");
|
2015-09-28 22:28:08 +08:00
|
|
|
kw_let = &IdentTable.get("let");
|
2016-11-11 00:20:58 +08:00
|
|
|
kw_module = &IdentTable.get("module");
|
2017-07-07 21:17:10 +08:00
|
|
|
kw_readonly = &IdentTable.get("readonly");
|
2017-04-26 20:34:15 +08:00
|
|
|
kw_set = &IdentTable.get("set");
|
2016-06-24 03:52:32 +08:00
|
|
|
kw_type = &IdentTable.get("type");
|
2017-08-02 01:42:16 +08:00
|
|
|
kw_typeof = &IdentTable.get("typeof");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_var = &IdentTable.get("var");
|
2016-04-25 06:05:09 +08:00
|
|
|
kw_yield = &IdentTable.get("yield");
|
2014-11-04 20:41:02 +08:00
|
|
|
|
2014-11-21 20:19:07 +08:00
|
|
|
kw_abstract = &IdentTable.get("abstract");
|
2015-09-16 07:48:17 +08:00
|
|
|
kw_assert = &IdentTable.get("assert");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_extends = &IdentTable.get("extends");
|
|
|
|
kw_implements = &IdentTable.get("implements");
|
2014-11-25 18:05:17 +08:00
|
|
|
kw_instanceof = &IdentTable.get("instanceof");
|
2014-11-11 00:30:02 +08:00
|
|
|
kw_interface = &IdentTable.get("interface");
|
2015-01-14 06:32:50 +08:00
|
|
|
kw_native = &IdentTable.get("native");
|
2014-11-27 02:03:42 +08:00
|
|
|
kw_package = &IdentTable.get("package");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_synchronized = &IdentTable.get("synchronized");
|
|
|
|
kw_throws = &IdentTable.get("throws");
|
2015-02-04 23:26:27 +08:00
|
|
|
kw___except = &IdentTable.get("__except");
|
2017-02-11 03:36:52 +08:00
|
|
|
kw___has_include = &IdentTable.get("__has_include");
|
|
|
|
kw___has_include_next = &IdentTable.get("__has_include_next");
|
2014-11-04 20:41:02 +08:00
|
|
|
|
2015-04-22 17:45:42 +08:00
|
|
|
kw_mark = &IdentTable.get("mark");
|
|
|
|
|
2015-11-20 22:32:54 +08:00
|
|
|
kw_extend = &IdentTable.get("extend");
|
2014-11-04 20:41:02 +08:00
|
|
|
kw_option = &IdentTable.get("option");
|
|
|
|
kw_optional = &IdentTable.get("optional");
|
|
|
|
kw_repeated = &IdentTable.get("repeated");
|
|
|
|
kw_required = &IdentTable.get("required");
|
|
|
|
kw_returns = &IdentTable.get("returns");
|
2015-04-07 23:04:40 +08:00
|
|
|
|
|
|
|
kw_signals = &IdentTable.get("signals");
|
2015-12-01 20:05:04 +08:00
|
|
|
kw_qsignals = &IdentTable.get("Q_SIGNALS");
|
2015-04-07 23:04:40 +08:00
|
|
|
kw_slots = &IdentTable.get("slots");
|
|
|
|
kw_qslots = &IdentTable.get("Q_SLOTS");
|
2017-07-05 20:24:01 +08:00
|
|
|
|
|
|
|
// Keep this at the end of the constructor to make sure everything here is
|
|
|
|
// already initialized.
|
|
|
|
JsExtraKeywords = std::unordered_set<IdentifierInfo *>(
|
|
|
|
{kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,
|
2017-07-07 21:17:10 +08:00
|
|
|
kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly,
|
2017-08-02 01:42:16 +08:00
|
|
|
kw_set, kw_type, kw_typeof, kw_var, kw_yield,
|
2017-07-05 20:24:01 +08:00
|
|
|
// Keywords from the Java section.
|
|
|
|
kw_abstract, kw_extends, kw_implements, kw_instanceof, kw_interface});
|
2014-11-04 20:41:02 +08:00
|
|
|
}
|
|
|
|
|
2015-02-04 23:26:27 +08:00
|
|
|
// Context sensitive keywords.
|
2015-08-24 22:28:08 +08:00
|
|
|
IdentifierInfo *kw_final;
|
|
|
|
IdentifierInfo *kw_override;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_in;
|
2016-02-11 21:24:15 +08:00
|
|
|
IdentifierInfo *kw_of;
|
2014-12-05 18:42:21 +08:00
|
|
|
IdentifierInfo *kw_CF_ENUM;
|
|
|
|
IdentifierInfo *kw_CF_OPTIONS;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_NS_ENUM;
|
2014-12-05 18:42:21 +08:00
|
|
|
IdentifierInfo *kw_NS_OPTIONS;
|
2015-02-04 23:26:27 +08:00
|
|
|
IdentifierInfo *kw___except;
|
2017-02-11 03:36:52 +08:00
|
|
|
IdentifierInfo *kw___has_include;
|
|
|
|
IdentifierInfo *kw___has_include_next;
|
2014-11-04 20:41:02 +08:00
|
|
|
|
|
|
|
// JavaScript keywords.
|
2016-05-20 19:24:24 +08:00
|
|
|
IdentifierInfo *kw_as;
|
2016-04-25 06:05:09 +08:00
|
|
|
IdentifierInfo *kw_async;
|
|
|
|
IdentifierInfo *kw_await;
|
2016-11-11 00:20:58 +08:00
|
|
|
IdentifierInfo *kw_declare;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_finally;
|
2016-03-22 22:32:20 +08:00
|
|
|
IdentifierInfo *kw_from;
|
2016-04-25 06:05:09 +08:00
|
|
|
IdentifierInfo *kw_function;
|
2017-04-26 20:34:15 +08:00
|
|
|
IdentifierInfo *kw_get;
|
2015-02-20 00:07:32 +08:00
|
|
|
IdentifierInfo *kw_import;
|
2015-12-30 16:00:58 +08:00
|
|
|
IdentifierInfo *kw_is;
|
2015-09-28 22:28:08 +08:00
|
|
|
IdentifierInfo *kw_let;
|
2016-11-11 00:20:58 +08:00
|
|
|
IdentifierInfo *kw_module;
|
2017-07-07 21:17:10 +08:00
|
|
|
IdentifierInfo *kw_readonly;
|
2017-04-26 20:34:15 +08:00
|
|
|
IdentifierInfo *kw_set;
|
2016-06-24 03:52:32 +08:00
|
|
|
IdentifierInfo *kw_type;
|
2017-08-02 01:42:16 +08:00
|
|
|
IdentifierInfo *kw_typeof;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_var;
|
2016-04-25 06:05:09 +08:00
|
|
|
IdentifierInfo *kw_yield;
|
2014-11-04 20:41:02 +08:00
|
|
|
|
|
|
|
// Java keywords.
|
2014-11-21 20:19:07 +08:00
|
|
|
IdentifierInfo *kw_abstract;
|
2015-09-16 07:48:17 +08:00
|
|
|
IdentifierInfo *kw_assert;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_extends;
|
|
|
|
IdentifierInfo *kw_implements;
|
2014-11-25 18:05:17 +08:00
|
|
|
IdentifierInfo *kw_instanceof;
|
2014-11-11 00:30:02 +08:00
|
|
|
IdentifierInfo *kw_interface;
|
2015-01-14 06:32:50 +08:00
|
|
|
IdentifierInfo *kw_native;
|
2014-11-27 02:03:42 +08:00
|
|
|
IdentifierInfo *kw_package;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_synchronized;
|
|
|
|
IdentifierInfo *kw_throws;
|
|
|
|
|
2015-04-22 17:45:42 +08:00
|
|
|
// Pragma keywords.
|
|
|
|
IdentifierInfo *kw_mark;
|
|
|
|
|
2014-11-04 20:41:02 +08:00
|
|
|
// Proto keywords.
|
2015-11-20 22:32:54 +08:00
|
|
|
IdentifierInfo *kw_extend;
|
2014-11-04 20:41:02 +08:00
|
|
|
IdentifierInfo *kw_option;
|
|
|
|
IdentifierInfo *kw_optional;
|
|
|
|
IdentifierInfo *kw_repeated;
|
|
|
|
IdentifierInfo *kw_required;
|
|
|
|
IdentifierInfo *kw_returns;
|
2015-04-07 23:04:40 +08:00
|
|
|
|
|
|
|
// QT keywords.
|
|
|
|
IdentifierInfo *kw_signals;
|
2015-12-01 20:05:04 +08:00
|
|
|
IdentifierInfo *kw_qsignals;
|
2015-04-07 23:04:40 +08:00
|
|
|
IdentifierInfo *kw_slots;
|
|
|
|
IdentifierInfo *kw_qslots;
|
2017-07-04 23:30:21 +08:00
|
|
|
|
|
|
|
/// \brief Returns \c true if \p Tok is a true JavaScript identifier, returns
|
|
|
|
/// \c false if it is a keyword or a pseudo keyword.
|
|
|
|
bool IsJavaScriptIdentifier(const FormatToken &Tok) const {
|
|
|
|
return Tok.is(tok::identifier) &&
|
|
|
|
JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==
|
|
|
|
JsExtraKeywords.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// \brief The JavaScript keywords beyond the C++ keyword set.
|
|
|
|
std::unordered_set<IdentifierInfo *> JsExtraKeywords;
|
2014-11-04 20:41:02 +08:00
|
|
|
};
|
|
|
|
|
2013-06-04 00:45:03 +08:00
|
|
|
} // namespace format
|
|
|
|
} // namespace clang
|
|
|
|
|
2014-08-14 00:25:19 +08:00
|
|
|
#endif
|