r208392 - [C++11] Use 'nullptr'.

Daniel Jasper djasper at google.com
Fri May 9 06:19:19 PDT 2014


Fixed in r208409.


On Fri, May 9, 2014 at 1:37 PM, Daniel Jasper <djasper at google.com> wrote:

>
>
>
> On Fri, May 9, 2014 at 10:15 AM, Craig Topper <craig.topper at gmail.com>wrote:
>
>> Author: ctopper
>> Date: Fri May  9 03:15:10 2014
>> New Revision: 208392
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=208392&view=rev
>> Log:
>> [C++11] Use 'nullptr'.
>>
>> Modified:
>>     cfe/trunk/lib/Edit/EditedSource.cpp
>>     cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
>>     cfe/trunk/lib/Format/ContinuationIndenter.cpp
>>     cfe/trunk/lib/Format/Format.cpp
>>     cfe/trunk/lib/Format/FormatToken.cpp
>>     cfe/trunk/lib/Format/FormatToken.h
>>     cfe/trunk/lib/Format/TokenAnnotator.cpp
>>     cfe/trunk/lib/Format/TokenAnnotator.h
>>     cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>>     cfe/trunk/lib/Format/UnwrappedLineParser.h
>>
>> Modified: cfe/trunk/lib/Edit/EditedSource.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/EditedSource.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Edit/EditedSource.cpp (original)
>> +++ cfe/trunk/lib/Edit/EditedSource.cpp Fri May  9 03:15:10 2014
>> @@ -158,7 +158,7 @@ void EditedSource::commitRemove(SourceLo
>>    }
>>
>>    FileOffset TopBegin, TopEnd;
>> -  FileEdit *TopFA = 0;
>> +  FileEdit *TopFA = nullptr;
>>
>>    if (I == FileEdits.end()) {
>>      FileEditsTy::iterator
>>
>> Modified: cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp (original)
>> +++ cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp Fri May  9 03:15:10
>> 2014
>> @@ -58,7 +58,7 @@ static bool checkForLiteralCreation(cons
>>
>>  bool edit::rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr
>> *Msg,
>>                                                const NSAPI &NS, Commit
>> &commit) {
>> -  IdentifierInfo *II = 0;
>> +  IdentifierInfo *II = nullptr;
>>    if (!checkForLiteralCreation(Msg, II,
>> NS.getASTContext().getLangOpts()))
>>      return false;
>>    if (Msg->getNumArgs() != 1)
>> @@ -339,7 +339,7 @@ static bool rewriteToStringBoxedExpressi
>>  bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
>>                                        const NSAPI &NS, Commit &commit,
>>                                        const ParentMap *PMap) {
>> -  IdentifierInfo *II = 0;
>> +  IdentifierInfo *II = nullptr;
>>    if (!checkForLiteralCreation(Msg, II,
>> NS.getASTContext().getLangOpts()))
>>      return false;
>>
>> @@ -447,7 +447,7 @@ static bool getNSArrayObjects(const Expr
>>      return false;
>>
>>    if (const ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E)) {
>> -    IdentifierInfo *Cls = 0;
>> +    IdentifierInfo *Cls = nullptr;
>>      if (!checkForLiteralCreation(Msg, Cls,
>> NS.getASTContext().getLangOpts()))
>>        return false;
>>
>> @@ -606,7 +606,7 @@ static bool shouldNotRewriteImmediateMes
>>    if (!Msg)
>>      return false;
>>
>> -  IdentifierInfo *II = 0;
>> +  IdentifierInfo *II = nullptr;
>>    if (!checkForLiteralCreation(Msg, II,
>> NS.getASTContext().getLangOpts()))
>>      return false;
>>
>>
>> Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
>> +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri May  9 03:15:10 2014
>> @@ -29,7 +29,7 @@ namespace format {
>>  // Returns the length of everything up to the first possible line break
>> after
>>  // the ), ], } or > matching \c Tok.
>>  static unsigned getLengthToMatchingParen(const FormatToken &Tok) {
>> -  if (Tok.MatchingParen == NULL)
>> +  if (!Tok.MatchingParen)
>>      return 0;
>>    FormatToken *End = Tok.MatchingParen;
>>    while (End->Next && !End->Next->CanBreakBefore) {
>> @@ -220,7 +220,7 @@ unsigned ContinuationIndenter::addTokenT
>>
>>    assert(!State.Stack.empty());
>>    if ((Current.Type == TT_ImplicitStringLiteral &&
>> -       (Current.Previous->Tok.getIdentifierInfo() == NULL ||
>> +       (Current.Previous->Tok.getIdentifierInfo() == nullptr ||
>>          Current.Previous->Tok.getIdentifierInfo()->getPPKeywordID() ==
>>              tok::pp_not_keyword))) {
>>      // FIXME: Is this correct?
>> @@ -916,7 +916,7 @@ unsigned ContinuationIndenter::breakProt
>>          Current, State.Line->Level, StartColumn, Current.OriginalColumn,
>>          !Current.Previous, State.Line->InPPDirective, Encoding, Style));
>>    } else if (Current.Type == TT_LineComment &&
>> -             (Current.Previous == NULL ||
>> +             (Current.Previous == nullptr ||
>>                Current.Previous->Type != TT_ImplicitStringLiteral)) {
>>      if (CommentPragmasRegex.match(Current.TokenText.substr(2)))
>>        return 0;
>>
>> Modified: cfe/trunk/lib/Format/Format.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/Format.cpp (original)
>> +++ cfe/trunk/lib/Format/Format.cpp Fri May  9 03:15:10 2014
>> @@ -495,7 +495,7 @@ public:
>>    void format(unsigned FirstIndent, const AnnotatedLine *Line) {
>>      LineState State =
>>          Indenter->getInitialState(FirstIndent, Line, /*DryRun=*/false);
>> -    while (State.NextToken != NULL) {
>> +    while (State.NextToken) {
>>        bool Newline =
>>            Indenter->mustBreak(State) ||
>>            (Indenter->canBreak(State) && State.NextToken->NewlinesBefore
>> > 0);
>> @@ -647,7 +647,7 @@ private:
>>
>>      FormatToken *Tok = I[1]->First;
>>      if (Tok->is(tok::r_brace) && !Tok->MustBreakBefore &&
>> -        (Tok->getNextNonComment() == NULL ||
>> +        (Tok->getNextNonComment() == nullptr ||
>>           Tok->getNextNonComment()->is(tok::semi))) {
>>        // We merge empty blocks even if the line exceeds the column limit.
>>        Tok->SpacesRequiredBefore = 0;
>> @@ -674,7 +674,7 @@ private:
>>          if (Tok->isOneOf(tok::l_brace, tok::r_brace))
>>            return 0;
>>          Tok = Tok->Next;
>> -      } while (Tok != NULL);
>> +      } while (Tok);
>>
>>        // Last, check that the third line starts with a closing brace.
>>        Tok = I[2]->First;
>> @@ -739,7 +739,7 @@ public:
>>      std::vector<int> IndentForLevel;
>>      for (unsigned i = 0, e = Lines[0]->Level; i != e; ++i)
>>        IndentForLevel.push_back(Style.IndentWidth * i + AdditionalIndent);
>> -    const AnnotatedLine *PreviousLine = NULL;
>> +    const AnnotatedLine *PreviousLine = nullptr;
>>      for (SmallVectorImpl<AnnotatedLine *>::const_iterator I =
>> Lines.begin(),
>>                                                            E =
>> Lines.end();
>>           I != E; ++I) {
>> @@ -808,7 +808,7 @@ public:
>>
>>          if (TheLine.Last->TotalLength + Indent <= ColumnLimit) {
>>            LineState State = Indenter->getInitialState(Indent, &TheLine,
>> DryRun);
>> -          while (State.NextToken != NULL)
>> +          while (State.NextToken)
>>              Indenter->addTokenToState(State, /*Newline=*/false, DryRun);
>>          } else if (Style.ColumnLimit == 0) {
>>            // FIXME: Implement nested blocks for ColumnLimit = 0.
>> @@ -826,7 +826,7 @@ public:
>>        } else {
>>          // Format the first token if necessary, and notify the
>> WhitespaceManager
>>          // about the unchanged whitespace.
>> -        for (FormatToken *Tok = TheLine.First; Tok != NULL; Tok =
>> Tok->Next) {
>> +        for (FormatToken *Tok = TheLine.First; Tok; Tok = Tok->Next) {
>>            if (Tok == TheLine.First &&
>>                (Tok->NewlinesBefore > 0 || Tok->IsFirst)) {
>>              unsigned LevelIndent = Tok->OriginalColumn;
>> @@ -851,7 +851,7 @@ public:
>>          }
>>        }
>>        if (!DryRun) {
>> -        for (FormatToken *Tok = TheLine.First; Tok != NULL; Tok =
>> Tok->Next) {
>> +        for (FormatToken *Tok = TheLine.First; Tok; Tok = Tok->Next) {
>>            Tok->Finalized = true;
>>          }
>>        }
>> @@ -1001,7 +1001,7 @@ private:
>>
>>      // Insert start element into queue.
>>      StateNode *Node =
>> -        new (Allocator.Allocate()) StateNode(InitialState, false, NULL);
>> +        new (Allocator.Allocate()) StateNode(InitialState, false,
>> nullptr);
>>      Queue.push(QueueItem(OrderedPenalty(0, Count), Node));
>>      ++Count;
>>
>> @@ -1011,7 +1011,7 @@ private:
>>      while (!Queue.empty()) {
>>        Penalty = Queue.top().first.first;
>>        StateNode *Node = Queue.top().second;
>> -      if (Node->State.NextToken == NULL) {
>> +      if (!Node->State.NextToken) {
>>          DEBUG(llvm::dbgs() << "\n---\nPenalty for line: " << Penalty <<
>> "\n");
>>          break;
>>        }
>> @@ -1182,9 +1182,9 @@ class FormatTokenLexer {
>>  public:
>>    FormatTokenLexer(Lexer &Lex, SourceManager &SourceMgr, FormatStyle
>> &Style,
>>                     encoding::Encoding Encoding)
>> -      : FormatTok(NULL), IsFirstToken(true), GreaterStashed(false),
>> Column(0),
>> -        TrailingWhitespace(0), Lex(Lex), SourceMgr(SourceMgr),
>> Style(Style),
>> -        IdentTable(getFormattingLangOpts()), Encoding(Encoding),
>> +      : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
>> +        Column(0), TrailingWhitespace(0), Lex(Lex), SourceMgr(SourceMgr),
>> +        Style(Style), IdentTable(getFormattingLangOpts()),
>> Encoding(Encoding),
>>
>
> Please revert this back to a clang-format-clean indentation.
>
>
>>          FirstInLineIndex(0) {
>>      Lex.SetKeepWhitespaceMode(true);
>>
>> @@ -1643,7 +1643,7 @@ private:
>>    bool computeAffectedLines(SmallVectorImpl<AnnotatedLine *>::iterator I,
>>                              SmallVectorImpl<AnnotatedLine *>::iterator
>> E) {
>>      bool SomeLineAffected = false;
>> -    const AnnotatedLine *PreviousLine = NULL;
>> +    const AnnotatedLine *PreviousLine = nullptr;
>>      while (I != E) {
>>        AnnotatedLine *Line = *I;
>>        Line->LeadingEmptyLinesAffected =
>> affectsLeadingEmptyLines(*Line->First);
>> @@ -1714,8 +1714,9 @@ private:
>>                       Line->First->NewlinesBefore == 0;
>>
>>      bool IsContinuedComment = Line->First->is(tok::comment) &&
>> -                              Line->First->Next == NULL &&
>> -                              Line->First->NewlinesBefore < 2 &&
>> PreviousLine &&
>> +                              Line->First->Next == nullptr &&
>> +                              Line->First->NewlinesBefore < 2 &&
>> +                              PreviousLine &&
>>                                PreviousLine->Affected &&
>>                                PreviousLine->Last->is(tok::comment);
>>
>>
>> Modified: cfe/trunk/lib/Format/FormatToken.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/FormatToken.cpp (original)
>> +++ cfe/trunk/lib/Format/FormatToken.cpp Fri May  9 03:15:10 2014
>> @@ -152,7 +152,7 @@ void CommaSeparatedList::precomputeForma
>>      MustBreakBeforeItem.push_back(ItemBegin->MustBreakBefore);
>>      if (ItemBegin->is(tok::l_brace))
>>        HasNestedBracedList = true;
>> -    const FormatToken *ItemEnd = NULL;
>> +    const FormatToken *ItemEnd = nullptr;
>>      if (i == Commas.size()) {
>>        ItemEnd = Token->MatchingParen;
>>        const FormatToken *NonCommentEnd =
>> ItemEnd->getPreviousNonComment();
>> @@ -232,7 +232,7 @@ void CommaSeparatedList::precomputeForma
>>
>>  const CommaSeparatedList::ColumnFormat *
>>  CommaSeparatedList::getColumnFormat(unsigned RemainingCharacters) const {
>> -  const ColumnFormat *BestFormat = NULL;
>> +  const ColumnFormat *BestFormat = nullptr;
>>    for (SmallVector<ColumnFormat, 4>::const_reverse_iterator
>>             I = Formats.rbegin(),
>>             E = Formats.rend();
>>
>> Modified: cfe/trunk/lib/Format/FormatToken.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/FormatToken.h (original)
>> +++ cfe/trunk/lib/Format/FormatToken.h Fri May  9 03:15:10 2014
>> @@ -109,7 +109,7 @@ struct FormatToken {
>>          StartsBinaryExpression(false), EndsBinaryExpression(false),
>>          OperatorIndex(0), LastOperator(false),
>>          PartOfMultiVariableDeclStmt(false), IsForEachMacro(false),
>> -        MatchingParen(NULL), Previous(NULL), Next(NULL),
>> +        MatchingParen(nullptr), Previous(nullptr), Next(nullptr),
>>          Decision(FD_Unformatted), Finalized(false) {}
>>
>>    /// \brief The \c Token.
>> @@ -354,7 +354,7 @@ struct FormatToken {
>>    /// \brief Returns the previous token ignoring comments.
>>    FormatToken *getPreviousNonComment() const {
>>      FormatToken *Tok = Previous;
>> -    while (Tok != NULL && Tok->is(tok::comment))
>> +    while (Tok && Tok->is(tok::comment))
>>        Tok = Tok->Previous;
>>      return Tok;
>>    }
>> @@ -362,7 +362,7 @@ struct FormatToken {
>>    /// \brief Returns the next token ignoring comments.
>>    const FormatToken *getNextNonComment() const {
>>      const FormatToken *Tok = Next;
>> -    while (Tok != NULL && Tok->is(tok::comment))
>> +    while (Tok && Tok->is(tok::comment))
>>        Tok = Tok->Next;
>>      return Tok;
>>    }
>>
>> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
>> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri May  9 03:15:10 2014
>> @@ -41,7 +41,7 @@ public:
>>
>>  private:
>>    bool parseAngle() {
>> -    if (CurrentToken == NULL)
>> +    if (!CurrentToken)
>>        return false;
>>      ScopedContextCreator ContextCreator(*this, tok::less, 10);
>>      FormatToken *Left = CurrentToken->Previous;
>> @@ -49,9 +49,9 @@ private:
>>      // If there's a template keyword before the opening angle bracket,
>> this is a
>>      // template parameter, not an argument.
>>      Contexts.back().InTemplateArgument =
>> -        Left->Previous != NULL &&
>> Left->Previous->Tok.isNot(tok::kw_template);
>> +        Left->Previous && Left->Previous->Tok.isNot(tok::kw_template);
>>
>> -    while (CurrentToken != NULL) {
>> +    while (CurrentToken) {
>>        if (CurrentToken->is(tok::greater)) {
>>          Left->MatchingParen = CurrentToken;
>>          CurrentToken->MatchingParen = Left;
>> @@ -85,7 +85,7 @@ private:
>>    }
>>
>>    bool parseParens(bool LookForDecls = false) {
>> -    if (CurrentToken == NULL)
>> +    if (!CurrentToken)
>>        return false;
>>      ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
>>
>> @@ -141,7 +141,7 @@ private:
>>      bool MightBeFunctionType = CurrentToken->is(tok::star);
>>      bool HasMultipleLines = false;
>>      bool HasMultipleParametersOnALine = false;
>> -    while (CurrentToken != NULL) {
>> +    while (CurrentToken) {
>>        // LookForDecls is set when "if (" has been seen. Check for
>>        // 'identifier' '*' 'identifier' followed by not '=' -- this
>>        // '*' has to be a binary operator but determineStarAmpUsage() will
>> @@ -175,7 +175,7 @@ private:
>>
>>          if (StartsObjCMethodExpr) {
>>            CurrentToken->Type = TT_ObjCMethodExpr;
>> -          if (Contexts.back().FirstObjCSelectorName != NULL) {
>> +          if (Contexts.back().FirstObjCSelectorName) {
>>
>>  Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
>>                  Contexts.back().LongestObjCSelectorName;
>>            }
>> @@ -243,7 +243,7 @@ private:
>>        Left->Type = TT_ArraySubscriptLSquare;
>>      }
>>
>> -    while (CurrentToken != NULL) {
>> +    while (CurrentToken) {
>>        if (CurrentToken->is(tok::r_square)) {
>>          if (CurrentToken->Next && CurrentToken->Next->is(tok::l_paren) &&
>>              Left->Type == TT_ObjCMethodExpr) {
>> @@ -257,12 +257,12 @@ private:
>>            // determineStarAmpUsage() thinks that '*' '[' is allocating an
>>            // array of pointers, but if '[' starts a selector then '*' is
>> a
>>            // binary operator.
>> -          if (Parent != NULL && Parent->Type == TT_PointerOrReference)
>> +          if (Parent && Parent->Type == TT_PointerOrReference)
>>              Parent->Type = TT_BinaryOperator;
>>          }
>>          Left->MatchingParen = CurrentToken;
>>          CurrentToken->MatchingParen = Left;
>> -        if (Contexts.back().FirstObjCSelectorName != NULL) {
>> +        if (Contexts.back().FirstObjCSelectorName) {
>>            Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName
>> =
>>                Contexts.back().LongestObjCSelectorName;
>>            if (Contexts.back().NumBlockParameters > 1)
>> @@ -288,7 +288,7 @@ private:
>>    }
>>
>>    bool parseBrace() {
>> -    if (CurrentToken != NULL) {
>> +    if (CurrentToken) {
>>        FormatToken *Left = CurrentToken->Previous;
>>
>>        if (Contexts.back().CaretFound)
>> @@ -298,7 +298,7 @@ private:
>>        ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);
>>        Contexts.back().ColonIsDictLiteral = true;
>>
>> -      while (CurrentToken != NULL) {
>> +      while (CurrentToken) {
>>          if (CurrentToken->is(tok::r_brace)) {
>>            Left->MatchingParen = CurrentToken;
>>            CurrentToken->MatchingParen = Left;
>> @@ -332,7 +332,7 @@ private:
>>    }
>>
>>    bool parseConditional() {
>> -    while (CurrentToken != NULL) {
>> +    while (CurrentToken) {
>>        if (CurrentToken->is(tok::colon)) {
>>          CurrentToken->Type = TT_ConditionalExpr;
>>          next();
>> @@ -345,12 +345,12 @@ private:
>>    }
>>
>>    bool parseTemplateDeclaration() {
>> -    if (CurrentToken != NULL && CurrentToken->is(tok::less)) {
>> +    if (CurrentToken && CurrentToken->is(tok::less)) {
>>        CurrentToken->Type = TT_TemplateOpener;
>>        next();
>>        if (!parseAngle())
>>          return false;
>> -      if (CurrentToken != NULL)
>> +      if (CurrentToken)
>>          CurrentToken->Previous->ClosesTemplateDeclaration = true;
>>        return true;
>>      }
>> @@ -363,11 +363,11 @@ private:
>>      switch (Tok->Tok.getKind()) {
>>      case tok::plus:
>>      case tok::minus:
>> -      if (Tok->Previous == NULL && Line.MustBeDeclaration)
>> +      if (!Tok->Previous && Line.MustBeDeclaration)
>>          Tok->Type = TT_ObjCMethodSpecifier;
>>        break;
>>      case tok::colon:
>> -      if (Tok->Previous == NULL)
>> +      if (!Tok->Previous)
>>          return false;
>>        // Colons from ?: are handled in parseConditional().
>>        if (Tok->Previous->is(tok::r_paren) && Contexts.size() == 1 &&
>> @@ -383,11 +383,11 @@ private:
>>              Contexts.back().LongestObjCSelectorName) {
>>            Contexts.back().LongestObjCSelectorName =
>> Tok->Previous->ColumnWidth;
>>          }
>> -        if (Contexts.back().FirstObjCSelectorName == NULL)
>> +        if (!Contexts.back().FirstObjCSelectorName)
>>            Contexts.back().FirstObjCSelectorName = Tok->Previous;
>>        } else if (Contexts.back().ColonIsForRangeExpr) {
>>          Tok->Type = TT_RangeBasedForLoopColon;
>> -      } else if (CurrentToken != NULL &&
>> +      } else if (CurrentToken &&
>>                   CurrentToken->is(tok::numeric_constant)) {
>>          Tok->Type = TT_BitFieldColon;
>>        } else if (Contexts.size() == 1 &&
>> Line.First->isNot(tok::kw_enum)) {
>> @@ -398,7 +398,7 @@ private:
>>        break;
>>      case tok::kw_if:
>>      case tok::kw_while:
>> -      if (CurrentToken != NULL && CurrentToken->is(tok::l_paren)) {
>> +      if (CurrentToken && CurrentToken->is(tok::l_paren)) {
>>          next();
>>          if (!parseParens(/*LookForDecls=*/true))
>>            return false;
>> @@ -441,7 +441,7 @@ private:
>>        return false;
>>      case tok::r_brace:
>>        // Lines can start with '}'.
>> -      if (Tok->Previous != NULL)
>> +      if (Tok->Previous)
>>          return false;
>>        break;
>>      case tok::greater:
>> @@ -489,15 +489,15 @@ private:
>>
>>    void parseIncludeDirective() {
>>      next();
>> -    if (CurrentToken != NULL && CurrentToken->is(tok::less)) {
>> +    if (CurrentToken && CurrentToken->is(tok::less)) {
>>        next();
>> -      while (CurrentToken != NULL) {
>> +      while (CurrentToken) {
>>          if (CurrentToken->isNot(tok::comment) || CurrentToken->Next)
>>            CurrentToken->Type = TT_ImplicitStringLiteral;
>>          next();
>>        }
>>      } else {
>> -      while (CurrentToken != NULL) {
>> +      while (CurrentToken) {
>>          if (CurrentToken->is(tok::string_literal))
>>            // Mark these string literals as "implicit" literals, too, so
>> that
>>            // they are not split or line-wrapped.
>> @@ -512,7 +512,7 @@ private:
>>      // We still want to format the whitespace left of the first token of
>> the
>>      // warning or error.
>>      next();
>> -    while (CurrentToken != NULL) {
>> +    while (CurrentToken) {
>>        CurrentToken->Type = TT_ImplicitStringLiteral;
>>        next();
>>      }
>> @@ -523,7 +523,7 @@ private:
>>      if (CurrentToken && CurrentToken->TokenText == "mark") {
>>        next(); // Consume "mark".
>>        next(); // Consume first token (so we fix leading whitespace).
>> -      while (CurrentToken != NULL) {
>> +      while (CurrentToken) {
>>          CurrentToken->Type = TT_ImplicitStringLiteral;
>>          next();
>>        }
>> @@ -532,7 +532,7 @@ private:
>>
>>    void parsePreprocessorDirective() {
>>      next();
>> -    if (CurrentToken == NULL)
>> +    if (!CurrentToken)
>>        return;
>>      if (CurrentToken->Tok.is(tok::numeric_constant)) {
>>        CurrentToken->SpacesRequiredBefore = 1;
>> @@ -540,7 +540,7 @@ private:
>>      }
>>      // Hashes in the middle of a line can lead to any strange token
>>      // sequence.
>> -    if (CurrentToken->Tok.getIdentifierInfo() == NULL)
>> +    if (!CurrentToken->Tok.getIdentifierInfo())
>>        return;
>>      switch (CurrentToken->Tok.getIdentifierInfo()->getPPKeywordID()) {
>>      case tok::pp_include:
>> @@ -562,7 +562,7 @@ private:
>>      default:
>>        break;
>>      }
>> -    while (CurrentToken != NULL)
>> +    while (CurrentToken)
>>        next();
>>    }
>>
>> @@ -581,7 +581,7 @@ public:
>>          CurrentToken->Next &&
>> CurrentToken->Next->is(tok::string_literal))
>>        parseIncludeDirective();
>>
>> -    while (CurrentToken != NULL) {
>> +    while (CurrentToken) {
>>        if (CurrentToken->is(tok::kw_virtual))
>>          KeywordVirtualFound = true;
>>        if (!consumeToken())
>> @@ -591,7 +591,7 @@ public:
>>        return LT_VirtualFunctionDecl;
>>
>>      if (Line.First->Type == TT_ObjCMethodSpecifier) {
>> -      if (Contexts.back().FirstObjCSelectorName != NULL)
>> +      if (Contexts.back().FirstObjCSelectorName)
>>          Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
>>              Contexts.back().LongestObjCSelectorName;
>>        return LT_ObjCMethodDecl;
>> @@ -602,7 +602,7 @@ public:
>>
>>  private:
>>    void resetTokenMetadata(FormatToken *Token) {
>> -    if (Token == nullptr) return;
>> +    if (!Token) return;
>>
>>      // Reset token type in case we have already looked at it and then
>>      // recovered from an error (e.g. failure to find the matching >).
>> @@ -613,13 +613,13 @@ private:
>>          CurrentToken->Type != TT_TrailingReturnArrow)
>>        CurrentToken->Type = TT_Unknown;
>>      if (CurrentToken->Role)
>> -      CurrentToken->Role.reset(NULL);
>> +      CurrentToken->Role.reset(nullptr);
>>      CurrentToken->FakeLParens.clear();
>>      CurrentToken->FakeRParens = 0;
>>    }
>>
>>    void next() {
>> -    if (CurrentToken != NULL) {
>> +    if (CurrentToken) {
>>        determineTokenType(*CurrentToken);
>>        CurrentToken->BindingStrength = Contexts.back().BindingStrength;
>>        CurrentToken->NestingLevel = Contexts.size() - 1;
>> @@ -637,8 +637,8 @@ private:
>>          : ContextKind(ContextKind), BindingStrength(BindingStrength),
>>            LongestObjCSelectorName(0), NumBlockParameters(0),
>>            ColonIsForRangeExpr(false), ColonIsDictLiteral(false),
>> -          ColonIsObjCMethodExpr(false), FirstObjCSelectorName(NULL),
>> -          FirstStartOfName(NULL), IsExpression(IsExpression),
>> +          ColonIsObjCMethodExpr(false), FirstObjCSelectorName(nullptr),
>> +          FirstStartOfName(nullptr), IsExpression(IsExpression),
>>            CanBeExpression(true), InTemplateArgument(false),
>>            InCtorInitializer(false), CaretFound(false),
>> IsForEachMacro(false) {}
>>
>> @@ -794,15 +794,15 @@ private:
>>    /// This is a heuristic based on whether \p Tok is an identifier
>> following
>>    /// something that is likely a type.
>>    bool isStartOfName(const FormatToken &Tok) {
>> -    if (Tok.isNot(tok::identifier) || Tok.Previous == NULL)
>> +    if (Tok.isNot(tok::identifier) || !Tok.Previous)
>>        return false;
>>
>>      // Skip "const" as it does not have an influence on whether this is
>> a name.
>>      FormatToken *PreviousNotConst = Tok.Previous;
>> -    while (PreviousNotConst != NULL &&
>> PreviousNotConst->is(tok::kw_const))
>> +    while (PreviousNotConst && PreviousNotConst->is(tok::kw_const))
>>        PreviousNotConst = PreviousNotConst->Previous;
>>
>> -    if (PreviousNotConst == NULL)
>> +    if (!PreviousNotConst)
>>        return false;
>>
>>      bool IsPPKeyword = PreviousNotConst->is(tok::identifier) &&
>> @@ -885,11 +885,11 @@ private:
>>    TokenType determineStarAmpUsage(const FormatToken &Tok, bool
>> IsExpression,
>>                                    bool InTemplateArgument) {
>>      const FormatToken *PrevToken = Tok.getPreviousNonComment();
>> -    if (PrevToken == NULL)
>> +    if (!PrevToken)
>>        return TT_UnaryOperator;
>>
>>      const FormatToken *NextToken = Tok.getNextNonComment();
>> -    if (NextToken == NULL)
>> +    if (!NextToken)
>>        return TT_Unknown;
>>
>>      if (PrevToken->is(tok::coloncolon) ||
>> @@ -934,7 +934,7 @@ private:
>>
>>    TokenType determinePlusMinusCaretUsage(const FormatToken &Tok) {
>>      const FormatToken *PrevToken = Tok.getPreviousNonComment();
>> -    if (PrevToken == NULL || PrevToken->Type == TT_CastRParen)
>> +    if (!PrevToken || PrevToken->Type == TT_CastRParen)
>>        return TT_UnaryOperator;
>>
>>      // Use heuristics to recognize unary operators.
>> @@ -954,7 +954,7 @@ private:
>>    /// \brief Determine whether ++/-- are pre- or
>> post-increments/-decrements.
>>    TokenType determineIncrementUsage(const FormatToken &Tok) {
>>      const FormatToken *PrevToken = Tok.getPreviousNonComment();
>> -    if (PrevToken == NULL || PrevToken->Type == TT_CastRParen)
>> +    if (!PrevToken || PrevToken->Type == TT_CastRParen)
>>        return TT_UnaryOperator;
>>      if (PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::identifier))
>>        return TT_TrailingUnaryOperator;
>> @@ -995,7 +995,7 @@ public:
>>              (Current->is(tok::colon) && Current->Type ==
>> TT_ObjCMethodExpr)))
>>        next();
>>
>> -    if (Current == NULL || Precedence > PrecedenceArrowAndPeriod)
>> +    if (!Current || Precedence > PrecedenceArrowAndPeriod)
>>        return;
>>
>>      // Conditional expressions need to be parsed separately for proper
>> nesting.
>> @@ -1012,7 +1012,7 @@ public:
>>      }
>>
>>      FormatToken *Start = Current;
>> -    FormatToken *LatestOperator = NULL;
>> +    FormatToken *LatestOperator = nullptr;
>>      unsigned OperatorIndex = 0;
>>
>>      while (Current) {
>> @@ -1030,7 +1030,7 @@ public:
>>
>>        // At the end of the line or when an operator with higher
>> precedence is
>>        // found, insert fake parenthesis and return.
>> -      if (Current == NULL || Current->closesScope() ||
>> +      if (!Current || Current->closesScope() ||
>>            (CurrentPrecedence != -1 && CurrentPrecedence < Precedence)) {
>>          if (LatestOperator) {
>>            LatestOperator->LastOperator = true;
>> @@ -1098,7 +1098,7 @@ private:
>>    /// \brief Parse unary operator expressions and surround them with fake
>>    /// parentheses if appropriate.
>>    void parseUnaryOperator() {
>> -    if (Current == NULL || Current->Type != TT_UnaryOperator) {
>> +    if (!Current || Current->Type != TT_UnaryOperator) {
>>        parse(PrecedenceArrowAndPeriod);
>>        return;
>>      }
>> @@ -1139,15 +1139,15 @@ private:
>>
>>  void
>>  TokenAnnotator::setCommentLineLevels(SmallVectorImpl<AnnotatedLine *>
>> &Lines) {
>> -  const AnnotatedLine *NextNonCommentLine = NULL;
>> +  const AnnotatedLine *NextNonCommentLine = nullptr;
>>    for (SmallVectorImpl<AnnotatedLine *>::reverse_iterator I =
>> Lines.rbegin(),
>>                                                            E =
>> Lines.rend();
>>         I != E; ++I) {
>>      if (NextNonCommentLine && (*I)->First->is(tok::comment) &&
>> -        (*I)->First->Next == NULL)
>> +        (*I)->First->Next == nullptr)
>>        (*I)->Level = NextNonCommentLine->Level;
>>      else
>> -      NextNonCommentLine = (*I)->First->isNot(tok::r_brace) ? (*I) :
>> NULL;
>> +      NextNonCommentLine = (*I)->First->isNot(tok::r_brace) ? (*I) :
>> nullptr;
>>
>>      setCommentLineLevels((*I)->Children);
>>    }
>> @@ -1185,7 +1185,7 @@ void TokenAnnotator::calculateFormatting
>>      return;
>>    FormatToken *Current = Line.First->Next;
>>    bool InFunctionDecl = Line.MightBeFunctionDecl;
>> -  while (Current != NULL) {
>> +  while (Current) {
>>      if (Current->Type == TT_LineComment) {
>>        if (Current->Previous->BlockKind == BK_BracedInit &&
>>            Current->Previous->opensScope())
>> @@ -1244,7 +1244,7 @@ void TokenAnnotator::calculateFormatting
>>    }
>>
>>    calculateUnbreakableTailLengths(Line);
>> -  for (Current = Line.First; Current != NULL; Current = Current->Next) {
>> +  for (Current = Line.First; Current != nullptr; Current =
>> Current->Next) {
>>      if (Current->Role)
>>        Current->Role->precomputeFormattingInfos(Current);
>>    }
>> @@ -1261,7 +1261,7 @@ void TokenAnnotator::calculateFormatting
>>  void TokenAnnotator::calculateUnbreakableTailLengths(AnnotatedLine
>> &Line) {
>>    unsigned UnbreakableTailLength = 0;
>>    FormatToken *Current = Line.Last;
>> -  while (Current != NULL) {
>> +  while (Current) {
>>      Current->UnbreakableTailLength = UnbreakableTailLength;
>>      if (Current->CanBreakBefore ||
>>          Current->isOneOf(tok::comment, tok::string_literal)) {
>> @@ -1526,8 +1526,8 @@ bool TokenAnnotator::spaceRequiredBefore
>>      return false;
>>    if (Tok.is(tok::colon))
>>      return !Line.First->isOneOf(tok::kw_case, tok::kw_default) &&
>> -           Tok.getNextNonComment() != NULL && Tok.Type !=
>> TT_ObjCMethodExpr &&
>> -           !Tok.Previous->is(tok::question) &&
>> +           Tok.getNextNonComment() &&
>> +           Tok.Type != TT_ObjCMethodExpr &&
>> !Tok.Previous->is(tok::question) &&
>>
>
> No reason to change the location of the line breaks.
>
>
>>             (Tok.Type != TT_DictLiteral ||
>> Style.SpacesInContainerLiterals);
>>    if (Tok.Previous->Type == TT_UnaryOperator ||
>>        Tok.Previous->Type == TT_CastRParen)
>> @@ -1734,7 +1734,7 @@ void TokenAnnotator::printDebugInfo(cons
>>      for (unsigned i = 0, e = Tok->FakeLParens.size(); i != e; ++i)
>>        llvm::errs() << Tok->FakeLParens[i] << "/";
>>      llvm::errs() << " FakeRParens=" << Tok->FakeRParens << "\n";
>> -    if (Tok->Next == NULL)
>> +    if (Tok->Next)
>>
>
> This is not the same thing!!! Did you create this change manually? How
> likely is it that there are more of these? Please fix and double check all
> your other changes.
>
>
>>        assert(Tok == Line.Last);
>>      Tok = Tok->Next;
>>    }
>>
>> Modified: cfe/trunk/lib/Format/TokenAnnotator.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.h?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/TokenAnnotator.h (original)
>> +++ cfe/trunk/lib/Format/TokenAnnotator.h Fri May  9 03:15:10 2014
>> @@ -48,7 +48,7 @@ public:
>>      // Calculate Next and Previous for all tokens. Note that we must
>> overwrite
>>      // Next and Previous for every token, as previous formatting runs
>> might have
>>      // left them in a different state.
>> -    First->Previous = NULL;
>> +    First->Previous = nullptr;
>>      FormatToken *Current = First;
>>      for (std::list<UnwrappedLineNode>::const_iterator I =
>> ++Line.Tokens.begin(),
>>                                                        E =
>> Line.Tokens.end();
>> @@ -67,7 +67,7 @@ public:
>>        }
>>      }
>>      Last = Current;
>> -    Last->Next = NULL;
>> +    Last->Next = nullptr;
>>    }
>>
>>    ~AnnotatedLine() {
>>
>> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri May  9 03:15:10 2014
>> @@ -60,7 +60,7 @@ public:
>>        : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
>>          PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
>>          StructuralError(StructuralError),
>> -        PreviousStructuralError(StructuralError), Token(NULL) {
>> +        PreviousStructuralError(StructuralError), Token(nullptr) {
>>      TokenSource = this;
>>      Line.Level = 0;
>>      Line.InPPDirective = true;
>> @@ -207,15 +207,15 @@ private:
>>  UnwrappedLineParser::UnwrappedLineParser(const FormatStyle &Style,
>>                                           ArrayRef<FormatToken *> Tokens,
>>                                           UnwrappedLineConsumer &Callback)
>> -    : Line(new UnwrappedLine), MustBreakBeforeNextToken(false),
>> -      CurrentLines(&Lines), StructuralError(false), Style(Style),
>> Tokens(NULL),
>> -      Callback(Callback), AllTokens(Tokens), PPBranchLevel(-1) {}
>> +  : Line(new UnwrappedLine), MustBreakBeforeNextToken(false),
>> +    CurrentLines(&Lines), StructuralError(false), Style(Style),
>> Tokens(nullptr),
>> +    Callback(Callback), AllTokens(Tokens), PPBranchLevel(-1) {}
>>
>
> Please revert indentation change.
>
>
>>  void UnwrappedLineParser::reset() {
>>    PPBranchLevel = -1;
>>    Line.reset(new UnwrappedLine);
>>    CommentsBeforeNextToken.clear();
>> -  FormatTok = NULL;
>> +  FormatTok = nullptr;
>>    MustBreakBeforeNextToken = false;
>>    PreprocessorDirectives.clear();
>>    CurrentLines = &Lines;
>> @@ -452,7 +452,7 @@ void UnwrappedLineParser::parsePPDirecti
>>    ScopedMacroState MacroState(*Line, Tokens, FormatTok, StructuralError);
>>    nextToken();
>>
>> -  if (FormatTok->Tok.getIdentifierInfo() == NULL) {
>> +  if (!FormatTok->Tok.getIdentifierInfo()) {
>>      parsePPUnknown();
>>      return;
>>    }
>>
>> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=208392&r1=208391&r2=208392&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.h (original)
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.h Fri May  9 03:15:10 2014
>> @@ -201,7 +201,7 @@ private:
>>  };
>>
>>  struct UnwrappedLineNode {
>> -  UnwrappedLineNode() : Tok(NULL) {}
>> +  UnwrappedLineNode() : Tok(nullptr) {}
>>    UnwrappedLineNode(FormatToken *Tok) : Tok(Tok) {}
>>
>>    FormatToken *Tok;
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140509/fbed8de0/attachment.html>


More information about the cfe-commits mailing list