From 030f63a397edc20f8f661bac62f7b90cb5cf57bc Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Mon, 14 Jan 2013 19:04:57 +0000 Subject: Expose an InitToTextSection through MCStreamer. The aim of this patch is to fix the following piece of code in the platform-independent AsmParser: void AsmParser::CheckForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) { TokError("expected section directive before assembly directive"); Out.SwitchSection(Ctx.getMachOSection( "__TEXT", "__text", MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0, SectionKind::getText())); } } This was added for the "-n" option of llvm-mc. The proposed fix adds another virtual method to MCStreamer, called InitToTextSection. Conceptually, it's similar to the existing InitSections which initializes all common sections and switches to text. The new method is implemented by each platform streamer in a way that it sees fit. So AsmParser can now do this: void AsmParser::CheckForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) { TokError("expected section directive before assembly directive"); Out.InitToTextSection(); } } Which is much more reasonable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172450 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCNullStreamer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/MC/MCNullStreamer.cpp') diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index 364c324..3eee5ca 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -24,6 +24,9 @@ namespace { /// @name MCStreamer Interface /// @{ + virtual void InitToTextSection() { + } + virtual void InitSections() { } -- cgit v1.1 From 5da3665cc501ed8928e63678254357214ec0b9eb Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 31 Jan 2013 23:29:57 +0000 Subject: Give the MCStreamer class hierarchy LLVM RTTI facilities for use with isa<> and dyn_cast<>. In several places, code is already hacking around the absence of this, and there seem to be several interfaces that might be lifted and/or devirtualized using this. This change was based on a discussion with Jim Grosbach about how best to handle testing for specific MCStreamer subclasses. He said that this was the correct end state, and everything else was too hacky so I decided to just make it so. No functionality should be changed here, this is just threading the kind through all the constructors and setting up the classof overloads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174113 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCNullStreamer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/MC/MCNullStreamer.cpp') diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index 3eee5ca..89f74c1 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -19,7 +19,7 @@ namespace { class MCNullStreamer : public MCStreamer { public: - MCNullStreamer(MCContext &Context) : MCStreamer(Context) {} + MCNullStreamer(MCContext &Context) : MCStreamer(SK_NullStreamer, Context) {} /// @name MCStreamer Interface /// @{ @@ -109,6 +109,11 @@ namespace { } /// @} + + static bool classof(const MCStreamer *S) { + return S->getKind() == SK_NullStreamer; + } + }; } -- cgit v1.1