[clang-tools-extra] r178901 - Fix symbol dependency errors introduced with libmigrateCore
Edwin Vane
edwin.vane at intel.com
Fri Apr 5 12:18:13 PDT 2013
Author: revane
Date: Fri Apr 5 14:18:13 2013
New Revision: 178901
URL: http://llvm.org/viewvc/llvm-project?rev=178901&view=rev
Log:
Fix symbol dependency errors introduced with libmigrateCore
With cpp11-migrate core functionality moved to a separate library (for enabling
unit tests) this library contained code that referenced symbols that are still
in the main binary. On some platforms, the shared library build broke as a
result. This revision fixes the dependency problem and is safe for the eventual
lib-ification of the transforms as well.
Modified:
clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.cpp
clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.h
clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp
Modified: clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.cpp?rev=178901&r1=178900&r2=178901&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.cpp Fri Apr 5 14:18:13 2013
@@ -13,17 +13,10 @@
//===----------------------------------------------------------------------===//
#include "Core/Transforms.h"
-#include "LoopConvert/LoopConvert.h"
-#include "UseNullptr/UseNullptr.h"
-#include "UseAuto/UseAuto.h"
+#include "Core/Transform.h"
namespace cl = llvm::cl;
-template <typename T>
-Transform *ConstructTransform() {
- return new T();
-}
-
Transforms::~Transforms() {
for (std::vector<Transform*>::iterator I = ChosenTransforms.begin(),
E = ChosenTransforms.end(); I != E; ++I) {
@@ -35,26 +28,11 @@ Transforms::~Transforms() {
}
}
-void Transforms::createTransformOpts() {
- Options.push_back(
- OptionVec::value_type(
- new cl::opt<bool>("loop-convert",
- cl::desc("Make use of range-based for loops where possible")),
- &ConstructTransform<LoopConvertTransform>));
-
- Options.push_back(
- OptionVec::value_type(
- new cl::opt<bool>("use-nullptr",
- cl::desc("Make use of nullptr keyword where possible")),
- &ConstructTransform<UseNullptrTransform>));
-
- Options.push_back(
- OptionVec::value_type(
- new cl::opt<bool>("use-auto",
- cl::desc("Use of 'auto' type specifier")),
- &ConstructTransform<UseAutoTransform>));
-
- // Add more transform options here.
+void Transforms::registerTransform(llvm::StringRef OptName,
+ llvm::StringRef Description,
+ TransformCreator Creator) {
+ Options.push_back(OptionVec::value_type(
+ new cl::opt<bool>(OptName.data(), cl::desc(Description.data())), Creator));
}
void Transforms::createSelectedTransforms() {
Modified: clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.h?rev=178901&r1=178900&r2=178901&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.h (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Core/Transforms.h Fri Apr 5 14:18:13 2013
@@ -17,6 +17,7 @@
#define LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_TRANSFORMS_H
#include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/StringRef.h"
#include <vector>
// Forward declarations
@@ -28,6 +29,10 @@ class Option;
class Transform;
typedef Transform *(*TransformCreator)();
+template <typename T>
+Transform *ConstructTransform() {
+ return new T();
+}
/// \brief Class encapsulating the creation of command line bool options
/// for each transform and instantiating transforms chosen by the user.
@@ -40,10 +45,12 @@ public:
~Transforms();
- /// \brief Create command line options using LLVM's command line library.
+ /// \brief Registers a transform causing the transform to be made available
+ /// on the command line.
///
- /// Be sure to call *before* parsing options.
- void createTransformOpts();
+ /// Be sure to register all transforms *before* parsing command line options.
+ void registerTransform(llvm::StringRef OptName, llvm::StringRef Description,
+ TransformCreator Creator);
/// \brief Instantiate all transforms that were selected on the command line.
///
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp?rev=178901&r1=178900&r2=178901&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp Fri Apr 5 14:18:13 2013
@@ -17,6 +17,9 @@
#include "Core/Transforms.h"
#include "Core/Transform.h"
+#include "LoopConvert/LoopConvert.h"
+#include "UseNullptr/UseNullptr.h"
+#include "UseAuto/UseAuto.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
@@ -59,7 +62,16 @@ int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
Transforms TransformManager;
- TransformManager.createTransformOpts();
+ TransformManager.registerTransform(
+ "loop-convert", "Make use of range-based for loops where possible",
+ &ConstructTransform<LoopConvertTransform>);
+ TransformManager.registerTransform(
+ "use-nullptr", "Make use of nullptr keyword where possible",
+ &ConstructTransform<UseNullptrTransform>);
+ TransformManager.registerTransform(
+ "use-auto", "Use of 'auto' type specifier",
+ &ConstructTransform<UseAutoTransform>);
+ // Add more transform options here.
// This causes options to be parsed.
CommonOptionsParser OptionsParser(argc, argv);
More information about the cfe-commits
mailing list