DerivedUser.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //===- DerivedUser.h - Base for non-IR Users --------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_IR_DERIVEDUSER_H
  9. #define LLVM_IR_DERIVEDUSER_H
  10. #include "llvm/IR/User.h"
  11. namespace llvm {
  12. class Type;
  13. class Use;
  14. /// Extension point for the Value hierarchy. All classes outside of lib/IR
  15. /// that wish to inherit from User should instead inherit from DerivedUser
  16. /// instead. Inheriting from this class is discouraged.
  17. ///
  18. /// Generally speaking, Value is the base of a closed class hierarchy
  19. /// that can't be extended by code outside of lib/IR. This class creates a
  20. /// loophole that allows classes outside of lib/IR to extend User to leverage
  21. /// its use/def list machinery.
  22. class DerivedUser : public User {
  23. protected:
  24. using DeleteValueTy = void (*)(DerivedUser *);
  25. private:
  26. friend class Value;
  27. DeleteValueTy DeleteValue;
  28. public:
  29. DerivedUser(Type *Ty, unsigned VK, Use *U, unsigned NumOps,
  30. DeleteValueTy DeleteValue)
  31. : User(Ty, VK, U, NumOps), DeleteValue(DeleteValue) {}
  32. };
  33. } // end namespace llvm
  34. #endif // LLVM_IR_DERIVEDUSER_H