DerivedUser.h 1.5 KB

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