summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/cpp11-migrate/Core/Transform.h
diff options
context:
space:
mode:
authorEdwin Vane <edwin.vane@intel.com>2013-06-06 20:31:52 +0000
committerEdwin Vane <edwin.vane@intel.com>2013-06-06 20:31:52 +0000
commit32e3553f838ed05d21b6df2e02f88340c645b5a6 (patch)
tree4b46c59fc7019a45608fa3088148e5cb49ffad9c /clang-tools-extra/cpp11-migrate/Core/Transform.h
parentfb5bddfd0a3383c9c724212e21857daa9b319595 (diff)
downloadbcm5719-llvm-32e3553f838ed05d21b6df2e02f88340c645b5a6.tar.gz
bcm5719-llvm-32e3553f838ed05d21b6df2e02f88340c645b5a6.zip
cpp11-migrate: Refactor how global options are passed to Transforms
Refactored how global options are passed to Transforms to avoid widespread changes every time a new global option is added. Tests updated to reflect new interface. llvm-svn: 183443
Diffstat (limited to 'clang-tools-extra/cpp11-migrate/Core/Transform.h')
-rw-r--r--clang-tools-extra/cpp11-migrate/Core/Transform.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/clang-tools-extra/cpp11-migrate/Core/Transform.h b/clang-tools-extra/cpp11-migrate/Core/Transform.h
index 1297ec1becd..264b59526a7 100644
--- a/clang-tools-extra/cpp11-migrate/Core/Transform.h
+++ b/clang-tools-extra/cpp11-migrate/Core/Transform.h
@@ -17,6 +17,7 @@
#include <string>
#include <vector>
+#include "IncludeExcludeInfo.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/Timer.h"
@@ -105,24 +106,32 @@ private:
clang::Rewriter Rewrite;
};
+/// \brief Container for global options affecting all transforms.
+struct TransformOptions {
+ /// \brief Enable the use of performance timers.
+ bool EnableTiming;
+
+ /// \brief Maximum allowed level of risk.
+ RiskLevel MaxRiskLevel;
+};
+
/// \brief Abstract base class for all C++11 migration transforms.
///
/// Per-source performance timing is handled by the callbacks
/// handleBeginSource() and handleEndSource() if timing is enabled. See
-/// clang::tooling::newFrontendActionFactory() for how to register
-/// a Transform object for callbacks.
+/// clang::tooling::newFrontendActionFactory() for how to register a Transform
+/// object for callbacks. When a Transform object is registered for
+/// FrontendAction source file callbacks, this behaviour can be used to time
+/// the application of a MatchFinder by subclasses. Durations are automatically
+/// stored in a TimingVec.
class Transform : public clang::tooling::SourceFileCallbacks {
public:
/// \brief Constructor
/// \param Name Name of the transform for human-readable purposes (e.g. -help
/// text)
- /// \param EnableTiming Enable the timing of the duration between calls to
- /// handleBeginSource() and handleEndSource(). When a Transform object is
- /// registered for FrontendAction source file callbacks, this behaviour can
- /// be used to time the application of a MatchFinder by subclasses. Durations
- /// are automatically stored in a TimingVec.
- Transform(llvm::StringRef Name, bool EnableTiming)
- : Name(Name), EnableTiming(EnableTiming) {
+ /// \param Options Collection of options that affect all transforms.
+ Transform(llvm::StringRef Name, const TransformOptions &Options)
+ : Name(Name), GlobalOptions(Options) {
Reset();
}
@@ -136,7 +145,6 @@ public:
/// Upon return, \p ResultStates shall contain the result of performing this
/// transform on the files listed in \p SourcePaths.
virtual int apply(const FileContentsByPath &InputStates,
- RiskLevel MaxRiskLevel,
const clang::tooling::CompilationDatabase &Database,
const std::vector<std::string> &SourcePaths,
FileContentsByPath &ResultStates) = 0;
@@ -214,9 +222,11 @@ protected:
/// data for all sources processed by this transform.
void addTiming(llvm::StringRef Label, llvm::TimeRecord Duration);
+ const TransformOptions &Options() { return GlobalOptions; }
+
private:
const std::string Name;
- bool EnableTiming;
+ const TransformOptions &GlobalOptions;
TimingVec Timings;
unsigned AcceptedChanges;
unsigned RejectedChanges;
OpenPOWER on IntegriCloud