diff options
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Debug.cpp | 4 | ||||
-rw-r--r-- | lib/Support/SourceMgr.cpp | 21 | ||||
-rw-r--r-- | lib/Support/StringExtras.cpp | 4 | ||||
-rw-r--r-- | lib/Support/raw_ostream.cpp | 11 |
4 files changed, 26 insertions, 14 deletions
diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index a035771..82b4b8c 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -115,9 +115,9 @@ raw_ostream &llvm::dbgs() { #else // Avoid "has no symbols" warning. namespace llvm { - /// dbgs - Return dbgs(). + /// dbgs - Return errs(). raw_ostream &dbgs() { - return dbgs(); + return errs(); } } diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index 7dd42f4..bdc637a 100644 --- a/lib/Support/SourceMgr.cpp +++ b/lib/Support/SourceMgr.cpp @@ -192,18 +192,21 @@ void SMDiagnostic::Print(const char *ProgName, raw_ostream &S) { if (ProgName && ProgName[0]) S << ProgName << ": "; - if (Filename == "-") - S << "<stdin>"; - else - S << Filename; + if (!Filename.empty()) { + if (Filename == "-") + S << "<stdin>"; + else + S << Filename; - if (LineNo != -1) { - S << ':' << LineNo; - if (ColumnNo != -1) - S << ':' << (ColumnNo+1); + if (LineNo != -1) { + S << ':' << LineNo; + if (ColumnNo != -1) + S << ':' << (ColumnNo+1); + } + S << ": "; } - S << ": " << Message << '\n'; + S << Message << '\n'; if (LineNo != -1 && ColumnNo != -1 && ShowLine) { S << LineContents << '\n'; diff --git a/lib/Support/StringExtras.cpp b/lib/Support/StringExtras.cpp index 785e0ec..eb2fa08 100644 --- a/lib/Support/StringExtras.cpp +++ b/lib/Support/StringExtras.cpp @@ -39,13 +39,11 @@ std::pair<StringRef, StringRef> llvm::getToken(StringRef Source, StringRef Delimiters) { // Figure out where the token starts. StringRef::size_type Start = Source.find_first_not_of(Delimiters); - if (Start == StringRef::npos) Start = Source.size(); // Find the next occurrence of the delimiter. StringRef::size_type End = Source.find_first_of(Delimiters, Start); - if (End == StringRef::npos) End = Source.size(); - return std::make_pair(Source.substr(Start, End), Source.substr(End)); + return std::make_pair(Source.slice(Start, End), Source.substr(End)); } /// SplitString - Split up the specified string according to the specified diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index a820210..10d7ec0 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -562,6 +562,17 @@ raw_svector_ostream::~raw_svector_ostream() { flush(); } +/// resync - 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. +void raw_svector_ostream::resync() { + assert(GetNumBytesInBuffer() == 0 && "Didn't flush before mutating vector"); + + if (OS.capacity() - OS.size() < 64) + OS.reserve(OS.capacity() * 2); + SetBuffer(OS.end(), OS.capacity() - OS.size()); +} + void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) { assert(Ptr == OS.end() && OS.size() + Size <= OS.capacity() && "Invalid write_impl() call!"); |