improve loplugin rewriter double source modification detection

because my new rewriter easily generates overlapping rewriting.

Move the code from flatten and salcall up into the pluginhandler, and
drop the simpler detection logic.

Change-Id: I3da51ac510954a5d4276cee0924cc5dc1fc9a734
Reviewed-on: https://gerrit.libreoffice.org/49493
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2018-02-09 15:28:41 +02:00
parent 5853b0b25d
commit 94ab8e4360
6 changed files with 34 additions and 68 deletions

View File

@@ -54,10 +54,13 @@ public:
DiagnosticBuilder report( DiagnosticsEngine::Level level, const char * plugin, StringRef message,
CompilerInstance& compiler, SourceLocation loc = SourceLocation());
bool ignoreLocation(SourceLocation loc);
bool addRemoval( SourceLocation loc );
bool isDebugMode() const { return debugMode; }
bool isLOOLMode() const { return !loolBasePath.empty(); }
static bool isUnitTestMode();
// If we overlap with a previous area we modified, we cannot perform this change
// without corrupting the source
bool checkOverlap(SourceRange range);
bool addSourceModification(SourceRange range);
private:
void handleOption( const std::string& option );
void createPlugins( std::set< std::string > rewriters );
@@ -67,12 +70,12 @@ private:
StringRef const mainFileName;
std::unordered_map<SourceLocation, bool> ignored_;
Rewriter rewriter;
std::set< SourceLocation > removals;
std::string scope;
std::string warningsOnly;
std::string loolBasePath;
bool warningsAsErrors;
bool debugMode = false;
std::vector<std::pair<char const*, char const*>> mvModifiedRanges;
};
/**