Consistent formatting for Dawn/Tint.
This CL updates the clang format files to have a single shared format
between Dawn and Tint. The major changes are tabs are 4 spaces, lines
are 100 columns and namespaces are not indented.
Bug: dawn:1339
Change-Id: I4208742c95643998d9fd14e77a9cc558071ded39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87603
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/source.h b/src/tint/source.h
index 931cdf1..734e693 100644
--- a/src/tint/source.h
+++ b/src/tint/source.h
@@ -26,186 +26,180 @@
/// Source describes a range of characters within a source file.
class Source {
- public:
- /// FileContent describes the content of a source file encoded using utf-8.
- class FileContent {
- public:
- /// Constructs the FileContent with the given file content.
- /// @param data the file contents
- explicit FileContent(const std::string& data);
+ public:
+ /// FileContent describes the content of a source file encoded using utf-8.
+ class FileContent {
+ public:
+ /// Constructs the FileContent with the given file content.
+ /// @param data the file contents
+ explicit FileContent(const std::string& data);
- /// Copy constructor
- /// @param rhs the FileContent to copy
- FileContent(const FileContent& rhs);
+ /// Copy constructor
+ /// @param rhs the FileContent to copy
+ FileContent(const FileContent& rhs);
- /// Destructor
- ~FileContent();
+ /// Destructor
+ ~FileContent();
- /// The original un-split file content
- const std::string data;
- /// A string_view over #data
- const std::string_view data_view;
- /// #data split by lines
- const std::vector<std::string_view> lines;
- };
+ /// The original un-split file content
+ const std::string data;
+ /// A string_view over #data
+ const std::string_view data_view;
+ /// #data split by lines
+ const std::vector<std::string_view> lines;
+ };
- /// File describes a source file, including path and content.
- class File {
- public:
- /// Constructs the File with the given file path and content.
- /// @param p the path for this file
- /// @param c the file contents
- inline File(const std::string& p, const std::string& c)
- : path(p), content(c) {}
+ /// File describes a source file, including path and content.
+ class File {
+ public:
+ /// Constructs the File with the given file path and content.
+ /// @param p the path for this file
+ /// @param c the file contents
+ inline File(const std::string& p, const std::string& c) : path(p), content(c) {}
- /// Copy constructor
- File(const File&) = default;
+ /// Copy constructor
+ File(const File&) = default;
- /// Move constructor
- File(File&&) = default;
+ /// Move constructor
+ File(File&&) = default;
- /// Destructor
- ~File();
+ /// Destructor
+ ~File();
- /// file path
- const std::string path;
- /// file content
- const FileContent content;
- };
+ /// file path
+ const std::string path;
+ /// file content
+ const FileContent content;
+ };
- /// Location holds a 1-based line and column index.
- class Location {
- public:
- /// the 1-based line number. 0 represents no line information.
- size_t line = 0;
- /// the 1-based column number in utf8-code units (bytes).
- /// 0 represents no column information.
- size_t column = 0;
+ /// Location holds a 1-based line and column index.
+ class Location {
+ public:
+ /// the 1-based line number. 0 represents no line information.
+ size_t line = 0;
+ /// the 1-based column number in utf8-code units (bytes).
+ /// 0 represents no column information.
+ size_t column = 0;
- /// Returns true of `this` location is lexicographically less than `rhs`
- /// @param rhs location to compare against
- /// @returns true if `this` < `rhs`
- inline bool operator<(const Source::Location& rhs) {
- return std::tie(line, column) < std::tie(rhs.line, rhs.column);
- }
+ /// Returns true of `this` location is lexicographically less than `rhs`
+ /// @param rhs location to compare against
+ /// @returns true if `this` < `rhs`
+ inline bool operator<(const Source::Location& rhs) {
+ return std::tie(line, column) < std::tie(rhs.line, rhs.column);
+ }
- /// Returns true of `this` location is equal to `rhs`
- /// @param rhs location to compare against
- /// @returns true if `this` == `rhs`
- inline bool operator==(const Location& rhs) const {
- return line == rhs.line && column == rhs.column;
- }
+ /// Returns true of `this` location is equal to `rhs`
+ /// @param rhs location to compare against
+ /// @returns true if `this` == `rhs`
+ inline bool operator==(const Location& rhs) const {
+ return line == rhs.line && column == rhs.column;
+ }
- /// Returns true of `this` location is not equal to `rhs`
- /// @param rhs location to compare against
- /// @returns true if `this` != `rhs`
- inline bool operator!=(const Location& rhs) const {
- return !(*this == rhs);
- }
- };
+ /// Returns true of `this` location is not equal to `rhs`
+ /// @param rhs location to compare against
+ /// @returns true if `this` != `rhs`
+ inline bool operator!=(const Location& rhs) const { return !(*this == rhs); }
+ };
- /// Range holds a Location interval described by [begin, end).
- class Range {
- public:
- /// Constructs a zero initialized Range.
- inline Range() = default;
+ /// Range holds a Location interval described by [begin, end).
+ class Range {
+ public:
+ /// Constructs a zero initialized Range.
+ inline Range() = default;
- /// Constructs a zero-length Range starting at `loc`
- /// @param loc the start and end location for the range
- inline constexpr explicit Range(const Location& loc)
- : begin(loc), end(loc) {}
+ /// Constructs a zero-length Range starting at `loc`
+ /// @param loc the start and end location for the range
+ inline constexpr explicit Range(const Location& loc) : begin(loc), end(loc) {}
- /// Constructs the Range beginning at `b` and ending at `e`
- /// @param b the range start location
- /// @param e the range end location
- inline constexpr Range(const Location& b, const Location& e)
- : begin(b), end(e) {}
+ /// Constructs the Range beginning at `b` and ending at `e`
+ /// @param b the range start location
+ /// @param e the range end location
+ inline constexpr Range(const Location& b, const Location& e) : begin(b), end(e) {}
- /// Return a column-shifted Range
+ /// Return a column-shifted Range
+ /// @param n the number of characters to shift by
+ /// @returns a Range with a #begin and #end column shifted by `n`
+ inline Range operator+(size_t n) const {
+ return Range{{begin.line, begin.column + n}, {end.line, end.column + n}};
+ }
+
+ /// Returns true of `this` range is not equal to `rhs`
+ /// @param rhs range to compare against
+ /// @returns true if `this` != `rhs`
+ inline bool operator==(const Range& rhs) const {
+ return begin == rhs.begin && end == rhs.end;
+ }
+
+ /// Returns true of `this` range is equal to `rhs`
+ /// @param rhs range to compare against
+ /// @returns true if `this` == `rhs`
+ inline bool operator!=(const Range& rhs) const { return !(*this == rhs); }
+
+ /// The location of the first character in the range.
+ Location begin;
+ /// The location of one-past the last character in the range.
+ Location end;
+ };
+
+ /// Constructs the Source with an zero initialized Range and null File.
+ inline Source() : range() {}
+
+ /// Constructs the Source with the Range `rng` and a null File
+ /// @param rng the source range
+ inline explicit Source(const Range& rng) : range(rng) {}
+
+ /// Constructs the Source with the Range `loc` and a null File
+ /// @param loc the start and end location for the source range
+ inline explicit Source(const Location& loc) : range(Range(loc)) {}
+
+ /// Constructs the Source with the Range `rng` and File `file`
+ /// @param rng the source range
+ /// @param f the source file
+ inline Source(const Range& rng, File const* f) : range(rng), file(f) {}
+
+ /// @returns a Source that points to the begin range of this Source.
+ inline Source Begin() const { return Source(Range{range.begin}, file); }
+
+ /// @returns a Source that points to the end range of this Source.
+ inline Source End() const { return Source(Range{range.end}, file); }
+
+ /// Return a column-shifted Source
/// @param n the number of characters to shift by
- /// @returns a Range with a #begin and #end column shifted by `n`
- inline Range operator+(size_t n) const {
- return Range{{begin.line, begin.column + n}, {end.line, end.column + n}};
+ /// @returns a Source with the range's columns shifted by `n`
+ inline Source operator+(size_t n) const { return Source(range + n, file); }
+
+ /// Returns true of `this` Source is lexicographically less than `rhs`
+ /// @param rhs source to compare against
+ /// @returns true if `this` < `rhs`
+ inline bool operator<(const Source& rhs) {
+ if (file != rhs.file) {
+ return false;
+ }
+ return range.begin < rhs.range.begin;
}
- /// Returns true of `this` range is not equal to `rhs`
- /// @param rhs range to compare against
- /// @returns true if `this` != `rhs`
- inline bool operator==(const Range& rhs) const {
- return begin == rhs.begin && end == rhs.end;
+ /// Helper function that returns the range union of two source locations. The
+ /// `start` and `end` locations are assumed to refer to the same source file.
+ /// @param start the start source of the range
+ /// @param end the end source of the range
+ /// @returns the combined source
+ inline static Source Combine(const Source& start, const Source& end) {
+ return Source(Source::Range(start.range.begin, end.range.end), start.file);
}
- /// Returns true of `this` range is equal to `rhs`
- /// @param rhs range to compare against
- /// @returns true if `this` == `rhs`
- inline bool operator!=(const Range& rhs) const { return !(*this == rhs); }
-
- /// The location of the first character in the range.
- Location begin;
- /// The location of one-past the last character in the range.
- Location end;
- };
-
- /// Constructs the Source with an zero initialized Range and null File.
- inline Source() : range() {}
-
- /// Constructs the Source with the Range `rng` and a null File
- /// @param rng the source range
- inline explicit Source(const Range& rng) : range(rng) {}
-
- /// Constructs the Source with the Range `loc` and a null File
- /// @param loc the start and end location for the source range
- inline explicit Source(const Location& loc) : range(Range(loc)) {}
-
- /// Constructs the Source with the Range `rng` and File `file`
- /// @param rng the source range
- /// @param f the source file
- inline Source(const Range& rng, File const* f) : range(rng), file(f) {}
-
- /// @returns a Source that points to the begin range of this Source.
- inline Source Begin() const { return Source(Range{range.begin}, file); }
-
- /// @returns a Source that points to the end range of this Source.
- inline Source End() const { return Source(Range{range.end}, file); }
-
- /// Return a column-shifted Source
- /// @param n the number of characters to shift by
- /// @returns a Source with the range's columns shifted by `n`
- inline Source operator+(size_t n) const { return Source(range + n, file); }
-
- /// Returns true of `this` Source is lexicographically less than `rhs`
- /// @param rhs source to compare against
- /// @returns true if `this` < `rhs`
- inline bool operator<(const Source& rhs) {
- if (file != rhs.file) {
- return false;
- }
- return range.begin < rhs.range.begin;
- }
-
- /// Helper function that returns the range union of two source locations. The
- /// `start` and `end` locations are assumed to refer to the same source file.
- /// @param start the start source of the range
- /// @param end the end source of the range
- /// @returns the combined source
- inline static Source Combine(const Source& start, const Source& end) {
- return Source(Source::Range(start.range.begin, end.range.end), start.file);
- }
-
- /// range is the span of text this source refers to in #file
- Range range;
- /// file is the optional source content this source refers to
- const File* file = nullptr;
+ /// range is the span of text this source refers to in #file
+ Range range;
+ /// file is the optional source content this source refers to
+ const File* file = nullptr;
};
/// Writes the Source::Location to the std::ostream.
/// @param out the std::ostream to write to
/// @param loc the location to write
/// @returns out so calls can be chained
-inline std::ostream& operator<<(std::ostream& out,
- const Source::Location& loc) {
- out << loc.line << ":" << loc.column;
- return out;
+inline std::ostream& operator<<(std::ostream& out, const Source::Location& loc) {
+ out << loc.line << ":" << loc.column;
+ return out;
}
/// Writes the Source::Range to the std::ostream.
@@ -213,8 +207,8 @@
/// @param range the range to write
/// @returns out so calls can be chained
inline std::ostream& operator<<(std::ostream& out, const Source::Range& range) {
- out << "[" << range.begin << ", " << range.end << "]";
- return out;
+ out << "[" << range.begin << ", " << range.end << "]";
+ return out;
}
/// Writes the Source to the std::ostream.
@@ -227,10 +221,9 @@
/// @param out the std::ostream to write to
/// @param content the file content to write
/// @returns out so calls can be chained
-inline std::ostream& operator<<(std::ostream& out,
- const Source::FileContent& content) {
- out << content.data;
- return out;
+inline std::ostream& operator<<(std::ostream& out, const Source::FileContent& content) {
+ out << content.data;
+ return out;
}
} // namespace tint