Home | History | Annotate | Download | only in IR
      1 //===-- DerivedUser.h - Base for non-IR Users -------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef LLVM_IR_DERIVEDUSER_H
     11 #define LLVM_IR_DERIVEDUSER_H
     12 
     13 #include "llvm/IR/User.h"
     14 
     15 namespace llvm {
     16 
     17 /// Extension point for the Value hierarchy. All classes outside of lib/IR
     18 /// that wish to inherit from User should instead inherit from DerivedUser
     19 /// instead. Inheriting from this class is discouraged.
     20 ///
     21 /// Generally speaking, Value is the base of a closed class hierarchy
     22 /// that can't be extended by code outside of lib/IR. This class creates a
     23 /// loophole that allows classes outside of lib/IR to extend User to leverage
     24 /// its use/def list machinery.
     25 class DerivedUser : public User {
     26 protected:
     27   typedef void (*DeleteValueTy)(DerivedUser *);
     28 
     29 private:
     30   friend Value;
     31   DeleteValueTy DeleteValue;
     32 
     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 
     39 } // namespace llvm
     40 
     41 #endif // LLVM_IR_DERIVEDUSER_H
     42