Author: Reid Kleckner
Date: 2019-11-15T13:32:52-08:00
New Revision: 631be5c0d41161057d02fe08a7aeb4fbde1a91d6

URL: 
https://github.com/llvm/llvm-project/commit/631be5c0d41161057d02fe08a7aeb4fbde1a91d6
DIFF: 
https://github.com/llvm/llvm-project/commit/631be5c0d41161057d02fe08a7aeb4fbde1a91d6.diff

LOG: Remove Support/Options.h, it is unused

It was added in 2014 in 732e0aa9fb84f1 with one use in Scalarizer.cpp.
That one use was then removed when porting to the new pass manager in
2018 in b6f76002d9158628e78.

While the RFC and the desire to get off of static initializers for
cl::opt all still stand, this code is now dead, and I think we should
delete this code until someone is ready to do the migration.

There were many clients of CommandLine.h that were it transitively
through LLVMContext.h, so I cleaned that up in 4c1a1d3cf97e1ede466.

Reviewers: beanz

Differential Revision: https://reviews.llvm.org/D70280

Added: 
    

Modified: 
    clang/tools/clang-scan-deps/ClangScanDeps.cpp
    llvm/include/llvm/IR/LLVMContext.h
    llvm/lib/Support/CMakeLists.txt
    llvm/lib/Support/DebugCounter.cpp
    llvm/lib/Support/Signals.cpp
    llvm/lib/Transforms/Scalar/Scalarizer.cpp

Removed: 
    llvm/include/llvm/Support/Options.h
    llvm/lib/Support/Options.cpp


################################################################################
diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 3d3c76c7714a..bd463cbdeee9 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -12,8 +12,8 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
-#include "llvm/Support/Options.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"

diff  --git a/llvm/include/llvm/IR/LLVMContext.h 
b/llvm/include/llvm/IR/LLVMContext.h
index ea272740ba9d..39d19b7cffd9 100644
--- a/llvm/include/llvm/IR/LLVMContext.h
+++ b/llvm/include/llvm/IR/LLVMContext.h
@@ -17,7 +17,6 @@
 #include "llvm-c/Types.h"
 #include "llvm/IR/DiagnosticHandler.h"
 #include "llvm/Support/CBindingWrapping.h"
-#include "llvm/Support/Options.h"
 #include <cstdint>
 #include <memory>
 #include <string>
