This reverts commit r234460 and r234461.

Revert "Add classof implementations to the raw_ostream classes."
Revert "Use the cast machinery to remove dummy uses of formatted_raw_ostream."

The underlying issue can be fixed without classof.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234495 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-04-09 15:54:59 +00:00
parent 28c2fda9df
commit a93117c50d
14 changed files with 51 additions and 86 deletions

View File

@@ -84,21 +84,15 @@ public:
/// so it doesn't want another layer of buffering to be happening
/// underneath it.
///
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
: raw_ostream(SK_FORMATTED), TheStream(nullptr), DeleteStream(false),
Position(0, 0) {
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
: raw_ostream(), TheStream(nullptr), DeleteStream(false), Position(0, 0) {
setStream(Stream, Delete);
}
explicit formatted_raw_ostream()
: raw_ostream(SK_FORMATTED), TheStream(nullptr), DeleteStream(false),
Position(0, 0) {
: raw_ostream(), TheStream(nullptr), DeleteStream(false), Position(0, 0) {
Scanned = nullptr;
}
static bool classof(const raw_ostream *OS) {
return OS->getKind() == SK_FORMATTED;
}
~formatted_raw_ostream() {
flush();
releaseStream();

View File

@@ -107,10 +107,14 @@ namespace llvm
/// management of it, etc.
///
circular_raw_ostream(raw_ostream &Stream, const char *Header,
size_t BuffSize = 0, bool Owns = REFERENCE_ONLY)
: raw_ostream(SK_CIRCULAR, /*unbuffered*/ true), TheStream(nullptr),
OwnsStream(Owns), BufferSize(BuffSize), BufferArray(nullptr),
Filled(false), Banner(Header) {
size_t BuffSize = 0, bool Owns = REFERENCE_ONLY)
: raw_ostream(/*unbuffered*/true),
TheStream(nullptr),
OwnsStream(Owns),
BufferSize(BuffSize),
BufferArray(nullptr),
Filled(false),
Banner(Header) {
if (BufferSize != 0)
BufferArray = new char[BufferSize];
Cur = BufferArray;
@@ -140,10 +144,6 @@ namespace llvm
///
void flushBufferWithBanner();
static bool classof(const raw_ostream *OS) {
return OS->getKind() == SK_CIRCULAR;
}
private:
/// releaseStream - Delete the held stream if needed. Otherwise,
/// transfer the buffer settings from this circular_raw_ostream

View File

@@ -33,11 +33,8 @@ class raw_os_ostream : public raw_ostream {
uint64_t current_pos() const override;
public:
raw_os_ostream(std::ostream &O) : raw_ostream(SK_STD_OS), OS(O) {}
raw_os_ostream(std::ostream &O) : OS(O) {}
~raw_os_ostream();
static bool classof(const raw_ostream *OS) {
return OS->getKind() == SK_STD_OS;
}
};
} // end llvm namespace

View File

@@ -16,7 +16,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include <system_error>
@@ -68,17 +67,6 @@ private:
} BufferMode;
public:
enum StreamKind {
SK_FD,
SK_STRING,
SK_SVECTOR,
SK_NULL,
SK_STD_OS,
SK_CIRCULAR,
SK_FORMATTED,
SK_COUNTING
};
// color order matches ANSI escape sequence, don't change
enum Colors {
BLACK=0,
@@ -92,8 +80,8 @@ public:
SAVEDCOLOR
};
explicit raw_ostream(StreamKind Kind, bool unbuffered = false)
: BufferMode(unbuffered ? Unbuffered : InternalBuffer), Kind(Kind) {
explicit raw_ostream(bool unbuffered=false)
: BufferMode(unbuffered ? Unbuffered : InternalBuffer) {
// Start out ready to flush.
OutBufStart = OutBufEnd = OutBufCur = nullptr;
}
@@ -271,10 +259,7 @@ public:
// Subclass Interface
//===--------------------------------------------------------------------===//
StreamKind getKind() const { return Kind; }
private:
StreamKind Kind;
/// The is the piece of the class that is implemented by subclasses. This
/// writes the \p Size bytes starting at
/// \p Ptr to the underlying stream.
@@ -379,8 +364,6 @@ public:
/// this closes the file when the stream is destroyed.
raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false);
static bool classof(const raw_ostream *OS) { return OS->getKind() == SK_FD; }
~raw_fd_ostream();
/// Manually flush the stream and close the file. Note that this does not call
@@ -460,13 +443,9 @@ class raw_string_ostream : public raw_ostream {
/// currently in the buffer.
uint64_t current_pos() const override { return OS.size(); }
public:
explicit raw_string_ostream(std::string &O) : raw_ostream(SK_STRING), OS(O) {}
explicit raw_string_ostream(std::string &O) : OS(O) {}
~raw_string_ostream();
static bool classof(const raw_ostream *OS) {
return OS->getKind() == SK_STRING;
}
/// Flushes the stream contents to the target string and returns the string's
/// reference.
std::string& str() {
@@ -494,10 +473,6 @@ public:
explicit raw_svector_ostream(SmallVectorImpl<char> &O);
~raw_svector_ostream();
static bool classof(const raw_ostream *OS) {
return OS->getKind() == SK_SVECTOR;
}
/// This is called when the SmallVector we're appending to is changed outside
/// of the raw_svector_ostream's control. It is only safe to do this if the
/// raw_svector_ostream has previously been flushed.
@@ -518,11 +493,8 @@ class raw_null_ostream : public raw_ostream {
uint64_t current_pos() const override;
public:
explicit raw_null_ostream() : raw_ostream(SK_NULL) {}
explicit raw_null_ostream() {}
~raw_null_ostream();
static bool classof(const raw_ostream *OS) {
return OS->getKind() == SK_NULL;
}
};
} // end llvm namespace