diff options
Diffstat (limited to 'compilerplugins/clang/plugin.cxx')
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 75d55782009c..85bd69625b09 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -105,9 +105,22 @@ bool RewritePlugin::insertTextBefore( SourceLocation Loc, StringRef Str ) return true; } +// These two removeText() overloads should not be merged into one, as the SourceRange +// one uses a token range (which counts token length for some reason), so exact length +// given to this overload would not match afterwards. bool RewritePlugin::removeText( SourceLocation Start, unsigned Length, RewriteOptions opts ) { - return removeText( SourceRange( Start, Start.getLocWithOffset( Length )), opts ); + if( opts.RemoveWholeStatement ) + { + SourceRange range( Start, Start.getLocWithOffset( Length - 1 )); + if( !adjustForWholeStatement( &range )) + return reportEditFailure( Start ); + Start = range.getBegin(); + Length = range.getEnd().getRawEncoding() - range.getBegin().getRawEncoding(); + } + if( rewriter.RemoveText( Start, Length, opts )) + return reportEditFailure( Start ); + return true; } bool RewritePlugin::removeText( SourceRange range, RewriteOptions opts ) |