~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Support/raw_ostream.h

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===--- raw_ostream.h - Raw output stream ----------------------*- 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 defines the raw_ostream class.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_SUPPORT_RAW_OSTREAM_H
 
15
#define LLVM_SUPPORT_RAW_OSTREAM_H
 
16
 
 
17
#include "llvm/ADT/StringRef.h"
 
18
#include "llvm/System/DataTypes.h"
 
19
 
 
20
namespace llvm {
 
21
  class format_object_base;
 
22
  template <typename T>
 
23
  class SmallVectorImpl;
 
24
 
 
25
/// raw_ostream - This class implements an extremely fast bulk output stream
 
26
/// that can *only* output to a stream.  It does not support seeking, reopening,
 
27
/// rewinding, line buffered disciplines etc. It is a simple buffer that outputs
 
28
/// a chunk at a time.
 
29
class raw_ostream {
 
30
private:
 
31
  // Do not implement. raw_ostream is noncopyable.
 
32
  void operator=(const raw_ostream &);
 
33
  raw_ostream(const raw_ostream &);
 
34
 
 
35
  /// The buffer is handled in such a way that the buffer is
 
36
  /// uninitialized, unbuffered, or out of space when OutBufCur >=
 
37
  /// OutBufEnd. Thus a single comparison suffices to determine if we
 
38
  /// need to take the slow path to write a single character.
 
39
  ///
 
40
  /// The buffer is in one of three states:
 
41
  ///  1. Unbuffered (BufferMode == Unbuffered)
 
42
  ///  1. Uninitialized (BufferMode != Unbuffered && OutBufStart == 0).
 
43
  ///  2. Buffered (BufferMode != Unbuffered && OutBufStart != 0 &&
 
44
  ///               OutBufEnd - OutBufStart >= 1).
 
45
  ///
 
46
  /// If buffered, then the raw_ostream owns the buffer if (BufferMode ==
 
47
  /// InternalBuffer); otherwise the buffer has been set via SetBuffer and is
 
48
  /// managed by the subclass.
 
49
  ///
 
50
  /// If a subclass installs an external buffer using SetBuffer then it can wait
 
51
  /// for a \see write_impl() call to handle the data which has been put into
 
52
  /// this buffer.
 
53
  char *OutBufStart, *OutBufEnd, *OutBufCur;
 
54
 
 
55
  enum BufferKind {
 
56
    Unbuffered = 0,
 
57
    InternalBuffer,
 
58
    ExternalBuffer
 
59
  } BufferMode;
 
60
 
 
61
public:
 
62
  // color order matches ANSI escape sequence, don't change
 
63
  enum Colors {
 
64
    BLACK=0,
 
65
    RED,
 
66
    GREEN,
 
67
    YELLOW,
 
68
    BLUE,
 
69
    MAGENTA,
 
70
    CYAN,
 
71
    WHITE,
 
72
    SAVEDCOLOR
 
73
  };
 
74
 
 
75
  explicit raw_ostream(bool unbuffered=false)
 
76
    : BufferMode(unbuffered ? Unbuffered : InternalBuffer) {
 
77
    // Start out ready to flush.
 
78
    OutBufStart = OutBufEnd = OutBufCur = 0;
 
79
  }
 
80
 
 
81
  virtual ~raw_ostream();
 
82
 
 
83
  /// tell - Return the current offset with the file.
 
84
  uint64_t tell() const { return current_pos() + GetNumBytesInBuffer(); }
 
85
 
 
86
  //===--------------------------------------------------------------------===//
 
87
  // Configuration Interface
 
88
  //===--------------------------------------------------------------------===//
 
89
 
 
90
  /// SetBuffered - Set the stream to be buffered, with an automatically
 
91
  /// determined buffer size.
 
92
  void SetBuffered();
 
93
 
 
94
  /// SetBufferSize - Set the stream to be buffered, using the
 
95
  /// specified buffer size.
 
96
  void SetBufferSize(size_t Size) {
 
97
    flush();
 
98
    SetBufferAndMode(new char[Size], Size, InternalBuffer);
 
99
  }
 
100
 
 
101
  size_t GetBufferSize() const {
 
102
    // If we're supposed to be buffered but haven't actually gotten around
 
103
    // to allocating the buffer yet, return the value that would be used.
 
104
    if (BufferMode != Unbuffered && OutBufStart == 0)
 
105
      return preferred_buffer_size();
 
106
 
 
107
    // Otherwise just return the size of the allocated buffer.
 
108
    return OutBufEnd - OutBufStart;
 
109
  }
 
110
 
 
111
  /// SetUnbuffered - Set the stream to be unbuffered. When
 
112
  /// unbuffered, the stream will flush after every write. This routine
 
113
  /// will also flush the buffer immediately when the stream is being
 
114
  /// set to unbuffered.
 
115
  void SetUnbuffered() {
 
116
    flush();
 
117
    SetBufferAndMode(0, 0, Unbuffered);
 
118
  }
 
119
 
 
120
  size_t GetNumBytesInBuffer() const {
 
121
    return OutBufCur - OutBufStart;
 
122
  }
 
123
 
 
124
  //===--------------------------------------------------------------------===//
 
125
  // Data Output Interface
 
126
  //===--------------------------------------------------------------------===//
 
127
 
 
128
  void flush() {
 
129
    if (OutBufCur != OutBufStart)
 
130
      flush_nonempty();
 
131
  }
 
132
 
 
133
  raw_ostream &operator<<(char C) {
 
134
    if (OutBufCur >= OutBufEnd)
 
135
      return write(C);
 
136
    *OutBufCur++ = C;
 
137
    return *this;
 
138
  }
 
139
 
 
140
  raw_ostream &operator<<(unsigned char C) {
 
141
    if (OutBufCur >= OutBufEnd)
 
142
      return write(C);
 
143
    *OutBufCur++ = C;
 
144
    return *this;
 
145
  }
 
146
 
 
147
  raw_ostream &operator<<(signed char C) {
 
148
    if (OutBufCur >= OutBufEnd)
 
149
      return write(C);
 
150
    *OutBufCur++ = C;
 
151
    return *this;
 
152
  }
 
153
 
 
154
  raw_ostream &operator<<(StringRef Str) {
 
155
    // Inline fast path, particularly for strings with a known length.
 
156
    size_t Size = Str.size();
 
157
 
 
158
    // Make sure we can use the fast path.
 
159
    if (OutBufCur+Size > OutBufEnd)
 
160
      return write(Str.data(), Size);
 
161
 
 
162
    memcpy(OutBufCur, Str.data(), Size);
 
163
    OutBufCur += Size;
 
164
    return *this;
 
165
  }
 
166
 
 
167
  raw_ostream &operator<<(const char *Str) {
 
168
    // Inline fast path, particulary for constant strings where a sufficiently
 
169
    // smart compiler will simplify strlen.
 
170
 
 
171
    return this->operator<<(StringRef(Str));
 
172
  }
 
173
 
 
174
  raw_ostream &operator<<(const std::string &Str) {
 
175
    // Avoid the fast path, it would only increase code size for a marginal win.
 
176
    return write(Str.data(), Str.length());
 
177
  }
 
178
 
 
179
  raw_ostream &operator<<(unsigned long N);
 
180
  raw_ostream &operator<<(long N);
 
181
  raw_ostream &operator<<(unsigned long long N);
 
182
  raw_ostream &operator<<(long long N);
 
183
  raw_ostream &operator<<(const void *P);
 
184
  raw_ostream &operator<<(unsigned int N) {
 
185
    return this->operator<<(static_cast<unsigned long>(N));
 
186
  }
 
187
 
 
188
  raw_ostream &operator<<(int N) {
 
189
    return this->operator<<(static_cast<long>(N));
 
190
  }
 
191
 
 
192
  raw_ostream &operator<<(double N);
 
193
 
 
194
  /// write_hex - Output \arg N in hexadecimal, without any prefix or padding.
 
195
  raw_ostream &write_hex(unsigned long long N);
 
196
 
 
197
  /// write_escaped - Output \arg Str, turning '\\', '\t', '\n', '"', and
 
198
  /// anything that doesn't satisfy std::isprint into an escape sequence.
 
199
  raw_ostream &write_escaped(StringRef Str);
 
200
 
 
201
  raw_ostream &write(unsigned char C);
 
202
  raw_ostream &write(const char *Ptr, size_t Size);
 
203
 
 
204
  // Formatted output, see the format() function in Support/Format.h.
 
205
  raw_ostream &operator<<(const format_object_base &Fmt);
 
206
 
 
207
  /// indent - Insert 'NumSpaces' spaces.
 
208
  raw_ostream &indent(unsigned NumSpaces);
 
209
 
 
210
 
 
211
  /// Changes the foreground color of text that will be output from this point
 
212
  /// forward.
 
213
  /// @param colors ANSI color to use, the special SAVEDCOLOR can be used to
 
214
  /// change only the bold attribute, and keep colors untouched
 
215
  /// @param bold bold/brighter text, default false
 
216
  /// @param bg if true change the background, default: change foreground
 
217
  /// @returns itself so it can be used within << invocations
 
218
  virtual raw_ostream &changeColor(enum Colors, bool = false, bool = false) {
 
219
    return *this; }
 
220
 
 
221
  /// Resets the colors to terminal defaults. Call this when you are done
 
222
  /// outputting colored text, or before program exit.
 
223
  virtual raw_ostream &resetColor() { return *this; }
 
224
 
 
225
  /// This function determines if this stream is connected to a "tty" or
 
226
  /// "console" window. That is, the output would be displayed to the user
 
227
  /// rather than being put on a pipe or stored in a file.
 
228
  virtual bool is_displayed() const { return false; }
 
229
 
 
230
  //===--------------------------------------------------------------------===//
 
231
  // Subclass Interface
 
232
  //===--------------------------------------------------------------------===//
 
233
 
 
234
private:
 
235
  /// write_impl - The is the piece of the class that is implemented
 
236
  /// by subclasses.  This writes the \args Size bytes starting at
 
237
  /// \arg Ptr to the underlying stream.
 
238
  ///
 
239
  /// This function is guaranteed to only be called at a point at which it is
 
240
  /// safe for the subclass to install a new buffer via SetBuffer.
 
241
  ///
 
242
  /// \arg Ptr - The start of the data to be written. For buffered streams this
 
243
  /// is guaranteed to be the start of the buffer.
 
244
  /// \arg Size - The number of bytes to be written.
 
245
  ///
 
246
  /// \invariant { Size > 0 }
 
247
  virtual void write_impl(const char *Ptr, size_t Size) = 0;
 
248
 
 
249
  // An out of line virtual method to provide a home for the class vtable.
 
250
  virtual void handle();
 
251
 
 
252
  /// current_pos - Return the current position within the stream, not
 
253
  /// counting the bytes currently in the buffer.
 
254
  virtual uint64_t current_pos() const = 0;
 
255
 
 
256
protected:
 
257
  /// SetBuffer - Use the provided buffer as the raw_ostream buffer. This is
 
258
  /// intended for use only by subclasses which can arrange for the output to go
 
259
  /// directly into the desired output buffer, instead of being copied on each
 
260
  /// flush.
 
261
  void SetBuffer(char *BufferStart, size_t Size) {
 
262
    SetBufferAndMode(BufferStart, Size, ExternalBuffer);
 
263
  }
 
264
 
 
265
  /// preferred_buffer_size - Return an efficient buffer size for the
 
266
  /// underlying output mechanism.
 
267
  virtual size_t preferred_buffer_size() const;
 
268
 
 
269
  /// getBufferStart - Return the beginning of the current stream buffer, or 0
 
270
  /// if the stream is unbuffered.
 
271
  const char *getBufferStart() const { return OutBufStart; }
 
272
 
 
273
  //===--------------------------------------------------------------------===//
 
274
  // Private Interface
 
275
  //===--------------------------------------------------------------------===//
 
276
private:
 
277
  /// SetBufferAndMode - Install the given buffer and mode.
 
278
  void SetBufferAndMode(char *BufferStart, size_t Size, BufferKind Mode);
 
279
 
 
280
  /// flush_nonempty - Flush the current buffer, which is known to be
 
281
  /// non-empty. This outputs the currently buffered data and resets
 
282
  /// the buffer to empty.
 
283
  void flush_nonempty();
 
284
 
 
285
  /// copy_to_buffer - Copy data into the buffer. Size must not be
 
286
  /// greater than the number of unused bytes in the buffer.
 
287
  void copy_to_buffer(const char *Ptr, size_t Size);
 
288
};
 
289
 
 
290
//===----------------------------------------------------------------------===//
 
291
// File Output Streams
 
292
//===----------------------------------------------------------------------===//
 
293
 
 
294
/// raw_fd_ostream - A raw_ostream that writes to a file descriptor.
 
295
///
 
296
class raw_fd_ostream : public raw_ostream {
 
297
  int FD;
 
298
  bool ShouldClose;
 
299
 
 
300
  /// Error This flag is true if an error of any kind has been detected.
 
301
  ///
 
302
  bool Error;
 
303
 
 
304
  uint64_t pos;
 
305
 
 
306
  /// write_impl - See raw_ostream::write_impl.
 
307
  virtual void write_impl(const char *Ptr, size_t Size);
 
308
 
 
309
  /// current_pos - Return the current position within the stream, not
 
310
  /// counting the bytes currently in the buffer.
 
311
  virtual uint64_t current_pos() const { return pos; }
 
312
 
 
313
  /// preferred_buffer_size - Determine an efficient buffer size.
 
314
  virtual size_t preferred_buffer_size() const;
 
315
 
 
316
  /// error_detected - Set the flag indicating that an output error has
 
317
  /// been encountered.
 
318
  void error_detected() { Error = true; }
 
319
 
 
320
public:
 
321
 
 
322
  enum {
 
323
    /// F_Excl - When opening a file, this flag makes raw_fd_ostream
 
324
    /// report an error if the file already exists.
 
325
    F_Excl  = 1,
 
326
 
 
327
    /// F_Append - When opening a file, if it already exists append to the
 
328
    /// existing file instead of returning an error.  This may not be specified
 
329
    /// with F_Excl.
 
330
    F_Append = 2,
 
331
 
 
332
    /// F_Binary - The file should be opened in binary mode on platforms that
 
333
    /// make this distinction.
 
334
    F_Binary = 4
 
335
  };
 
336
 
 
337
  /// raw_fd_ostream - Open the specified file for writing. If an error occurs,
 
338
  /// information about the error is put into ErrorInfo, and the stream should
 
339
  /// be immediately destroyed; the string will be empty if no error occurred.
 
340
  /// This allows optional flags to control how the file will be opened.
 
341
  ///
 
342
  /// As a special case, if Filename is "-", then the stream will use
 
343
  /// STDOUT_FILENO instead of opening a file. Note that it will still consider
 
344
  /// itself to own the file descriptor. In particular, it will close the
 
345
  /// file descriptor when it is done (this is necessary to detect
 
346
  /// output errors).
 
347
  raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
 
348
                 unsigned Flags = 0);
 
349
 
 
350
  /// raw_fd_ostream ctor - FD is the file descriptor that this writes to.  If
 
351
  /// ShouldClose is true, this closes the file when the stream is destroyed.
 
352
  raw_fd_ostream(int fd, bool shouldClose,
 
353
                 bool unbuffered=false) : raw_ostream(unbuffered), FD(fd),
 
354
                                          ShouldClose(shouldClose),
 
355
                                          Error(false) {}
 
356
 
 
357
  ~raw_fd_ostream();
 
358
 
 
359
  /// close - Manually flush the stream and close the file.
 
360
  /// Note that this does not call fsync.
 
361
  void close();
 
362
 
 
363
  /// seek - Flushes the stream and repositions the underlying file descriptor
 
364
  /// positition to the offset specified from the beginning of the file.
 
365
  uint64_t seek(uint64_t off);
 
366
 
 
367
  virtual raw_ostream &changeColor(enum Colors colors, bool bold=false,
 
368
                                   bool bg=false);
 
369
  virtual raw_ostream &resetColor();
 
370
 
 
371
  virtual bool is_displayed() const;
 
372
 
 
373
  /// has_error - Return the value of the flag in this raw_fd_ostream indicating
 
374
  /// whether an output error has been encountered.
 
375
  /// This doesn't implicitly flush any pending output.  Also, it doesn't
 
376
  /// guarantee to detect all errors unless the the stream has been closed.
 
377
  bool has_error() const {
 
378
    return Error;
 
379
  }
 
380
 
 
381
  /// clear_error - Set the flag read by has_error() to false. If the error
 
382
  /// flag is set at the time when this raw_ostream's destructor is called,
 
383
  /// report_fatal_error is called to report the error. Use clear_error()
 
384
  /// after handling the error to avoid this behavior.
 
385
  ///
 
386
  ///   "Errors should never pass silently.
 
387
  ///    Unless explicitly silenced."
 
388
  ///      - from The Zen of Python, by Tim Peters
 
389
  ///
 
390
  void clear_error() {
 
391
    Error = false;
 
392
  }
 
393
};
 
