summaryrefslogtreecommitdiff
path: root/src/preprocessing/preprocessing_pass_registry.h
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2018-10-02 14:55:21 -0700
committerGitHub <noreply@github.com>2018-10-02 14:55:21 -0700
commit937d37ef78d3ef445335928d498422083df74d77 (patch)
tree0e686ba7f9a7d745bc86c71c8629ee21510bb728 /src/preprocessing/preprocessing_pass_registry.h
parenta580349bbb39fa9681ab2e2d05dd448f8b082399 (diff)
Make registration of preprocessing passes explicit (#2564)
As it turns out, self-registering types are problematic with static linkage [0]. Instead of fixing the issue with linker flags, which seems possible but also brittle (e.g. the flags may be different for different linkers), this commit adds an explicit registration of each preprocessing pass. [0] https://www.bfilipek.com/2018/02/static-vars-static-lib.html
Diffstat (limited to 'src/preprocessing/preprocessing_pass_registry.h')
-rw-r--r--src/preprocessing/preprocessing_pass_registry.h45
1 files changed, 7 insertions, 38 deletions
diff --git a/src/preprocessing/preprocessing_pass_registry.h b/src/preprocessing/preprocessing_pass_registry.h
index 44e9b4e6e..e6c98c1f9 100644
--- a/src/preprocessing/preprocessing_pass_registry.h
+++ b/src/preprocessing/preprocessing_pass_registry.h
@@ -12,8 +12,7 @@
** \brief The preprocessing pass registry
**
** This file defines the classes PreprocessingPassRegistry, which keeps track
- ** of the available preprocessing passes, and RegisterPass, which registers a
- ** preprocessing pass with the registry.
+ ** of the available preprocessing passes.
**/
#include "cvc4_private.h"
@@ -80,6 +79,12 @@ class PreprocessingPassRegistry {
private:
/**
+ * Private constructor for the preprocessing pass registry. The
+ * registry is a singleton and no other instance should be created.
+ */
+ PreprocessingPassRegistry();
+
+ /**
* Map of available preprocessing passes, mapping from preprocessing pass
* name to a function that constructs a corresponding instance.
*/
@@ -89,42 +94,6 @@ class PreprocessingPassRegistry {
d_ppInfo;
}; // class PreprocessingPassRegistry
-/**
- * Class used to register a preprocessing pass. In the source file of a given
- * pass, create a static instance of this class, e.g.:
- *
- * static RegisterPass<MyPass> X("my-pass");
- *
- * where `MyPass` is the class of your pass and "my-pass" is its name. This
- * registers the pass with the `PreprocessingPassRegistry`.
- */
-template <class T>
-class RegisterPass
-{
- public:
- /**
- * Creates a new preprocessing pass registration.
- *
- * @param name The name that should be associated with the preprocessing pass
- */
- RegisterPass(const std::string& name)
- {
- PreprocessingPassRegistry::getInstance().registerPassInfo(name, callCtor);
- }
-
- /**
- * This method is used by the `PreprocessingPassRegistry` to create a new
- * instance of the preprocessing pass T.
- *
- * @param ppCtx The preprocessing pass context passed to the constructor of
- * the preprocessing pass
- */
- static PreprocessingPass* callCtor(PreprocessingPassContext* ppCtx)
- {
- return new T(ppCtx);
- }
-}; // class RegisterPass
-
} // namespace preprocessing
} // namespace CVC4
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback