This is an archive of the discontinued LLVM Phabricator instance.

Add assert on End iteration distance to Rewriter::getRewrittenText.
ClosedPublic

Authored by ahedberg on Jan 18 2022, 10:01 AM.

Details

Summary

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.

Diff Detail

Event Timeline

ahedberg requested review of this revision.Jan 18 2022, 10:01 AM
ahedberg created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2022, 10:01 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ahedberg edited the summary of this revision. (Show Details)Jan 18 2022, 10:02 AM
ahedberg added a reviewer: ymandel.
gribozavr2 accepted this revision.Jan 20 2022, 11:28 AM
This revision is now accepted and ready to land.Jan 20 2022, 11:28 AM
This revision was landed with ongoing or failed builds.Jan 25 2022, 9:28 AM
This revision was automatically updated to reflect the committed changes.