~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Value.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/Value.h - Definition of the Value class ------------*- 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 declares the Value class. 
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_VALUE_H
 
15
#define LLVM_VALUE_H
 
16
 
 
17
#include "llvm/AbstractTypeUser.h"
 
18
#include "llvm/Use.h"
 
19
#include "llvm/ADT/StringRef.h"
 
20
#include "llvm/Support/Casting.h"
 
21
#include <string>
 
22
 
 
23
namespace llvm {
 
24
 
 
25
class Constant;
 
26
class Argument;
 
27
class Instruction;
 
28
class BasicBlock;
 
29
class GlobalValue;
 
30
class Function;
 
31
class GlobalVariable;
 
32
class GlobalAlias;
 
33
class InlineAsm;
 
34
class ValueSymbolTable;
 
35
class TypeSymbolTable;
 
36
template<typename ValueTy> class StringMapEntry;
 
37
template <typename ValueTy = Value>
 
38
class AssertingVH;
 
39
typedef StringMapEntry<Value*> ValueName;
 
40
class raw_ostream;
 
41
class AssemblyAnnotationWriter;
 
42
class ValueHandleBase;
 
43
class LLVMContext;
 
44
class Twine;
 
45
class MDNode;
 
46
 
 
47
//===----------------------------------------------------------------------===//
 
48
//                                 Value Class
 
49
//===----------------------------------------------------------------------===//
 
50
 
 
51
/// This is a very important LLVM class. It is the base class of all values 
 
52
/// computed by a program that may be used as operands to other values. Value is
 
53
/// the super class of other important classes such as Instruction and Function.
 
54
/// All Values have a Type. Type is not a subclass of Value. All types can have
 
55
/// a name and they should belong to some Module. Setting the name on the Value
 
56
/// automatically updates the module's symbol table.
 
57
///
 
58
/// Every value has a "use list" that keeps track of which other Values are
 
59
/// using this Value.  A Value can also have an arbitrary number of ValueHandle
 
60
/// objects that watch it and listen to RAUW and Destroy events.  See
 
61
/// llvm/Support/ValueHandle.h for details.
 
62
///
 
63
/// @brief LLVM Value Representation
 
64
class Value {
 
65
  const unsigned char SubclassID;   // Subclass identifier (for isa/dyn_cast)
 
66
  unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
 
67
protected:
 
68
  /// SubclassOptionalData - This member is similar to SubclassData, however it
 
69
  /// is for holding information which may be used to aid optimization, but
 
70
  /// which may be cleared to zero without affecting conservative
 
71
  /// interpretation.
 
72
  unsigned char SubclassOptionalData : 7;
 
73
 
 
74
private:
 
75
  /// SubclassData - This member is defined by this class, but is not used for
 
76
  /// anything.  Subclasses can use it to hold whatever state they find useful.
 
77
  /// This field is initialized to zero by the ctor.
 
78
  unsigned short SubclassData;
 
79
 
 
80
  PATypeHolder VTy;
 
81
  Use *UseList;
 
82
 
 
83
  friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
 
84
  friend class ValueHandleBase;
 
85
  friend class AbstractTypeUser;
 
86
  ValueName *Name;
 
87
 
 
88
  void operator=(const Value &);     // Do not implement
 
89
  Value(const Value &);              // Do not implement
 
90
 
 
91
protected:
 
92
  /// printCustom - Value subclasses can override this to implement custom
 
93
  /// printing behavior.
 
94
  virtual void printCustom(raw_ostream &O) const;
 
95
 
 
96
public:
 
97
  Value(const Type *Ty, unsigned scid);
 
98
  virtual ~Value();
 
99
 
 
100
  /// dump - Support for debugging, callable in GDB: V->dump()
 
101
  //
 
102
  void dump() const;
 
103
 
 
104
  /// print - Implement operator<< on Value.
 
105
  ///
 
106
  void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
 
107
 
 
108
  /// All values are typed, get the type of this value.
 
109
  ///
 
110
  inline const Type *getType() const { return VTy; }
 
111
 
 
112
  /// All values hold a context through their type.
 
113
  LLVMContext &getContext() const;
 
114
 
 
115
  // All values can potentially be named...
 
116
  inline bool hasName() const { return Name != 0; }
 
117
  ValueName *getValueName() const { return Name; }
 
118
  
 
119
  /// getName() - Return a constant reference to the value's name. This is cheap
 
120
  /// and guaranteed to return the same reference as long as the value is not
 
121
  /// modified.
 
122
  ///
 
123
  /// This is currently guaranteed to return a StringRef for which data() points
 
124
  /// to a valid null terminated string. The use of StringRef.data() is 
 
125
  /// deprecated here, however, and clients should not rely on it. If such 
 
126
  /// behavior is needed, clients should use expensive getNameStr(), or switch 
 
127
  /// to an interface that does not depend on null termination.
 
128
  StringRef getName() const;
 
129
 
 
130
  /// getNameStr() - Return the name of the specified value, *constructing a
 
131
  /// string* to hold it.  This is guaranteed to construct a string and is very
 
132
  /// expensive, clients should use getName() unless necessary.
 
133
  std::string getNameStr() const;
 
134
 
 
135
  /// setName() - Change the name of the value, choosing a new unique name if
 
136
  /// the provided name is taken.
 
137
  ///
 
138
  /// \arg Name - The new name; or "" if the value's name should be removed.
 
139
  void setName(const Twine &Name);
 
140
 
 
141
  
 
142
  /// takeName - transfer the name from V to this value, setting V's name to
 
143
  /// empty.  It is an error to call V->takeName(V). 
 
144
  void takeName(Value *V);
 
145
 
 
146
  /// replaceAllUsesWith - Go through the uses list for this definition and make
 
147
  /// each use point to "V" instead of "this".  After this completes, 'this's
 
148
  /// use list is guaranteed to be empty.
 
149
  ///
 
150
  void replaceAllUsesWith(Value *V);
 
151
 
 
152
  // uncheckedReplaceAllUsesWith - Just like replaceAllUsesWith but dangerous.
 
153
  // Only use when in type resolution situations!
 
154
  void uncheckedReplaceAllUsesWith(Value *V);
 
155
 
 
156
  //----------------------------------------------------------------------
 
157
  // Methods for handling the chain of uses of this Value.
 
158
  //
 
159
  typedef value_use_iterator<User>       use_iterator;
 
160
  typedef value_use_iterator<const User> use_const_iterator;
 
161
 
 
162
  bool               use_empty() const { return UseList == 0; }
 
163
  use_iterator       use_begin()       { return use_iterator(UseList); }
 
164
  use_const_iterator use_begin() const { return use_const_iterator(UseList); }
 
165
  use_iterator       use_end()         { return use_iterator(0);   }
 
166
  use_const_iterator use_end()   const { return use_const_iterator(0);   }
 
167
  User              *use_back()        { return *use_begin(); }
 
168
  const User        *use_back()  const { return *use_begin(); }
 
169
 
 
170
  /// hasOneUse - Return true if there is exactly one user of this value.  This
 
171
  /// is specialized because it is a common request and does not require
 
172
  /// traversing the whole use list.
 
173
  ///
 
174
  bool hasOneUse() const {
 
175
    use_const_iterator I = use_begin(), E = use_end();
 
176
    if (I == E) return false;
 
177
    return ++I == E;
 
178
  }
 
179
 
 
180
  /// hasNUses - Return true if this Value has exactly N users.
 
181
  ///
 
182
  bool hasNUses(unsigned N) const;
 
183
 
 
184
  /// hasNUsesOrMore - Return true if this value has N users or more.  This is
 
185
  /// logically equivalent to getNumUses() >= N.
 
186
  ///
 
187
  bool hasNUsesOrMore(unsigned N) const;
 
188
 
 
189
  bool isUsedInBasicBlock(const BasicBlock *BB) const;
 
190
 
 
191
  /// getNumUses - This method computes the number of uses of this Value.  This
 
192
  /// is a linear time operation.  Use hasOneUse, hasNUses, or hasMoreThanNUses
 
193
  /// to check for specific values.
 
194
  unsigned getNumUses() const;
 
195
 
 
196
  /// addUse - This method should only be used by the Use class.
 
197
  ///
 
198
  void addUse(Use &U) { U.addToList(&UseList); }
 
199
 
 
200
  /// An enumeration for keeping track of the concrete subclass of Value that
 
201
  /// is actually instantiated. Values of this enumeration are kept in the 
 
202
  /// Value classes SubclassID field. They are used for concrete type
 
203
  /// identification.
 
204
  enum ValueTy {
 
205
    ArgumentVal,              // This is an instance of Argument
 
206
    BasicBlockVal,            // This is an instance of BasicBlock
 
207
    FunctionVal,              // This is an instance of Function
 
208
    GlobalAliasVal,           // This is an instance of GlobalAlias
 
209
    GlobalVariableVal,        // This is an instance of GlobalVariable
 
210
    UndefValueVal,            // This is an instance of UndefValue
 
211
    BlockAddressVal,          // This is an instance of BlockAddress
 
212
    ConstantExprVal,          // This is an instance of ConstantExpr
 
213
    ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull
 
214
    ConstantIntVal,           // This is an instance of ConstantInt
 
215
    ConstantFPVal,            // This is an instance of ConstantFP
 
216
    ConstantArrayVal,         // This is an instance of ConstantArray
 
217
    ConstantStructVal,        // This is an instance of ConstantStruct
 
218
    ConstantUnionVal,         // This is an instance of ConstantUnion
 
219
    ConstantVectorVal,        // This is an instance of ConstantVector
 
220
    ConstantPointerNullVal,   // This is an instance of ConstantPointerNull
 
221
    MDNodeVal,                // This is an instance of MDNode
 
222
    MDStringVal,              // This is an instance of MDString
 
223
    NamedMDNodeVal,           // This is an instance of NamedMDNode
 
224
    InlineAsmVal,             // This is an instance of InlineAsm
 
225
    PseudoSourceValueVal,     // This is an instance of PseudoSourceValue
 
226
    FixedStackPseudoSourceValueVal, // This is an instance of 
 
227
                                    // FixedStackPseudoSourceValue
 
228
    InstructionVal,           // This is an instance of Instruction
 
229
    // Enum values starting at InstructionVal are used for Instructions;
 
230
    // don't add new values here!
 
231
 
 
232
    // Markers:
 
233
    ConstantFirstVal = FunctionVal,
 
234
    ConstantLastVal  = ConstantPointerNullVal
 
235
  };
 
236
 
 
237
  /// getValueID - Return an ID for the concrete type of this object.  This is
 
238
  /// used to implement the classof checks.  This should not be used for any
 
239
  /// other purpose, as the values may change as LLVM evolves.  Also, note that
 
240
  /// for instructions, the Instruction's opcode is added to InstructionVal. So
 
241
  /// this means three things:
 
242
  /// # there is no value with code InstructionVal (no opcode==0).
 
243
  /// # there are more possible values for the value type than in ValueTy enum.
 
244
  /// # the InstructionVal enumerator must be the highest valued enumerator in
 
245
  ///   the ValueTy enum.
 
246
  unsigned getValueID() const {
 
247
    return SubclassID;
 
248
  }
 
249
 
 
250
  /// getRawSubclassOptionalData - Return the raw optional flags value
 
251
  /// contained in this value. This should only be used when testing two
 
252
  /// Values for equivalence.
 
253
  unsigned getRawSubclassOptionalData() const {
 
254
    return SubclassOptionalData;
 
255
  }
 
256
 
 
257
  /// hasSameSubclassOptionalData - Test whether the optional flags contained
 
258
  /// in this value are equal to the optional flags in the given value.
 
259
  bool hasSameSubclassOptionalData(const Value *V) const {
 
260
    return SubclassOptionalData == V->SubclassOptionalData;
 
261
  }
 
262
 
 
263
  /// intersectOptionalDataWith - Clear any optional flags in this value
 
264
  /// that are not also set in the given value.
 
265
  void intersectOptionalDataWith(const Value *V) {
 
266
    SubclassOptionalData &= V->SubclassOptionalData;
 
267
  }
 
268
 
 
269
  // Methods for support type inquiry through isa, cast, and dyn_cast:
 
270
  static inline bool classof(const Value *) {
 
271
    return true; // Values are always values.
 
272
  }
 
273
 
 
274
  /// getRawType - This should only be used to implement the vmcore library.
 
275
  ///
 
276
  const Type *getRawType() const { return VTy.getRawType(); }
 
277
 
 
278
  /// stripPointerCasts - This method strips off any unneeded pointer
 
279
  /// casts from the specified value, returning the original uncasted value.
 
280
  /// Note that the returned value has pointer type if the specified value does.
 
281
  Value *stripPointerCasts();
 
282
  const Value *stripPointerCasts() const {
 
283
    return const_cast<Value*>(this)->stripPointerCasts();
 
284
  }
 
285
 
 
286
  /// getUnderlyingObject - This method strips off any GEP address adjustments
 
287
  /// and pointer casts from the specified value, returning the original object
 
288
  /// being addressed.  Note that the returned value has pointer type if the
 
289
  /// specified value does.  If the MaxLookup value is non-zero, it limits the
 
290
  /// number of instructions to be stripped off.
 
291
  Value *getUnderlyingObject(unsigned MaxLookup = 6);
 
292
  const Value *getUnderlyingObject(unsigned MaxLookup = 6) const {
 
293
    return const_cast<Value*>(this)->getUnderlyingObject(MaxLookup);
 
294
  }
 
295
  
 
296
  /// DoPHITranslation - If this value is a PHI node with CurBB as its parent,
 
297
  /// return the value in the PHI node corresponding to PredBB.  If not, return
 
298
  /// ourself.  This is useful if you want to know the value something has in a
 
299
  /// predecessor block.
 
300
  Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB);
 
301
 
 
302
  const Value *DoPHITranslation(const BasicBlock *CurBB,
 
303
                                const BasicBlock *PredBB) const{
 
304
    return const_cast<Value*>(this)->DoPHITranslation(CurBB, PredBB);
 
305
  }
 
306
  
 
307
protected:
 
308
  unsigned short getSubclassDataFromValue() const { return SubclassData; }
 
309
  void setValueSubclassData(unsigned short D) { SubclassData = D; }
 
310
};
 
