From 8ad5a0037fdb1f723a494a6e367613cc946f63de Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 28 Sep 2023 22:20:21 -0700 Subject: [PATCH] Fix indentation in source-manager. --- compiler/source-location.h | 13 ------ compiler/source-manager.cpp | 2 +- compiler/source-manager.h | 90 ++++++++++++++++++------------------- 3 files changed, 46 insertions(+), 59 deletions(-) diff --git a/compiler/source-location.h b/compiler/source-location.h index ec82a4a1e..017170cba 100644 --- a/compiler/source-location.h +++ b/compiler/source-location.h @@ -76,16 +76,3 @@ class SourceLocation private: uint32_t id_; }; - -struct SourceRange -{ - SourceLocation start; - SourceLocation end; - - SourceRange() - {} - SourceRange(const SourceLocation& start, const SourceLocation& end) - : start(start), - end(end) - {} -}; diff --git a/compiler/source-manager.cpp b/compiler/source-manager.cpp index f74c79afd..32d9f33d3 100644 --- a/compiler/source-manager.cpp +++ b/compiler/source-manager.cpp @@ -31,7 +31,7 @@ std::shared_ptr SourceManager::Open(const std::string& path, { auto file = std::make_shared(); if (!file->Open(path)) - return nullptr; + return nullptr; size_t loc_index; if (!TrackExtents(file->size(), &loc_index)) { diff --git a/compiler/source-manager.h b/compiler/source-manager.h index 8b8c00e62..567d27b15 100644 --- a/compiler/source-manager.h +++ b/compiler/source-manager.h @@ -45,56 +45,56 @@ struct token_pos_t { // trackFile() or trackMacro(). struct LREntry { - // Starting id for this source range. - uint32_t id; + // Starting id for this source range. + uint32_t id; private: - // If we're creating a range from an #include, this is the location in the - // parent file we were #included from, if any. - // - // If we're creating a range for macro insertion, this is where we started - // inserting tokens. - SourceLocation parent_; + // If we're creating a range from an #include, this is the location in the + // parent file we were #included from, if any. + // + // If we're creating a range for macro insertion, this is where we started + // inserting tokens. + SourceLocation parent_; - // If we included from a file, this is where we included. - std::shared_ptr file_; + // If we included from a file, this is where we included. + std::shared_ptr file_; public: - LREntry() - : id(0) - {} - - bool valid() const { - return id != 0; - } - - void init(const SourceLocation& parent, std::shared_ptr file) { - this->parent_ = parent; - this->file_ = std::move(file); - } - - std::shared_ptr file() const { - return file_; - } - const SourceLocation& parent() const { - return parent_; - } - - uint32_t length() const { - return file_->size(); - } - - bool owns(const SourceLocation& loc) const { - if (loc.offset() >= id && loc.offset() <= id + length()) - return true; - return false; - } - - SourceLocation FilePos(uint32_t offset) const { - assert(file_); - assert(offset <= file_->size()); - return SourceLocation::FromFile(id, offset); - } + LREntry() + : id(0) + {} + + bool valid() const { + return id != 0; + } + + void init(const SourceLocation& parent, std::shared_ptr file) { + this->parent_ = parent; + this->file_ = std::move(file); + } + + std::shared_ptr file() const { + return file_; + } + const SourceLocation& parent() const { + return parent_; + } + + uint32_t length() const { + return file_->size(); + } + + bool owns(const SourceLocation& loc) const { + if (loc.offset() >= id && loc.offset() <= id + length()) + return true; + return false; + } + + SourceLocation FilePos(uint32_t offset) const { + assert(file_); + assert(offset <= file_->size()); + return SourceLocation::FromFile(id, offset); + } }; class SourceManager final