[PATCH] D101207: [flang] Fix crash from -DMACRO= with empty replacement

Peter Klausler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 24 10:56:45 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0eb3299d28e4: [flang] Fix crash from -DMACRO= with empty replacement (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101207/new/

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.340304.patch
Type: text/x-patch
Size: 871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210424/f3e61e9f/attachment.bin>


More information about the llvm-commits mailing list