311
 
 
312
inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
 
313
  V.print(OS);
 
314
  return OS;
 
315
}
 
316
  
 
317
void Use::set(Value *V) {
 
318
  if (Val) removeFromList();
 
319
  Val = V;
 
320
  if (V) V->addUse(*this);
 
321
}
 
322
 
 
323
 
 
324
// isa - Provide some specializations of isa so that we don't have to include
 
325
// the subtype header files to test to see if the value is a subclass...
 
326
//
 
327
template <> inline bool isa_impl<Constant, Value>(const Value &Val) {
 
328
  return Val.getValueID() >= Value::ConstantFirstVal &&
 
329
         Val.getValueID() <= Value::ConstantLastVal;
 
330
}
 
331
template <> inline bool isa_impl<Argument, Value>(const Value &Val) {
 
332
  return Val.getValueID() == Value::ArgumentVal;
 
333
}
 
334
template <> inline bool isa_impl<InlineAsm, Value>(const Value &Val) {
 
335
  return Val.getValueID() == Value::InlineAsmVal;
 
336
}
 
337
template <> inline bool isa_impl<Instruction, Value>(const Value &Val) {
 
338
  return Val.getValueID() >= Value::InstructionVal;
 
339
}
 
340
template <> inline bool isa_impl<BasicBlock, Value>(const Value &Val) {
 
341
  return Val.getValueID() == Value::BasicBlockVal;
 
342
}
 
