[llvm] r257727 - [GC] Remove a bunch of unused complexity from Registry and RegistryParser [NFCI]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 13 16:45:16 PST 2016
Author: reames
Date: Wed Jan 13 18:45:15 2016
New Revision: 257727
URL: http://llvm.org/viewvc/llvm-project?rev=257727&view=rev
Log:
[GC] Remove a bunch of unused complexity from Registry and RegistryParser [NFCI]
The only two Registries we have in the system are the GCStrategy and GCMetadataPrinter ones. Registry has a bunch of problems - for instance, order of initialization is undefined - and the code was overly general for what was actually used. I hope to completely kill Registry in the near future, but for now, just delete all the unused listener and parsing support.
Removed:
llvm/trunk/include/llvm/Support/RegistryParser.h
Modified:
llvm/trunk/include/llvm/Support/Registry.h
Modified: llvm/trunk/include/llvm/Support/Registry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Registry.h?rev=257727&r1=257726&r2=257727&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Registry.h (original)
+++ llvm/trunk/include/llvm/Support/Registry.h Wed Jan 13 18:45:15 2016
@@ -62,23 +62,14 @@ namespace llvm {
typedef typename U::entry entry;
class node;
- class listener;
class iterator;
private:
Registry() = delete;
- static void Announce(const entry &E) {
- for (listener *Cur = ListenerHead; Cur; Cur = Cur->Next)
- Cur->registered(E);
- }
-
friend class node;
static node *Head, *Tail;
- friend class listener;
- static listener *ListenerHead, *ListenerTail;
-
public:
/// Node in linked list of entries.
///
@@ -95,8 +86,6 @@ namespace llvm {
else
Head = this;
Tail = this;
-
- Announce(V);
}
};
@@ -122,60 +111,6 @@ namespace llvm {
return make_range(begin(), end());
}
- /// Abstract base class for registry listeners, which are informed when new
- /// entries are added to the registry. Simply subclass and instantiate:
- ///
- /// \code
- /// class CollectorPrinter : public Registry<Collector>::listener {
- /// protected:
- /// void registered(const Registry<Collector>::entry &e) {
- /// cerr << "collector now available: " << e->getName() << "\n";
- /// }
- ///
- /// public:
- /// CollectorPrinter() { init(); } // Print those already registered.
- /// };
- ///
- /// CollectorPrinter Printer;
- /// \endcode
- class listener {
- listener *Prev, *Next;
-
- friend void Registry::Announce(const entry &E);
-
- protected:
- /// Called when an entry is added to the registry.
- ///
- virtual void registered(const entry &) = 0;
-
- /// Calls 'registered' for each pre-existing entry.
- ///
- void init() {
- for (iterator I = begin(), E = end(); I != E; ++I)
- registered(*I);
- }
-
- public:
- listener() : Prev(ListenerTail), Next(nullptr) {
- if (Prev)
- Prev->Next = this;
- else
- ListenerHead = this;
- ListenerTail = this;
- }
-
- virtual ~listener() {
- if (Next)
- Next->Prev = Prev;
- else
- ListenerTail = Prev;
- if (Prev)
- Prev->Next = Next;
- else
- ListenerHead = Next;
- }
- };
-
/// A static registration template. Use like such:
///
/// Registry<Collector>::Add<FancyGC>
@@ -203,8 +138,6 @@ namespace llvm {
Add(const char *Name, const char *Desc)
: Entry(Name, Desc, CtorFn), Node(Entry) {}
};
-
- /// Registry::Parser now lives in llvm/Support/RegistryParser.h.
};
// Since these are defined in a header file, plugins must be sure to export
@@ -215,13 +148,6 @@ namespace llvm {
template <typename T, typename U>
typename Registry<T,U>::node *Registry<T,U>::Tail;
-
- template <typename T, typename U>
- typename Registry<T,U>::listener *Registry<T,U>::ListenerHead;
-
- template <typename T, typename U>
- typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
-
} // end namespace llvm
#endif // LLVM_SUPPORT_REGISTRY_H
Removed: llvm/trunk/include/llvm/Support/RegistryParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/RegistryParser.h?rev=257726&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/RegistryParser.h (original)
+++ llvm/trunk/include/llvm/Support/RegistryParser.h (removed)
@@ -1,55 +0,0 @@
-//=== RegistryParser.h - Linker-supported plugin registries -----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Defines a command-line parser for a registry.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_REGISTRYPARSER_H
-#define LLVM_SUPPORT_REGISTRYPARSER_H
-
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Registry.h"
-
-namespace llvm {
-
- /// A command-line parser for a registry. Use like such:
- ///
- /// static cl::opt<Registry<Collector>::entry, false,
- /// RegistryParser<Collector> >
- /// GCOpt("gc", cl::desc("Garbage collector to use."),
- /// cl::value_desc());
- ///
- /// To make use of the value:
- ///
- /// Collector *TheCollector = GCOpt->instantiate();
- ///
- template <typename T, typename U = RegistryTraits<T> >
- class RegistryParser :
- public cl::parser<const typename U::entry*>,
- public Registry<T, U>::listener {
- typedef U traits;
- typedef typename U::entry entry;
- typedef typename Registry<T, U>::listener listener;
-
- protected:
- void registered(const entry &E) {
- addLiteralOption(traits::nameof(E), &E, traits::descof(E));
- }
-
- public:
- void initialize(cl::Option &O) {
- listener::init();
- cl::parser<const typename U::entry*>::initialize(O);
- }
- };
-
-}
-
-#endif // LLVM_SUPPORT_REGISTRYPARSER_H
More information about the llvm-commits
mailing list