From 8f6ce5796fb74daf0c4cd39fbda9f7ceb1c7a7b6 Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Mon, 3 Nov 2008 11:20:24 +0000 Subject: [PATCH] Fix clang block rewriter: Assertion failed: Offset+NumBytes <= size() && "Invalid region to erase!", file c:\cygwin\home\Administrator\llvm\to ols\clang\include\clang/Rewrite/RewriteRope.h, line 219. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58607 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/RewriteBlocks.cpp | 3 +++ Driver/RewriteObjC.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Driver/RewriteBlocks.cpp b/Driver/RewriteBlocks.cpp index cab4b81781..d8e347fafb 100644 --- a/Driver/RewriteBlocks.cpp +++ b/Driver/RewriteBlocks.cpp @@ -746,6 +746,9 @@ void RewriteBlocks::RewriteCastExpr(CastExpr *CE) { SourceLocation LocStart = CE->getLocStart(); SourceLocation LocEnd = CE->getLocEnd(); + if (!Rewriter::isRewritable(LocStart) || !Rewriter::isRewritable(LocEnd)) + return; + const char *startBuf = SM->getCharacterData(LocStart); const char *endBuf = SM->getCharacterData(LocEnd); diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp index 39f4f15ae9..ee9e2bc249 100644 --- a/Driver/RewriteObjC.cpp +++ b/Driver/RewriteObjC.cpp @@ -3570,6 +3570,9 @@ void RewriteObjC::RewriteCastExpr(CastExpr *CE) { // Need to avoid trying to rewrite synthesized casts. if (LocStart.isInvalid()) return; + // Need to avoid trying to rewrite casts contained in macros. + if (!Rewriter::isRewritable(LocStart) || !Rewriter::isRewritable(LocEnd)) + return; const char *startBuf = SM->getCharacterData(LocStart); const char *endBuf = SM->getCharacterData(LocEnd); -- 2.50.1