343
template <> inline bool isa_impl<Function, Value>(const Value &Val) {
 
344
  return Val.getValueID() == Value::FunctionVal;
 
345
}
 
346
template <> inline bool isa_impl<GlobalVariable, Value>(const Value &Val) {
 
347
  return Val.getValueID() == Value::GlobalVariableVal;
 
348
}
 
349
template <> inline bool isa_impl<GlobalAlias, Value>(const Value &Val) {
 
350
  return Val.getValueID() == Value::GlobalAliasVal;
 
351
}
 
352
template <> inline bool isa_impl<GlobalValue, Value>(const Value &Val) {
 
353
  return isa<GlobalVariable>(Val) || isa<Function>(Val) ||
 
354
         isa<GlobalAlias>(Val);
 
355
}
 
356
template <> inline bool isa_impl<MDNode, Value>(const Value &Val) {
 
357
  return Val.getValueID() == Value::MDNodeVal;
 
358
}
 
359
  
 
360
  
 
361
// Value* is only 4-byte aligned.
 
362
template<>
 
363
class PointerLikeTypeTraits<Value*> {
 
364
  typedef Value* PT;
 
365
public:
 
366
  static inline void *getAsVoidPointer(PT P) { return P; }
 
367
  static inline PT getFromVoidPointer(void *P) {
 
368
    return static_cast<PT>(P);
 
369
  }
 
370
  enum { NumLowBitsAvailable = 2 };
 
371
};
 
372
 
 
373
} // End llvm namespace
 
374
 
 
375
#endif