[flang] Clean out some dead code, improve naming & comments

Original-commit: flang-compiler/f18@3495555565
Reviewed-on: https://github.com/flang-compiler/f18/pull/715
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-09-05 13:10:43 -07:00
parent db25a52fe7
commit fa3410d5fb
5 changed files with 11 additions and 20 deletions

View File

@ -97,7 +97,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdelete-non-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 '-DCHECK=(void)'")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUGF18")

View File

@ -44,7 +44,7 @@ public:
}
bool empty() const { return bytes_ == 0; }
std::size_t size() const { return bytes_; }
std::size_t bytes() const { return bytes_; }
void clear() {
blocks_.clear();

View File

@ -28,12 +28,13 @@ void OffsetToProvenanceMappings::shrink_to_fit() {
provenanceMap_.shrink_to_fit();
}
std::size_t OffsetToProvenanceMappings::size() const {
std::size_t OffsetToProvenanceMappings::SizeInBytes() const {
if (provenanceMap_.empty()) {
return 0;
} else {
const ContiguousProvenanceMapping &last{provenanceMap_.back()};
return last.start + last.range.size();
}
const ContiguousProvenanceMapping &last{provenanceMap_.back()};
return last.start + last.range.size();
}
void OffsetToProvenanceMappings::Put(ProvenanceRange range) {
@ -241,14 +242,6 @@ const SourceFile *AllSources::GetSourceFile(
origin.u);
}
ProvenanceRange AllSources::GetContiguousRangeAround(
ProvenanceRange range) const {
CHECK(IsValid(range));
const Origin &origin{MapToOrigin(range.start())};
CHECK(origin.covers.Contains(range));
return origin.covers;
}
std::string AllSources::GetPath(Provenance at) const {
const SourceFile *source{GetSourceFile(at)};
return source ? source->path() : ""s;
@ -329,7 +322,7 @@ std::optional<ProvenanceRange> CookedSource::GetProvenanceRange(
}
void CookedSource::Marshal() {
CHECK(provenanceMap_.size() == buffer_.size());
CHECK(provenanceMap_.SizeInBytes() == buffer_.bytes());
provenanceMap_.Put(allSources_.AddCompilerInsertion("(after end of source)"));
data_ = buffer_.Marshal();
buffer_.clear();

View File

@ -90,10 +90,10 @@ using ProvenanceRange = common::Interval<Provenance>;
class OffsetToProvenanceMappings {
public:
OffsetToProvenanceMappings() {}
std::size_t size() const;
void clear();
void swap(OffsetToProvenanceMappings &);
void shrink_to_fit();
std::size_t SizeInBytes() const;
void Put(ProvenanceRange);
void Put(const OffsetToProvenanceMappings &);
ProvenanceRange Map(std::size_t at) const;
@ -106,6 +106,8 @@ private:
ProvenanceRange range;
};
// Elements appear in ascending order of distinct .start values;
// their .range values are disjoint and not necessarily adjacent.
std::vector<ContiguousProvenanceMapping> provenanceMap_;
};
@ -143,7 +145,6 @@ public:
const std::string &message, bool echoSourceLine = false) const;
const SourceFile *GetSourceFile(
Provenance, std::size_t *offset = nullptr) const;
ProvenanceRange GetContiguousRangeAround(ProvenanceRange) const;
std::string GetPath(Provenance) const; // __FILE__
int GetLineNumber(Provenance) const; // __LINE__
Provenance CompilerInsertionProvenance(char ch);
@ -155,9 +156,6 @@ private:
const SourceFile &source;
bool isModule{false};
};
struct Module {
const SourceFile &source;
};
struct Macro {
ProvenanceRange definition;
std::string expansion;
@ -182,6 +180,7 @@ private:
const Origin &MapToOrigin(Provenance) const;
// Elements are in ascending & contiguous order of .covers.
std::vector<Origin> origin_;
ProvenanceRange range_;
std::map<char, Provenance> compilerInsertionProvenance_;

View File

@ -223,7 +223,7 @@ bool SourceFile::ReadFile(std::string errorPath, std::stringstream *error) {
--openFileDescriptors;
}
fileDescriptor_ = -1;
if (buffer.size() == 0) {
if (buffer.bytes() == 0) {
// empty file
address_ = content_ = nullptr;
size_ = bytes_ = 0;