394
 
 
395
/// outs() - This returns a reference to a raw_ostream for standard output.
 
396
/// Use it like: outs() << "foo" << "bar";
 
397
raw_ostream &outs();
 
398
 
 
399
/// errs() - This returns a reference to a raw_ostream for standard error.
 
400
/// Use it like: errs() << "foo" << "bar";
 
401
raw_ostream &errs();
 
402
 
 
403
/// nulls() - This returns a reference to a raw_ostream which simply discards
 
404
/// output.
 
405
raw_ostream &nulls();
 
406
 
 
407
//===----------------------------------------------------------------------===//
 
408
// Output Stream Adaptors
 
409
//===----------------------------------------------------------------------===//
 
410
 
 
411
/// raw_string_ostream - A raw_ostream that writes to an std::string.  This is a
 
412
/// simple adaptor class. This class does not encounter output errors.
 
413
class raw_string_ostream : public raw_ostream {
 
414
  std::string &OS;
 
415
 
 
416
  /// write_impl - See raw_ostream::write_impl.
 
417
  virtual void write_impl(const char *Ptr, size_t Size);
 
418
 
 
419
  /// current_pos - Return the current position within the stream, not
 
420
  /// counting the bytes currently in the buffer.
 
421
  virtual uint64_t current_pos() const { return OS.size(); }
 
422
public:
 
423
  explicit raw_string_ostream(std::string &O) : OS(O) {}
 
424
  ~raw_string_ostream();
 
425
 
 
426
  /// str - Flushes the stream contents to the target string and returns
 
427
  ///  the string's reference.
 
428
  std::string& str() {
 
429
    flush();
 
430
    return OS;
 
431
  }
 
432
};
 
