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

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

Issue 1905473003: 🐣 GN: Print the import trail when parse errors occur. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add null origin check Created 4 years, 8 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
« tools/gn/location.h ('K') | « tools/gn/location.h ('k') | 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 (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/location.h" 5 #include "tools/gn/location.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "tools/gn/input_file.h" 11 #include "tools/gn/input_file.h"
12 12
13 Location::Location() 13 Location::Location()
14 : file_(nullptr), 14 : file_(nullptr),
15 line_number_(-1), 15 line_number_(-1),
16 column_number_(-1) { 16 column_number_(-1) {
17 } 17 }
18 18
19 Location::Location(const InputFile* file, 19 Location::Location(const InputFile* file,
20 int line_number, 20 int line_number,
21 int column_number, 21 int column_number,
22 int byte) 22 int byte)
23 : file_(file), 23 : file_(file),
24 line_number_(line_number), 24 line_number_(line_number),
25 column_number_(column_number), 25 column_number_(column_number),
26 byte_(byte) { 26 byte_(byte) {
27 } 27 }
28 28
29 bool Location::is_null() const {
30 return *this == Location();
31 }
32
29 bool Location::operator==(const Location& other) const { 33 bool Location::operator==(const Location& other) const {
30 return other.file_ == file_ && 34 return other.file_ == file_ &&
31 other.line_number_ == line_number_ && 35 other.line_number_ == line_number_ &&
32 other.column_number_ == column_number_; 36 other.column_number_ == column_number_;
33 } 37 }
34 38
35 bool Location::operator!=(const Location& other) const { 39 bool Location::operator!=(const Location& other) const {
36 return !operator==(other); 40 return !operator==(other);
37 } 41 }
38 42
(...skipping 24 matching lines...) Expand all
63 67
64 LocationRange::LocationRange() { 68 LocationRange::LocationRange() {
65 } 69 }
66 70
67 LocationRange::LocationRange(const Location& begin, const Location& end) 71 LocationRange::LocationRange(const Location& begin, const Location& end)
68 : begin_(begin), 72 : begin_(begin),
69 end_(end) { 73 end_(end) {
70 DCHECK(begin_.file() == end_.file()); 74 DCHECK(begin_.file() == end_.file());
71 } 75 }
72 76
77 bool LocationRange::is_null() const {
78 return begin_.is_null(); // No need to check both for the null case.
79 }
80
73 LocationRange LocationRange::Union(const LocationRange& other) const { 81 LocationRange LocationRange::Union(const LocationRange& other) const {
74 DCHECK(begin_.file() == other.begin_.file()); 82 DCHECK(begin_.file() == other.begin_.file());
75 return LocationRange( 83 return LocationRange(
76 begin_ < other.begin_ ? begin_ : other.begin_, 84 begin_ < other.begin_ ? begin_ : other.begin_,
77 end_ < other.end_ ? other.end_ : end_); 85 end_ < other.end_ ? other.end_ : end_);
78 } 86 }
OLDNEW
« tools/gn/location.h ('K') | « tools/gn/location.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698