diff options
-rw-r--r-- | Driver/RewriteBlocks.cpp | 3 | ||||
-rw-r--r-- | Driver/RewriteObjC.cpp | 3 |
2 files changed, 6 insertions, 0 deletions
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); |