[flang-commits] [flang] 0eb3299 - [flang] Fix crash from -DMACRO= with empty replacement
peter klausler via flang-commits
flang-commits at lists.llvm.org
Sat Apr 24 10:56:36 PDT 2021
Author: peter klausler
Date: 2021-04-24T10:56:25-07:00
New Revision: 0eb3299d28e4a9e235dec28d70a0df9e74e74722
URL: https://github.com/llvm/llvm-project/commit/0eb3299d28e4a9e235dec28d70a0df9e74e74722
DIFF: https://github.com/llvm/llvm-project/commit/0eb3299d28e4a9e235dec28d70a0df9e74e74722.diff
LOG: [flang] Fix crash from -DMACRO= with empty replacement
Such macros were exposing some edge cases in the preprocessor
regarding empty tokens.
Differential Revision: https://reviews.llvm.org/D101207
Added:
Modified:
flang/include/flang/Common/interval.h
flang/lib/Parser/provenance.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Common/interval.h b/flang/include/flang/Common/interval.h
index c1ef8d72eb303..9d819f0364915 100644
--- a/flang/include/flang/Common/interval.h
+++ b/flang/include/flang/Common/interval.h
@@ -93,7 +93,7 @@ template <typename A> class Interval {
return x - start_;
}
A OffsetMember(std::size_t n) const {
- CHECK(n < size_);
+ CHECK(n <= size_);
return start_ + n;
}
diff --git a/flang/lib/Parser/provenance.cpp b/flang/lib/Parser/provenance.cpp
index 2aa1a97ce5570..86de7657f9615 100644
--- a/flang/lib/Parser/provenance.cpp
+++ b/flang/lib/Parser/provenance.cpp
@@ -91,7 +91,10 @@ void OffsetToProvenanceMappings::Put(const OffsetToProvenanceMappings &that) {
}
ProvenanceRange OffsetToProvenanceMappings::Map(std::size_t at) const {
- // CHECK(!provenanceMap_.empty());
+ if (provenanceMap_.empty()) {
+ CHECK(at == 0);
+ return {};
+ }
std::size_t low{0}, count{provenanceMap_.size()};
while (count > 1) {
std::size_t mid{low + (count >> 1)};
More information about the flang-commits
mailing list