Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: tools/gn/parser.cc

Issue 2105553005: tools/gn: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/parse_tree_unittest.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/parser.h" 5 #include "tools/gn/parser.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 704
705 void Parser::AssignComments(ParseNode* file) { 705 void Parser::AssignComments(ParseNode* file) {
706 // Start by generating a pre- and post- order traversal of the tree so we 706 // Start by generating a pre- and post- order traversal of the tree so we
707 // can determine what's before and after comments. 707 // can determine what's before and after comments.
708 std::vector<const ParseNode*> pre; 708 std::vector<const ParseNode*> pre;
709 std::vector<const ParseNode*> post; 709 std::vector<const ParseNode*> post;
710 TraverseOrder(file, &pre, &post); 710 TraverseOrder(file, &pre, &post);
711 711
712 // Assign line comments to syntax immediately following. 712 // Assign line comments to syntax immediately following.
713 int cur_comment = 0; 713 int cur_comment = 0;
714 for (const auto& node : pre) { 714 for (auto* node : pre) {
715 const Location& start = node->GetRange().begin(); 715 const Location& start = node->GetRange().begin();
716 while (cur_comment < static_cast<int>(line_comment_tokens_.size())) { 716 while (cur_comment < static_cast<int>(line_comment_tokens_.size())) {
717 if (start.byte() >= line_comment_tokens_[cur_comment].location().byte()) { 717 if (start.byte() >= line_comment_tokens_[cur_comment].location().byte()) {
718 const_cast<ParseNode*>(node)->comments_mutable()->append_before( 718 const_cast<ParseNode*>(node)->comments_mutable()->append_before(
719 line_comment_tokens_[cur_comment]); 719 line_comment_tokens_[cur_comment]);
720 ++cur_comment; 720 ++cur_comment;
721 } else { 721 } else {
722 break; 722 break;
723 } 723 }
724 } 724 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 break; 761 break;
762 } 762 }
763 } 763 }
764 764
765 // Suffix comments were assigned in reverse, so if there were multiple on 765 // Suffix comments were assigned in reverse, so if there were multiple on
766 // the same node, they need to be reversed. 766 // the same node, they need to be reversed.
767 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) 767 if ((*i)->comments() && !(*i)->comments()->suffix().empty())
768 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); 768 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix();
769 } 769 }
770 } 770 }
OLDNEW
« no previous file with comments | « tools/gn/parse_tree_unittest.cc ('k') | tools/gn/scope.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698