]> granicus.if.org Git - clang/commitdiff
Reformat clang-format's source files after r185822 and others.
authorDaniel Jasper <djasper@google.com>
Mon, 8 Jul 2013 14:34:09 +0000 (14:34 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 8 Jul 2013 14:34:09 +0000 (14:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185823 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/BreakableToken.cpp
lib/Format/BreakableToken.h
lib/Format/Encoding.h
lib/Format/Format.cpp
lib/Format/FormatToken.h
lib/Format/TokenAnnotator.cpp
lib/Format/UnwrappedLineParser.h
lib/Format/WhitespaceManager.cpp
lib/Format/WhitespaceManager.h

index f01b481b844b56a50e9ef2803775cb1a55ad537b..816fd237bbac4f4ebf878ee5deade5a1ca5e7080 100644 (file)
@@ -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,
index afcc8b83a53e6118aa69b40dfe441160f9e6c302..90b78ac03a72ce6275e6cf84cac55066c0b78b01 100644 (file)
@@ -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
index a44f4590a24873034f23fa6df782a978f8c50135..e9e9ae71c791aa408178f075301cb8ba1591458a 100644 (file)
@@ -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') ||
index 0b0092d31f85e5cef2a88b9c06d25eedbddb064a..e4004a649b08557465b1c8cf8086a4733702e7a4 100644 (file)
@@ -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;
index 94425550b9ed1866b329e94a5e72ada51636977c..69afaac965d6b4a64c0c2271ab528c25bf2b1b52 100644 (file)
@@ -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 {
index 8db28635e88a1d683be104591a75126f1a58fc76..1bcdac8e21a3d34ba877bc02c1a4e54094cae42b 100644 (file)
@@ -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.
index 227b023a81b569d9775a7bc82891bb007f293efe..fb65078c330b3a20bdb10fdefeee757c38d7e39b 100644 (file)
@@ -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.
index 90f856bd117a8a387b5ce05b8ba89ad9f7416c1d..3805278de72cb20843886014aa44eb78c0506367 100644 (file)
@@ -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));
index 11167fa4c3cbc6a8f6be86cb8f29ddcbc0a393a3..9ca34806374d1744a26003247c4a809fc39c256e 100644 (file)
@@ -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