From 5759c3a02902026a27a0d1bc24a5bad85f52bd71 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 24 Oct 2013 22:43:10 +0000 Subject: [PATCH] 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 --- include/llvm/MC/MCStreamer.h | 3 ++- lib/CodeGen/AsmPrinter/DIE.cpp | 2 +- lib/MC/MCAsmStreamer.cpp | 4 ++-- lib/MC/MCStreamer.cpp | 5 ++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 974feea08e0..47d798dd8bd 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -149,6 +149,8 @@ protected: } void EmitW64Tables(); + virtual void EmitRawTextImpl(StringRef String); + public: virtual ~MCStreamer(); @@ -657,7 +659,6 @@ public: /// EmitRawText - If this file is backed by a assembly streamer, this dumps /// the specified string in the output .s file. This capability is /// indicated by the hasRawTextSupport() predicate. By default this aborts. - virtual void EmitRawText(StringRef String); void EmitRawText(const Twine &String); /// Flush - Causes any cached state to be written out. diff --git a/lib/CodeGen/AsmPrinter/DIE.cpp b/lib/CodeGen/AsmPrinter/DIE.cpp index f9110c00c37..f9bf8b98a60 100644 --- a/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/lib/CodeGen/AsmPrinter/DIE.cpp @@ -196,7 +196,7 @@ void DIEInteger::EmitValue(AsmPrinter *Asm, dwarf::Form Form) const { // Emit something to keep the lines and comments in sync. // FIXME: Is there a better way to do this? if (Asm->OutStreamer.hasRawTextSupport()) - Asm->OutStreamer.EmitRawText(StringRef("")); + Asm->OutStreamer.EmitRawText(""); return; case dwarf::DW_FORM_flag: // Fall thru case dwarf::DW_FORM_ref1: // Fall thru diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index e751a6d9fc3..ca49f8f5908 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 04e36bedc0b..2be89e95e70 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) {