static const char *const Blanks = " \t\v\f";
static bool IsBlank(char C) {
switch (C) {
- case ' ':
- case '\t':
- case '\v':
- case '\f':
- return true;
- default:
- return false;
+ case ' ':
+ case '\t':
+ case '\v':
+ case '\f':
+ return true;
+ default:
+ return false;
}
}
}
}
- unsigned WhitespaceOffsetInToken =
- Lines[LineIndex].data() - Tok.TokenText.data() -
- LeadingWhitespace[LineIndex];
+ unsigned WhitespaceOffsetInToken = Lines[LineIndex].data() -
+ Tok.TokenText.data() -
+ LeadingWhitespace[LineIndex];
assert(StartOfLineColumn[LineIndex] >= Prefix.size());
Whitespaces.replaceWhitespaceInToken(
Tok, WhitespaceOffsetInToken, LeadingWhitespace[LineIndex], "", Prefix,
/// specified from the start of the (original) line.
/// \p Length can be set to StringRef::npos, which means "to the end of line".
virtual unsigned
- getLineLengthAfterSplit(unsigned LineIndex, unsigned Offset,
- StringRef::size_type Length) const = 0;
+ getLineLengthAfterSplit(unsigned LineIndex, unsigned Offset,
+ StringRef::size_type Length) const = 0;
/// \brief Returns a range (offset, length) at which to break the line at
/// \p LineIndex, if previously broken at \p TailOffset. If possible, do not
/// Encoding.
inline unsigned getCodePointCount(StringRef Text, Encoding Encoding) {
switch (Encoding) {
- case Encoding_UTF8:
- return getCodePointCountUTF8(Text);
- default:
- return Text.size();
+ case Encoding_UTF8:
+ return getCodePointCountUTF8(Text);
+ default:
+ return Text.size();
}
}
/// codepoint and starting with FirstChar in the specified Encoding.
inline unsigned getCodePointNumBytes(char FirstChar, Encoding Encoding) {
switch (Encoding) {
- case Encoding_UTF8:
- return getNumBytesForUTF8(FirstChar);
- default:
- return 1;
+ case Encoding_UTF8:
+ return getNumBytesForUTF8(FirstChar);
+ default:
+ return 1;
}
}
-inline bool isOctDigit(char c) {
- return '0' <= c && c <= '7';
-}
+inline bool isOctDigit(char c) { return '0' <= c && c <= '7'; }
inline bool isHexDigit(char c) {
return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') ||
LineState State;
State.Column = FirstIndent;
State.NextToken = RootToken;
- State.Stack.push_back(
- ParenState(FirstIndent, FirstIndent, /*AvoidBinPacking=*/false,
- /*NoLineBreak=*/false));
+ State.Stack.push_back(ParenState(FirstIndent, FirstIndent,
+ /*AvoidBinPacking=*/false,
+ /*NoLineBreak=*/false));
State.LineContainsContinuedForLoopSection = false;
State.ParenLevel = 0;
State.StartOfStringLiteral = 0;
!AnnotatedLines[i].First->Next)
AnnotatedLines[i].Level = NextNonCommentLine->Level;
else
- NextNonCommentLine =
- AnnotatedLines[i].First->isNot(tok::r_brace) ? &AnnotatedLines[i]
- : NULL;
+ NextNonCommentLine = AnnotatedLines[i].First->isNot(tok::r_brace)
+ ? &AnnotatedLines[i]
+ : NULL;
}
std::vector<int> IndentForLevel;
bool opensScope() const {
return isOneOf(tok::l_paren, tok::l_brace, tok::l_square) ||
Type == TT_TemplateOpener;
-
}
/// \brief Returns whether \p Tok is )]} or a template closing >.
bool closesScope() const {
ScopedContextCreator(AnnotatingParser &P, tok::TokenKind ContextKind,
unsigned Increase)
: P(P) {
- P.Contexts.push_back(
- Context(ContextKind, P.Contexts.back().BindingStrength + Increase,
- P.Contexts.back().IsExpression));
+ P.Contexts.push_back(Context(ContextKind,
+ P.Contexts.back().BindingStrength + Increase,
+ P.Contexts.back().IsExpression));
}
~ScopedContextCreator() { P.Contexts.pop_back(); }
if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf &&
Contexts.back().IsExpression)
IsCast = true;
- if (Current.Next &&
- Current.Next->isNot(tok::string_literal) &&
+ if (Current.Next && Current.Next->isNot(tok::string_literal) &&
(Current.Next->Tok.isLiteral() ||
Current.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof)))
IsCast = true;
if (PreviousNotConst == NULL)
return false;
- bool IsPPKeyword =
- PreviousNotConst->is(tok::identifier) && PreviousNotConst->Previous &&
- PreviousNotConst->Previous->is(tok::hash);
+ bool IsPPKeyword = PreviousNotConst->is(tok::identifier) &&
+ PreviousNotConst->Previous &&
+ PreviousNotConst->Previous->is(tok::hash);
return (!IsPPKeyword && PreviousNotConst->is(tok::identifier)) ||
PreviousNotConst->Type == TT_PointerOrReference ||
if (Current->MustBreakBefore)
Current->TotalLength = Current->Previous->TotalLength + Style.ColumnLimit;
else
- Current->TotalLength =
- Current->Previous->TotalLength + Current->CodePointCount +
- Current->SpacesRequiredBefore;
+ Current->TotalLength = Current->Previous->TotalLength +
+ Current->CodePointCount +
+ Current->SpacesRequiredBefore;
// FIXME: Only calculate this if CanBreakBefore is true once static
// initializers etc. are sorted out.
// FIXME: Move magic numbers to a better place.
/// \c UnwrappedLineFormatter. The key property is that changing the formatting
/// within an unwrapped line does not affect any other unwrapped lines.
struct UnwrappedLine {
- UnwrappedLine() : Level(0), InPPDirective(false), MustBeDeclaration(false) {
- }
+ UnwrappedLine() : Level(0), InPPDirective(false), MustBeDeclaration(false) {}
// FIXME: Don't use std::list here.
/// \brief The \c Tokens comprising this \c UnwrappedLine.
class UnwrappedLineConsumer {
public:
- virtual ~UnwrappedLineConsumer() {
- }
+ virtual ~UnwrappedLineConsumer() {}
virtual void consumeUnwrappedLine(const UnwrappedLine &Line) = 0;
};
// Represents preprocessor branch type, so we can find matching
// #if/#else/#endif directives.
enum PPBranchKind {
- PP_Conditional, // Any #if, #ifdef, #ifndef, #elif, block outside #if 0
- PP_Unreachable // #if 0 or a conditional preprocessor block inside #if 0
+ PP_Conditional, // Any #if, #ifdef, #ifndef, #elif, block outside #if 0
+ PP_Unreachable // #if 0 or a conditional preprocessor block inside #if 0
};
// Keeps a stack of currently active preprocessor branching directives.
unsigned Newlines, unsigned Spaces,
unsigned StartOfTokenColumn,
bool InPPDirective) {
- Changes.push_back(
- Change(true, Tok.WhitespaceRange, Spaces, StartOfTokenColumn, Newlines,
- "", "", Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst));
+ Changes.push_back(Change(true, Tok.WhitespaceRange, Spaces,
+ StartOfTokenColumn, Newlines, "", "",
+ Tok.Tok.getKind(), InPPDirective && !Tok.IsFirst));
}
void WhitespaceManager::addUntouchableToken(const FormatToken &Tok,
SourceMgr.getFileOffset(Changes[i].OriginalWhitespaceRange.getBegin());
unsigned PreviousOriginalWhitespaceEnd = SourceMgr.getFileOffset(
Changes[i - 1].OriginalWhitespaceRange.getEnd());
- Changes[i - 1].TokenLength =
- OriginalWhitespaceStart - PreviousOriginalWhitespaceEnd +
- Changes[i].PreviousLinePostfix.size() +
- Changes[i - 1].CurrentLinePrefix.size();
+ Changes[i - 1].TokenLength = OriginalWhitespaceStart -
+ PreviousOriginalWhitespaceEnd +
+ Changes[i].PreviousLinePostfix.size() +
+ Changes[i - 1].CurrentLinePrefix.size();
Changes[i].PreviousEndOfTokenColumn =
Changes[i - 1].StartOfTokenColumn + Changes[i - 1].TokenLength;
SourceMgr.getFileOffset(Range.getBegin());
// Don't create a replacement, if it does not change anything.
if (StringRef(SourceMgr.getCharacterData(Range.getBegin()),
- WhitespaceLength) ==
- Text)
+ WhitespaceLength) == Text)
return;
Replaces.insert(tooling::Replacement(
SourceMgr, CharSourceRange::getCharRange(Range), Text));
struct Change {
/// \brief Functor to sort changes in original source order.
class IsBeforeInFile {
- public:
+ public:
IsBeforeInFile(const SourceManager &SourceMgr) : SourceMgr(SourceMgr) {}
bool operator()(const Change &C1, const Change &C2) const;
- private:
+ private:
const SourceManager &SourceMgr;
};
unsigned TokenLength;
unsigned PreviousEndOfTokenColumn;
unsigned EscapedNewlineColumn;
-
};
/// \brief Calculate \c IsTrailingComment, \c TokenLength for the last tokens