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

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

Issue 2384493003: Fix GN issues identified by MSVC static analysis. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/command_format.h" 5 #include "tools/gn/command_format.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 const base::StringPiece lhs = ident->value().value(); 316 const base::StringPiece lhs = ident->value().value();
317 if (lhs == "data" || lhs == "datadeps" || lhs == "data_deps" || 317 if (lhs == "data" || lhs == "datadeps" || lhs == "data_deps" ||
318 lhs == "deps" || lhs == "inputs" || lhs == "outputs" || 318 lhs == "deps" || lhs == "inputs" || lhs == "outputs" ||
319 lhs == "public" || lhs == "public_deps" || lhs == "sources") { 319 lhs == "public" || lhs == "public_deps" || lhs == "sources") {
320 const_cast<ListNode*>(list)->set_prefer_multiline(true); 320 const_cast<ListNode*>(list)->set_prefer_multiline(true);
321 } 321 }
322 } 322 }
323 } 323 }
324 324
325 void Printer::SortIfSourcesOrDeps(const BinaryOpNode* binop) { 325 void Printer::SortIfSourcesOrDeps(const BinaryOpNode* binop) {
326 if (binop && binop->comments() && !binop->comments()->before().empty() && 326 if (binop->comments() && !binop->comments()->before().empty() &&
327 binop->comments()->before()[0].value().as_string() == "# NOSORT") { 327 binop->comments()->before()[0].value().as_string() == "# NOSORT") {
328 // Allow disabling of sort for specific actions that might be 328 // Allow disabling of sort for specific actions that might be
329 // order-sensitive. 329 // order-sensitive.
330 return; 330 return;
331 } 331 }
332 const IdentifierNode* ident = binop->left()->AsIdentifier(); 332 const IdentifierNode* ident = binop->left()->AsIdentifier();
333 const ListNode* list = binop->right()->AsList(); 333 const ListNode* list = binop->right()->AsList();
334 if ((binop->op().value() == "=" || binop->op().value() == "+=" || 334 if ((binop->op().value() == "=" || binop->op().value() == "+=" ||
335 binop->op().value() == "-=") && 335 binop->op().value() == "-=") &&
336 ident && list) { 336 ident && list) {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 int start_column = CurrentColumn(); 739 int start_column = CurrentColumn();
740 Print(func_call->function().value()); 740 Print(func_call->function().value());
741 Print("("); 741 Print("(");
742 742
743 bool have_block = func_call->block() != nullptr; 743 bool have_block = func_call->block() != nullptr;
744 bool force_multiline = false; 744 bool force_multiline = false;
745 745
746 const auto& list = func_call->args()->contents(); 746 const auto& list = func_call->args()->contents();
747 const ParseNode* end = func_call->args()->End(); 747 const ParseNode* end = func_call->args()->End();
748 748
749 if (end && end->comments() && !end->comments()->before().empty()) 749 if (end->comments() && !end->comments()->before().empty())
750 force_multiline = true; 750 force_multiline = true;
751 751
752 // If there's before line comments, make sure we have a place to put them. 752 // If there's before line comments, make sure we have a place to put them.
753 for (const auto& i : list) { 753 for (const auto& i : list) {
754 if (i->comments() && !i->comments()->before().empty()) 754 if (i->comments() && !i->comments()->before().empty())
755 force_multiline = true; 755 force_multiline = true;
756 } 756 }
757 757
758 // Calculate the penalties for 3 possible layouts: 758 // Calculate the penalties for 3 possible layouts:
759 // 1. all on same line; 759 // 1. all on same line;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 } 1073 }
1074 printf("Wrote formatted to '%s'.\n", to_write.AsUTF8Unsafe().c_str()); 1074 printf("Wrote formatted to '%s'.\n", to_write.AsUTF8Unsafe().c_str());
1075 } 1075 }
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 return 0; 1079 return 0;
1080 } 1080 }
1081 1081
1082 } // namespace commands 1082 } // namespace commands
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698