diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-08-20 19:42:16 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-08-21 15:08:16 +0200 |
commit | 75f41baab6ce75786a91fe461835ee16a23ec18e (patch) | |
tree | 7d9c37c648d827c92cc24f14537633fd61f8240f | |
parent | 21c795488c67a8e35354ca7175445a770600159b (diff) |
warn when rewriter should modify something involving a macro
Apparently Clang rewriter API doesn't properly bail out if the range
given is not inside one file, so check explicitly.
Change-Id: I27be6d396a131d385231e9c0dfa8c84d9fa15ccc
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 65333025e576..064bfa5b91a7 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -199,6 +199,8 @@ bool RewritePlugin::removeText( SourceRange range, RewriteOptions opts ) bool RewritePlugin::removeText( CharSourceRange range, RewriteOptions opts ) { + if( rewriter.getRangeSize( range, opts ) == -1 ) + return reportEditFailure( range.getBegin()); if( removals.find( range.getBegin()) != removals.end()) report( DiagnosticsEngine::Warning, "double code removal, possible plugin error", range.getBegin()); removals.insert( range.getBegin()); @@ -264,6 +266,8 @@ bool RewritePlugin::replaceText( SourceLocation Start, unsigned OrigLength, Stri bool RewritePlugin::replaceText( SourceRange range, StringRef NewStr ) { + if( rewriter.getRangeSize( range ) == -1 ) + return reportEditFailure( range.getBegin()); if( removals.find( range.getBegin()) != removals.end()) report( DiagnosticsEngine::Warning, "double code replacement, possible plugin error", range.getBegin()); removals.insert( range.getBegin()); @@ -274,6 +278,8 @@ bool RewritePlugin::replaceText( SourceRange range, StringRef NewStr ) bool RewritePlugin::replaceText( SourceRange range, SourceRange replacementRange ) { + if( rewriter.getRangeSize( range ) == -1 ) + return reportEditFailure( range.getBegin()); if( removals.find( range.getBegin()) != removals.end()) report( DiagnosticsEngine::Warning, "double code replacement, possible plugin error", range.getBegin()); removals.insert( range.getBegin()); |