diff options
author | Justin Lebar <jlebar@google.com> | 2016-03-30 20:39:29 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-03-30 20:39:29 +0000 |
commit | 2fe132311205aa143f976c4922891a40d87583c3 (patch) | |
tree | b0cfaf65d3a92770fe4f00f790e44cf6d05b07dd /llvm/include | |
parent | c73c9d273dfe5b12ae50cc5f1a6c7b763ee1a746 (diff) | |
download | bcm5719-llvm-2fe132311205aa143f976c4922891a40d87583c3.tar.gz bcm5719-llvm-2fe132311205aa143f976c4922891a40d87583c3.zip |
[PassManager] Make PassManagerBuilder::addExtension take an std::function, rather than a function pointer.
Summary:
This gives callers flexibility to pass lambdas with captures, which lets
callers avoid the C-style void*-ptr closure style. (Currently, callers
in clang store state in the PassManagerBuilderBase arg.)
No functional change, and the new API is backwards-compatible.
Reviewers: chandlerc
Subscribers: joker.eph, cfe-commits
Differential Revision: http://reviews.llvm.org/D18613
llvm-svn: 264918
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h index 071c08400bb..ad14d83b0f3 100644 --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -59,8 +59,9 @@ class PassManagerBuilder { public: /// Extensions are passed the builder itself (so they can see how it is /// configured) as well as the pass manager to add stuff to. - typedef void (*ExtensionFn)(const PassManagerBuilder &Builder, - legacy::PassManagerBase &PM); + typedef std::function<void(const PassManagerBuilder &Builder, + legacy::PassManagerBase &PM)> + ExtensionFn; enum ExtensionPointTy { /// EP_EarlyAsPossible - This extension point allows adding passes before /// any other transformations, allowing them to see the code as it is coming @@ -143,7 +144,7 @@ public: private: /// ExtensionList - This is list of all of the extensions that are registered. - std::vector<std::pair<ExtensionPointTy, ExtensionFn> > Extensions; + std::vector<std::pair<ExtensionPointTy, ExtensionFn>> Extensions; public: PassManagerBuilder(); @@ -184,7 +185,7 @@ public: struct RegisterStandardPasses { RegisterStandardPasses(PassManagerBuilder::ExtensionPointTy Ty, PassManagerBuilder::ExtensionFn Fn) { - PassManagerBuilder::addGlobalExtension(Ty, Fn); + PassManagerBuilder::addGlobalExtension(Ty, std::move(Fn)); } }; |