@@ -288,14 +287,6 @@ class LLVMContext {
   void emitError(const Instruction *I, const Twine &ErrorStr);
   void emitError(const Twine &ErrorStr);
 
-  /// Query for a debug option's value.
-  ///
-  /// This function returns typed data populated from command line parsing.
-  template <typename ValT, typename Base, ValT(Base::*Mem)>
-  ValT getOption() const {
-    return OptionRegistry::instance().template get<ValT, Base, Mem>();
-  }
-
   /// Access the object which can disable optional passes and individual
   /// optimizations at compile time.
   OptPassGate &getOptPassGate() const;

diff  --git a/llvm/include/llvm/Support/Options.h 
b/llvm/include/llvm/Support/Options.h
deleted file mode 100644
index d02ef85a75bf..000000000000
--- a/llvm/include/llvm/Support/Options.h
+++ /dev/null
@@ -1,119 +0,0 @@
-//===- llvm/Support/Options.h - Debug options support -----------*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-/// \file
-/// This file declares helper objects for defining debug options that can be
-/// configured via the command line. The new API currently builds on the 
cl::opt
-/// API, but does not require the use of static globals.
-///
-/// With this API options are registered during initialization. For passes, 
this
-/// happens during pass initialization. Passes with options will call a static
-/// registerOptions method during initialization that registers options with 
the
-/// OptionRegistry. An example implementation of registerOptions is:
-///
-/// static void registerOptions() {
-///   OptionRegistry::registerOption<bool, Scalarizer,
-///                                &Scalarizer::ScalarizeLoadStore>(
-///       "scalarize-load-store",
-///       "Allow the scalarizer pass to scalarize loads and store", false);
-/// }
-///
-/// When reading data for options the interface is via the LLVMContext. Option
-/// data for passes should be read from the context during doInitialization. An
-/// example of reading the above option would be:
-///
-/// ScalarizeLoadStore =
-///   M.getContext().getOption<bool,
-///                            Scalarizer,
-///                            &Scalarizer::ScalarizeLoadStore>();
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_OPTIONS_H
-#define LLVM_SUPPORT_OPTIONS_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/Support/CommandLine.h"
-
-namespace llvm {
-
-namespace detail {
-
-// Options are keyed of the unique address of a static character synthesized
-// based on template arguments.
-template <typename ValT, typename Base, ValT(Base::*Mem)> class OptionKey {
-public:
-  static char ID;
-};
-
-template <typename ValT, typename Base, ValT(Base::*Mem)>
-char OptionKey<ValT, Base, Mem>::ID = 0;
-
-} // namespace detail
-
-/// Singleton class used to register debug options.
-///
-/// The OptionRegistry is responsible for managing lifetimes of the options and
-/// provides interfaces for option registration and reading values from 
options.
-/// This object is a singleton, only one instance should ever exist so that all
-/// options are registered in the same place.
-class OptionRegistry {
-private:
-  DenseMap<void *, cl::Option *> Options;
-
-  /// Adds a cl::Option to the registry.
-  ///
-  /// \param Key unique key for option
-  /// \param O option to map to \p Key
-  ///
-  /// Allocated cl::Options are owned by the OptionRegistry and are deallocated
-  /// on destruction or removal
-  void addOption(void *Key, cl::Option *O);
-
-public:
-  ~OptionRegistry();
-  OptionRegistry() {}
-
-  /// Returns a reference to the singleton instance.
-  static OptionRegistry &instance();
-
-  /// Registers an option with the OptionRegistry singleton.
-  ///
-  /// \tparam ValT type of the option's data
-  /// \tparam Base class used to key the option
-  /// \tparam Mem member of \p Base used for keying the option
-  ///
-  /// Options are keyed off the template parameters to generate unique static
-  /// characters. The template parameters are (1) the type of the data the
-  /// option stores (\p ValT), the class that will read the option (\p Base),
-  /// and the member that the class will store the data into (\p Mem).
-  template <typename ValT, typename Base, ValT(Base::*Mem)>
-  static void registerOption(StringRef ArgStr, StringRef Desc,
-                             const ValT &InitValue) {
-    cl::opt<ValT> *Option = new cl::opt<ValT>(ArgStr, cl::desc(Desc),
-                                              cl::Hidden, cl::init(InitValue));
-    instance().addOption(&detail::OptionKey<ValT, Base, Mem>::ID, Option);
-  }
-
-  /// Returns the value of the option.
-  ///
-  /// \tparam ValT type of the option's data
-  /// \tparam Base class used to key the option
-  /// \tparam Mem member of \p Base used for keying the option
-  ///
-  /// Reads option values based on the key generated by the template 
parameters.
-  /// Keying for get() is the same as keying for registerOption.
-  template <typename ValT, typename Base, ValT(Base::*Mem)> ValT get() const {
-    auto It = Options.find(&detail::OptionKey<ValT, Base, Mem>::ID);
-    assert(It != Options.end() && "Option not in OptionRegistry");
-    return *(cl::opt<ValT> *)It->second;
-  }
-};
-
-} // namespace llvm
-
-#endif

diff  --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index cc80175185b9..824ceec6a212 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -116,7 +116,6 @@ add_llvm_library(LLVMSupport
   MD5.cpp
   NativeFormatting.cpp
   Optional.cpp
-  Options.cpp
   Parallel.cpp
   PluginLoader.cpp
   PrettyStackTrace.cpp

diff  --git a/llvm/lib/Support/DebugCounter.cpp 
b/llvm/lib/Support/DebugCounter.cpp
index 6598103658da..1e3ec300964c 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -2,7 +2,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/Options.h"
 
 using namespace llvm;
 

diff  --git a/llvm/lib/Support/Options.cpp b/llvm/lib/Support/Options.cpp
deleted file mode 100644
index 770b7381c20e..000000000000
--- a/llvm/lib/Support/Options.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===- llvm/Support/Options.cpp - Debug options support ---------*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the helper objects for defining debug options using the
-// new API built on cl::opt, but not requiring the use of static globals.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/Options.h"
-#include "llvm/Support/ManagedStatic.h"
-
-using namespace llvm;
-
-OptionRegistry::~OptionRegistry() {
-  for (auto IT = Options.begin(); IT != Options.end(); ++IT)
-    delete IT->second;
-}
-
-void OptionRegistry::addOption(void *Key, cl::Option *O) {
-  assert(Options.find(Key) == Options.end() &&
-         "Argument with this key already registerd");
-  Options.insert(std::make_pair(Key, O));
-}
-
-static ManagedStatic<OptionRegistry> OR;
-
-OptionRegistry &OptionRegistry::instance() { return *OR; }

diff  --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp
index 173a07f009d2..add6fde0eb5e 100644
--- a/llvm/lib/Support/Signals.cpp
+++ b/llvm/lib/Support/Signals.cpp
@@ -15,19 +15,19 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Options.h"
 #include <vector>
 
 
//===----------------------------------------------------------------------===//

diff  --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp 
b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 003d34317f34..c25c6c632b8f 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -38,8 +38,8 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Support/Options.h"
 #include "llvm/Transforms/Scalar.h"
 #include <cassert>
 #include <cstdint>


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to