~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/ValueSymbolTable.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/ValueSymbolTable.h - Implement a Value Symtab ------*- 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 implements the name/Value symbol table for LLVM.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_VALUE_SYMBOL_TABLE_H
 
15
#define LLVM_VALUE_SYMBOL_TABLE_H
 
16
 
 
17
#include "llvm/Value.h"
 
18
#include "llvm/ADT/StringMap.h"
 
19
#include "llvm/System/DataTypes.h"
 
20
 
 
21
namespace llvm {
 
22
  template<typename ValueSubClass, typename ItemParentClass>
 
23
        class SymbolTableListTraits;
 
24
  class BasicBlock;
 
25
  class Function;
 
26
  class NamedMDNode;
 
27
  class Module;
 
28
  class StringRef;
 
29
 
 
30
/// This class provides a symbol table of name/value pairs. It is essentially
 
31
/// a std::map<std::string,Value*> but has a controlled interface provided by
 
32
/// LLVM as well as ensuring uniqueness of names.
 
33
///
 
34
class ValueSymbolTable {
 
35
  friend class Value;
 
36
  friend class SymbolTableListTraits<Argument, Function>;
 
37
  friend class SymbolTableListTraits<BasicBlock, Function>;
 
38
  friend class SymbolTableListTraits<Instruction, BasicBlock>;
 
39
  friend class SymbolTableListTraits<Function, Module>;
 
40
  friend class SymbolTableListTraits<GlobalVariable, Module>;
 
41
  friend class SymbolTableListTraits<GlobalAlias, Module>;
 
42
/// @name Types
 
43
/// @{
 
44
public:
 
45
  /// @brief A mapping of names to values.
 
46
  typedef StringMap<Value*> ValueMap;
 
47
 
 
48
  /// @brief An iterator over a ValueMap.
 
49
  typedef ValueMap::iterator iterator;
 
50
 
 
51
  /// @brief A const_iterator over a ValueMap.
 
52
  typedef ValueMap::const_iterator const_iterator;
 
53
 
 
54
/// @}
 
55
/// @name Constructors
 
56
/// @{
 
57
public:
 
58
 
 
59
  ValueSymbolTable() : vmap(0), LastUnique(0) {}
 
60
  ~ValueSymbolTable();
 
61
 
 
62
/// @}
 
63
/// @name Accessors
 
64
/// @{
 
65
public:
 
66
 
 
67
  /// This method finds the value with the given \p Name in the
 
68
  /// the symbol table. 
 
69
  /// @returns the value associated with the \p Name
 
70
  /// @brief Lookup a named Value.
 
71
  Value *lookup(StringRef Name) const { return vmap.lookup(Name); }
 
72
 
 
73
  /// @returns true iff the symbol table is empty
 
74
  /// @brief Determine if the symbol table is empty
 
75
  inline bool empty() const { return vmap.empty(); }
 
76
 
 
77
  /// @brief The number of name/type pairs is returned.
 
78
  inline unsigned size() const { return unsigned(vmap.size()); }
 
79
 
 
80
  /// This function can be used from the debugger to display the
 
81
  /// content of the symbol table while debugging.
 
82
  /// @brief Print out symbol table on stderr
 
83
  void dump() const;
 
84
 
 
85
/// @}
 
86
/// @name Iteration
 
87
/// @{
 
88
public:
 
89
  /// @brief Get an iterator that from the beginning of the symbol table.
 
90
  inline iterator begin() { return vmap.begin(); }
 
91
 
 
92
  /// @brief Get a const_iterator that from the beginning of the symbol table.
 
93
  inline const_iterator begin() const { return vmap.begin(); }
 
94
 
 
95
  /// @brief Get an iterator to the end of the symbol table.
 
96
  inline iterator end() { return vmap.end(); }
 
97
 
 
98
  /// @brief Get a const_iterator to the end of the symbol table.
 
99
  inline const_iterator end() const { return vmap.end(); }
 
100
  
 
101
/// @}
 
102
/// @name Mutators
 
103
/// @{
 
104
private:
 
105
  /// This method adds the provided value \p N to the symbol table.  The Value
 
106
  /// must have a name which is used to place the value in the symbol table. 
 
107
  /// If the inserted name conflicts, this renames the value.
 
108
  /// @brief Add a named value to the symbol table
 
109
  void reinsertValue(Value *V);
 
110
    
 
111
  /// createValueName - This method attempts to create a value name and insert
 
112
  /// it into the symbol table with the specified name.  If it conflicts, it
 
113
  /// auto-renames the name and returns that instead.
 
114
  ValueName *createValueName(StringRef Name, Value *V);
 
115
  
 
116
  /// This method removes a value from the symbol table.  It leaves the
 
117
  /// ValueName attached to the value, but it is no longer inserted in the
 
118
  /// symtab.
 
119
  void removeValueName(ValueName *V);
 
120
  
 
121
/// @}
 
122
/// @name Internal Data
 
123
/// @{
 
124
private:
 
125
  ValueMap vmap;                    ///< The map that holds the symbol table.
 
126
  mutable uint32_t LastUnique; ///< Counter for tracking unique names
 
127
 
 
128
/// @}
 
129
};
 
130
 
 
131
/// This class provides a symbol table of name/NamedMDNode pairs. It is 
 
132
/// essentially a StringMap wrapper.
 
133
 
 
134
class MDSymbolTable {
 
135
  friend class SymbolTableListTraits<NamedMDNode, Module>;
 
136
/// @name Types
 
137
/// @{
 
138
private:
 
139
  /// @brief A mapping of names to metadata
 
140
  typedef StringMap<NamedMDNode*> MDMap;
 
141
 
 
142
public:
 
143
  /// @brief An iterator over a ValueMap.
 
144
  typedef MDMap::iterator iterator;
 
145
 
 
146
  /// @brief A const_iterator over a ValueMap.
 
147
  typedef MDMap::const_iterator const_iterator;
 
148
 
 
149
/// @}
 
150
/// @name Constructors
 
151
/// @{
 
152
public:
 
153
 
 
154
  MDSymbolTable(const MDNode &);             // DO NOT IMPLEMENT
 
155
  void operator=(const MDSymbolTable &);     // DO NOT IMPLEMENT
 
156
  MDSymbolTable() : mmap(0) {}
 
157
  ~MDSymbolTable();
 
158
 
 
159
/// @}
 
160
/// @name Accessors
 
161
/// @{
 
162
public:
 
163
 
 
164
  /// This method finds the value with the given \p Name in the
 
165
  /// the symbol table. 
 
166
  /// @returns the NamedMDNode associated with the \p Name
 
167
  /// @brief Lookup a named Value.
 
168
  NamedMDNode *lookup(StringRef Name) const { return mmap.lookup(Name); }
 
169
 
 
170
  /// @returns true iff the symbol table is empty
 
171
  /// @brief Determine if the symbol table is empty
 
172
  inline bool empty() const { return mmap.empty(); }
 
173
 
 
174
  /// @brief The number of name/type pairs is returned.
 
175
  inline unsigned size() const { return unsigned(mmap.size()); }
 
176
 
 
177
/// @}
 
178
/// @name Iteration
 
179
/// @{
 
180
public:
 
181
  /// @brief Get an iterator that from the beginning of the symbol table.
 
182
  inline iterator begin() { return mmap.begin(); }
 
183
 
 
184
  /// @brief Get a const_iterator that from the beginning of the symbol table.
 
185
  inline const_iterator begin() const { return mmap.begin(); }
 
186
 
 
187
  /// @brief Get an iterator to the end of the symbol table.
 
188
  inline iterator end() { return mmap.end(); }
 
189
 
 
190
  /// @brief Get a const_iterator to the end of the symbol table.
 
191
  inline const_iterator end() const { return mmap.end(); }
 
192
  
 
193
/// @}
 
194
/// @name Mutators
 
195
/// @{
 
196
public:
 
197
  /// insert - The method inserts a new entry into the stringmap. This will
 
198
  /// replace existing entry, if any.
 
199
  void insert(StringRef Name,  NamedMDNode *Node) {
 
200
    StringMapEntry<NamedMDNode *> &Entry = 
 
201
      mmap.GetOrCreateValue(Name, Node);
 
202
    if (Entry.getValue() != Node) {
 
203
      mmap.remove(&Entry);
 
204
      (void) mmap.GetOrCreateValue(Name, Node);
 
205
    }
 
206
  }
 
207
  
 
208
  /// This method removes a NamedMDNode from the symbol table.  
 
209
  void remove(StringRef Name) { mmap.erase(Name); }
 
210
 
 
211
/// @}
 
212
/// @name Internal Data
 
213
/// @{
 
214
private:
 
215
  MDMap mmap;                  ///< The map that holds the symbol table.
 
216
/// @}
 
217
};
 
218
 
 
219
} // End llvm namespace
 
220
 
 
221
#endif