433
 
 
434
/// raw_svector_ostream - A raw_ostream that writes to an SmallVector or
 
435
/// SmallString.  This is a simple adaptor class. This class does not
 
436
/// encounter output errors.
 
437
class raw_svector_ostream : public raw_ostream {
 
438
  SmallVectorImpl<char> &OS;
 
439
 
 
440
  /// write_impl - See raw_ostream::write_impl.
 
441
  virtual void write_impl(const char *Ptr, size_t Size);
 
442
 
 
443
  /// current_pos - Return the current position within the stream, not
 
444
  /// counting the bytes currently in the buffer.
 
445
  virtual uint64_t current_pos() const;
 
446
public:
 
447
  /// Construct a new raw_svector_ostream.
 
448
  ///
 
449
  /// \arg O - The vector to write to; this should generally have at least 128
 
450
  /// bytes free to avoid any extraneous memory overhead.
 
451
  explicit raw_svector_ostream(SmallVectorImpl<char> &O);
 
452
  ~raw_svector_ostream();
 
453
 
 
454
  /// resync - This is called when the SmallVector we're appending to is changed
 
455
  /// outside of the raw_svector_ostream's control.  It is only safe to do this
 
456
  /// if the raw_svector_ostream has previously been flushed.
 
457
  void resync();
 
458
 
 
459
  /// str - Flushes the stream contents to the target vector and return a
 
460
  /// StringRef for the vector contents.
 
461
  StringRef str();
 
462
};
 
