Index: tools/gn/parser.cc |
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc |
index c99282f2b0fb36ade03ffb5c439634a7e8f75ef5..b1b310f73ebe82279b532e24457c268be272b7b1 100644 |
--- a/tools/gn/parser.cc |
+++ b/tools/gn/parser.cc |
@@ -550,7 +550,7 @@ void Parser::AssignComments(ParseNode* file) { |
const Location& start = (*i)->GetRange().begin(); |
while (cur_comment < static_cast<int>(line_comment_tokens_.size())) { |
if (start.byte() >= line_comment_tokens_[cur_comment].location().byte()) { |
- const_cast<ParseNode*>((*i))->comments_mutable()->append_before( |
+ const_cast<ParseNode*>(*i)->comments_mutable()->append_before( |
line_comment_tokens_[cur_comment]); |
++cur_comment; |
} else { |
@@ -589,12 +589,16 @@ void Parser::AssignComments(ParseNode* file) { |
while (cur_comment >= 0) { |
if (end.byte() <= suffix_comment_tokens_[cur_comment].location().byte()) { |
- const_cast<ParseNode*>((*i))->comments_mutable()->append_suffix( |
+ const_cast<ParseNode*>(*i)->comments_mutable()->append_suffix( |
suffix_comment_tokens_[cur_comment]); |
--cur_comment; |
} else { |
break; |
} |
} |
+ |
+ // Suffix comments were assigned in reverse, so if there were multiple on |
+ // the same node, they need to be reversed. |
+ const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); |
} |
} |