[all-commits] [llvm/llvm-project] bd1fac: Add assert on End iteration distance to Rewriter::...

ahedberg via All-commits all-commits at lists.llvm.org
Tue Jan 25 09:28:09 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bd1fac2fafd7a1afacce05cd53a3741a2214f5f1
      https://github.com/llvm/llvm-project/commit/bd1fac2fafd7a1afacce05cd53a3741a2214f5f1
  Author: Ashley Hedberg <ahedberg at google.com>
  Date:   2022-01-25 (Tue, 25 Jan 2022)

  Changed paths:
    M clang/lib/Rewrite/Rewriter.cpp

  Log Message:
  -----------
  Add assert on End iteration distance to Rewriter::getRewrittenText.

I currently have code that is crashing in the second std::advance call,
and it was not straightforward to identify the problem, as the first line
of the stacktrace is in RopePieceBTreeIterator::operator++:

```

*** SIGILL; stack trace: ***
PC: clang/include/clang/Rewrite/Core/RewriteRope.h:119 clang::RopePieceBTreeIterator::operator++()
    ../include/c++/v1/__iterator/advance.h:35 std::__u::__advance<>()
    ../include/c++/v1/__iterator/advance.h:65 std::__u::advance<>()
    clang/lib/Rewrite/Rewriter.cpp:228 clang::Rewriter::getRewrittenText()
    clang/include/clang/Rewrite/Core/Rewriter.h:106 clang::Rewriter::getRewrittenText()
```

Adding an assertion produces a friendlier error message for the caller.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D117579




More information about the All-commits mailing list