forked from OSchip/llvm-project
Reformat clang-format's source files after r185822 and others.
llvm-svn: 185823
This commit is contained in:
parent
ee7539a387
commit
3ac9b9e258
|
@ -28,13 +28,13 @@ namespace format {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,9 +388,9 @@ BreakableBlockComment::replaceWhitespaceBefore(unsigned LineIndex,
|
|||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
/// 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
|
||||
|
|
|
@ -50,10 +50,10 @@ inline unsigned getCodePointCountUTF8(StringRef Text) {
|
|||
/// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,16 +61,14 @@ inline unsigned getCodePointCount(StringRef Text, Encoding Encoding) {
|
|||
/// 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') ||
|
||||
|
|
|
@ -271,9 +271,9 @@ public:
|
|||
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;
|
||||
|
@ -1289,9 +1289,9 @@ public:
|
|||
!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;
|
||||
|
|
|
@ -212,7 +212,6 @@ struct FormatToken {
|
|||
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 {
|
||||
|
|
|
@ -542,9 +542,9 @@ private:
|
|||
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(); }
|
||||
|
@ -625,8 +625,7 @@ private:
|
|||
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;
|
||||
|
@ -678,9 +677,9 @@ private:
|
|||
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 ||
|
||||
|
@ -952,9 +951,9 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
|
|||
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.
|
||||
|
|
|
@ -31,8 +31,7 @@ namespace format {
|
|||
/// \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.
|
||||
|
@ -49,8 +48,7 @@ struct UnwrappedLine {
|
|||
|
||||
class UnwrappedLineConsumer {
|
||||
public:
|
||||
virtual ~UnwrappedLineConsumer() {
|
||||
}
|
||||
virtual ~UnwrappedLineConsumer() {}
|
||||
virtual void consumeUnwrappedLine(const UnwrappedLine &Line) = 0;
|
||||
};
|
||||
|
||||
|
@ -163,8 +161,8 @@ private:
|
|||
// 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.
|
||||
|
|
|
@ -42,9 +42,9 @@ void WhitespaceManager::replaceWhitespace(const FormatToken &Tok,
|
|||
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,
|
||||
|
@ -94,10 +94,10 @@ void WhitespaceManager::calculateLineBreakInformation() {
|
|||
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;
|
||||
|
@ -242,8 +242,7 @@ void WhitespaceManager::storeReplacement(const SourceRange &Range,
|
|||
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));
|
||||
|
|
|
@ -75,11 +75,11 @@ private:
|
|||
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;
|
||||
};
|
||||
|
||||
|
@ -126,7 +126,6 @@ private:
|
|||
unsigned TokenLength;
|
||||
unsigned PreviousEndOfTokenColumn;
|
||||
unsigned EscapedNewlineColumn;
|
||||
|
||||
};
|
||||
|
||||
/// \brief Calculate \c IsTrailingComment, \c TokenLength for the last tokens
|
||||
|
|
Loading…
Reference in New Issue