[flang-commits] [PATCH] D101207: [flang] Fix crash from -DMACRO= with empty replacement
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Apr 23 16:28:54 PDT 2021
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
Such macros were exposing some edge cases in the preprocessor
regarding empty tokens.
https://reviews.llvm.org/D101207
Files:
flang/include/flang/Common/interval.h
flang/lib/Parser/provenance.cpp
Index: flang/lib/Parser/provenance.cpp
===================================================================
--- flang/lib/Parser/provenance.cpp
+++ flang/lib/Parser/provenance.cpp
@@ -91,7 +91,10 @@
}
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)};
Index: flang/include/flang/Common/interval.h
===================================================================
--- flang/include/flang/Common/interval.h
+++ flang/include/flang/Common/interval.h
@@ -93,7 +93,7 @@
return x - start_;
}
A OffsetMember(std::size_t n) const {
- CHECK(n < size_);
+ CHECK(n <= size_);
return start_ + n;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101207.340197.patch
Type: text/x-patch
Size: 871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210423/7b7bea16/attachment.bin>
More information about the flang-commits
mailing list