~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/CodeGen/MachinePassRegistry.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===-- llvm/CodeGen/MachinePassRegistry.h ----------------------*- 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
// This file contains the mechanics for machine function pass registries.  A
 
11
// function pass registry (MachinePassRegistry) is auto filled by the static
 
12
// constructors of MachinePassRegistryNode.  Further there is a command line
 
13
// parser (RegisterPassParser) which listens to each registry for additions
 
14
// and deletions, so that the appropriate command option is updated.
 
15
//
 
16
//===----------------------------------------------------------------------===//
 
17
 
 
18
#ifndef LLVM_CODEGEN_MACHINEPASSREGISTRY_H
 
19
#define LLVM_CODEGEN_MACHINEPASSREGISTRY_H
 
20
 
 
21
#include "llvm/CodeGen/Passes.h"
 
22
#include "llvm/Support/CommandLine.h"
 
23
 
 
24
namespace llvm {
 
25
 
 
26
typedef void *(*MachinePassCtor)();
 
27
 
 
28
 
 
29
//===----------------------------------------------------------------------===// 
 
30
///
 
31
/// MachinePassRegistryListener - Listener to adds and removals of nodes in
 
32
/// registration list.
 
33
///
 
34
//===----------------------------------------------------------------------===//
 
35
class MachinePassRegistryListener {
 
36
public:
 
37
  MachinePassRegistryListener() {}
 
38
  virtual ~MachinePassRegistryListener() {}
 
39
  virtual void NotifyAdd(const char *N, MachinePassCtor C, const char *D) = 0;
 
40
  virtual void NotifyRemove(const char *N) = 0;
 
41
};
 
42
 
 
43
 
 
44
//===----------------------------------------------------------------------===// 
 
45
///
 
46
/// MachinePassRegistryNode - Machine pass node stored in registration list.
 
47
///
 
48
//===----------------------------------------------------------------------===//
 
49
class MachinePassRegistryNode {
 
50
 
 
51
private:
 
52
 
 
53
  MachinePassRegistryNode *Next;        // Next function pass in list.
 
54
  const char *Name;                     // Name of function pass.
 
55
  const char *Description;              // Description string.
 
56
  MachinePassCtor Ctor;                 // Function pass creator.
 
57
  
 
58
public:
 
59
 
 
60
  MachinePassRegistryNode(const char *N, const char *D, MachinePassCtor C)
 
61
  : Next(NULL)
 
62
  , Name(N)
 
63
  , Description(D)
 
64
  , Ctor(C)
 
65
  {}
 
66
 
 
67
  // Accessors
 
68
  MachinePassRegistryNode *getNext()      const { return Next; }
 
69
  MachinePassRegistryNode **getNextAddress()    { return &Next; }
 
70
  const char *getName()                   const { return Name; }
 
71
  const char *getDescription()            const { return Description; }
 
72
  MachinePassCtor getCtor()               const { return Ctor; }
 
73
  void setNext(MachinePassRegistryNode *N)      { Next = N; }
 
74
  
 
75
};
 
76
 
 
77
 
 
78
//===----------------------------------------------------------------------===// 
 
79
///
 
80
/// MachinePassRegistry - Track the registration of machine passes.
 
81
///
 
82
//===----------------------------------------------------------------------===//
 
83
class MachinePassRegistry {
 
84
 
 
85
private:
 
86
 
 
87
  MachinePassRegistryNode *List;        // List of registry nodes.
 
88
  MachinePassCtor Default;              // Default function pass creator.
 
89
  MachinePassRegistryListener* Listener;// Listener for list adds are removes.
 
90
  
 
91
public:
 
92
 
 
93
  // NO CONSTRUCTOR - we don't want static constructor ordering to mess
 
94
  // with the registry.
 
95
 
 
96
  // Accessors.
 
97
  //
 
98
  MachinePassRegistryNode *getList()                    { return List; }
 
99
  MachinePassCtor getDefault()                          { return Default; }
 
100
  void setDefault(MachinePassCtor C)                    { Default = C; }
 
101
  void setListener(MachinePassRegistryListener *L)      { Listener = L; }
 
102
 
 
103
  /// Add - Adds a function pass to the registration list.
 
104
  ///
 
105
  void Add(MachinePassRegistryNode *Node);
 
106
 
 
107
  /// Remove - Removes a function pass from the registration list.
 
108
  ///
 
109
  void Remove(MachinePassRegistryNode *Node);
 
110
 
 
111
};
 
112
 
 
113
 
 
114
//===----------------------------------------------------------------------===//
 
115
///
 
116
/// RegisterPassParser class - Handle the addition of new machine passes.
 
117
///
 
118
//===----------------------------------------------------------------------===//
 
119
template<class RegistryClass>
 
120
class RegisterPassParser : public MachinePassRegistryListener,
 
121
                   public cl::parser<typename RegistryClass::FunctionPassCtor> {
 
122
public:
 
123
  RegisterPassParser() {}
 
124
  ~RegisterPassParser() { RegistryClass::setListener(NULL); }
 
125
 
 
126
  void initialize(cl::Option &O) {
 
127
    cl::parser<typename RegistryClass::FunctionPassCtor>::initialize(O);
 
128
    
 
129
    // Add existing passes to option.
 
130
    for (RegistryClass *Node = RegistryClass::getList();
 
131
         Node; Node = Node->getNext()) {
 
132
      this->addLiteralOption(Node->getName(),
 
133
                      (typename RegistryClass::FunctionPassCtor)Node->getCtor(),
 
134
                             Node->getDescription());
 
135
    }
 
136
    
 
137
    // Make sure we listen for list changes.
 
138
    RegistryClass::setListener(this);
 
139
  }
 
140
 
 
141
  // Implement the MachinePassRegistryListener callbacks.
 
142
  //
 
143
  virtual void NotifyAdd(const char *N,
 
144
                         MachinePassCtor C,
 
145
                         const char *D) {
 
146
    this->addLiteralOption(N, (typename RegistryClass::FunctionPassCtor)C, D);
 
147
  }
 
148
  virtual void NotifyRemove(const char *N) {
 
149
    this->removeLiteralOption(N);
 
150
  }
 
151
};
 
152
 
 
153
 
 
154
} // end namespace llvm
 
155
 
 
156
#endif