blob: 67c483d3c497723c5759f069bb2a3494d2be0747 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- 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
15namespace llvm {
16
17class Type;
18class Use;
19
20/// Extension point for the Value hierarchy. All classes outside of lib/IR
21/// that wish to inherit from User should instead inherit from DerivedUser
22/// instead. Inheriting from this class is discouraged.
23///
24/// Generally speaking, Value is the base of a closed class hierarchy
25/// that can't be extended by code outside of lib/IR. This class creates a
26/// loophole that allows classes outside of lib/IR to extend User to leverage
27/// its use/def list machinery.
28class DerivedUser : public User {
29protected:
30 using DeleteValueTy = void (*)(DerivedUser *);
31
32private:
33 friend class Value;
34
35 DeleteValueTy DeleteValue;
36
37public:
38 DerivedUser(Type *Ty, unsigned VK, Use *U, unsigned NumOps,
39 DeleteValueTy DeleteValue)
40 : User(Ty, VK, U, NumOps), DeleteValue(DeleteValue) {}
41};
42
43} // end namespace llvm
44
45#endif // LLVM_IR_DERIVEDUSER_H