From ebde78c4c6149dfd6dfcddd39ed07e5aec1860ed Mon Sep 17 00:00:00 2001 From: Guillaume Papin Date: Wed, 24 Jul 2013 14:24:33 +0000 Subject: cpp11-migrate: Register the transforms automatically using llvm::Registry With this change each transform now register a factory. The factories are registered using an llvm::Registry which makes them available globally. llvm-svn: 187041 --- clang-tools-extra/cpp11-migrate/UseAuto/UseAuto.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'clang-tools-extra/cpp11-migrate/UseAuto/UseAuto.cpp') diff --git a/clang-tools-extra/cpp11-migrate/UseAuto/UseAuto.cpp b/clang-tools-extra/cpp11-migrate/UseAuto/UseAuto.cpp index b85f54712a7..47c2cd53215 100644 --- a/clang-tools-extra/cpp11-migrate/UseAuto/UseAuto.cpp +++ b/clang-tools-extra/cpp11-migrate/UseAuto/UseAuto.cpp @@ -47,3 +47,17 @@ int UseAutoTransform::apply(FileOverrides &InputStates, return 0; } + +struct UseAutoFactory : TransformFactory { + Transform *createTransform(const TransformOptions &Opts) LLVM_OVERRIDE { + return new UseAutoTransform(Opts); + } +}; + +// Register the factory using this statically initialized variable. +static TransformFactoryRegistry::Add +X("use-auto", "Use of 'auto' type specifier"); + +// This anchor is used to force the linker to link in the generated object file +// and thus register the factory. +volatile int UseAutoTransformAnchorSource = 0; -- cgit v1.2.3