From 5759c3a02902026a27a0d1bc24a5bad85f52bd71 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 24 Oct 2013 22:43:10 +0000 Subject: MCStreamer: Reimplement the virtual EmitRawText as a protected member, EmitRawTextImpl, to avoid string literal ambiguities Also improve the implementation of EmitRawText(Twine) so it doesn't bother using the SmallString buffer if the Twine is a simple StringRef anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193378 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCAsmStreamer.cpp | 4 ++-- lib/MC/MCStreamer.cpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/MC') diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index e751a6d9fc..ca49f8f590 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -255,7 +255,7 @@ public: /// EmitRawText - If this file is backed by an assembly streamer, this dumps /// the specified string in the output .s file. This capability is /// indicated by the hasRawTextSupport() predicate. - virtual void EmitRawText(StringRef String); + virtual void EmitRawTextImpl(StringRef String); virtual void FinishImpl(); }; @@ -1346,7 +1346,7 @@ void MCAsmStreamer::EmitBundleUnlock() { /// EmitRawText - If this file is backed by an assembly streamer, this dumps /// the specified string in the output .s file. This capability is /// indicated by the hasRawTextSupport() predicate. -void MCAsmStreamer::EmitRawText(StringRef String) { +void MCAsmStreamer::EmitRawTextImpl(StringRef String) { if (!String.empty() && String.back() == '\n') String = String.substr(0, String.size()-1); OS << String; diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 04e36bedc0..2be89e95e7 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -571,7 +571,7 @@ void MCStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) { /// EmitRawText - If this file is backed by an assembly streamer, this dumps /// the specified string in the output .s file. This capability is /// indicated by the hasRawTextSupport() predicate. -void MCStreamer::EmitRawText(StringRef String) { +void MCStreamer::EmitRawTextImpl(StringRef String) { errs() << "EmitRawText called on an MCStreamer that doesn't support it, " " something must not be fully mc'ized\n"; abort(); @@ -579,8 +579,7 @@ void MCStreamer::EmitRawText(StringRef String) { void MCStreamer::EmitRawText(const Twine &T) { SmallString<128> Str; - T.toVector(Str); - EmitRawText(Str.str()); + EmitRawTextImpl(T.toStringRef(Str)); } void MCStreamer::EmitFrames(MCAsmBackend *MAB, bool usingCFI) { -- cgit v1.2.3