463
 
 
464
/// raw_null_ostream - A raw_ostream that discards all output.
 
465
class raw_null_ostream : public raw_ostream {
 
466
  /// write_impl - See raw_ostream::write_impl.
 
467
  virtual void write_impl(const char *Ptr, size_t size);
 
468
 
 
469
  /// current_pos - Return the current position within the stream, not
 
470
  /// counting the bytes currently in the buffer.
 
471
  virtual uint64_t current_pos() const;
 
472
 
 
473
public:
 
474
  explicit raw_null_ostream() {}
 
475
  ~raw_null_ostream();
 
476
};
 
477
 
 
478
/// tool_output_file - This class contains a raw_fd_ostream and adds a
 
479
/// few extra features commonly needed for compiler-like tool output files:
 
480
///   - The file is automatically deleted if the process is killed.
 
481
///   - The file is automatically deleted when the tool_output_file
 
482
///     object is destroyed unless the client calls keep().
 
483
class tool_output_file {
 
484
  /// Installer - This class is declared before the raw_fd_ostream so that
 
485
  /// it is constructed before the raw_fd_ostream is constructed and
 
486
  /// destructed after the raw_fd_ostream is destructed. It installs
 
487
  /// cleanups in its constructor and uninstalls them in its destructor.
 
488
  class CleanupInstaller {
 
489
    /// Filename - The name of the file.
 
490
    std::string Filename;
 
491
  public:
 
492
    /// Keep - The flag which indicates whether we should not delete the file.
 
493
    bool Keep;
 
494
 
 
495
    explicit CleanupInstaller(const char *filename);
 
496
    ~CleanupInstaller();
 
497
  } Installer;
 
498
 
 
499
  /// OS - The contained stream. This is intentionally declared after
 
500
  /// Installer.
 
501
  raw_fd_ostream OS;
 
502
 
 
503
public:
 
504
  /// tool_output_file - This constructor's arguments are passed to
 
505
  /// to raw_fd_ostream's constructor.
 
506
  tool_output_file(const char *filename, std::string &ErrorInfo,
 
507
                   unsigned Flags = 0);
 
508
 
 
509
  /// os - Return the contained raw_fd_ostream.
 
510
  raw_fd_ostream &os() { return OS; }
 
511
 
 
512
  /// keep - Indicate that the tool's job wrt this output file has been
 
513
  /// successful and the file should not be deleted.
 
514
  void keep() { Installer.Keep = true; }
 
515
};
 
516
 
 
517
} // end llvm namespace
 
518
 
 
519
#endif