fix a bunch of failing tests now that MCContext::GetSection doesn't create sections.
authorChris Lattner <sabre@nondot.org>
Fri, 31 Jul 2009 17:47:16 +0000 (17:47 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 31 Jul 2009 17:47:16 +0000 (17:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77689 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-mc/AsmParser.cpp
tools/llvm-mc/llvm-mc.cpp

index 3cd2b8e7540addaad3ec2b951d3c33cda6fb718d..8348479240d803036d435dad721824e90b5dc28f 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/SourceMgr.h"
@@ -641,7 +642,12 @@ bool AsmParser::ParseDirectiveDarwinSection() {
     return TokError("unexpected token in '.section' directive");
   Lexer.Lex();
 
-  Out.SwitchSection(Ctx.GetSection(Section.c_str()));
+  // FIXME: Arch specific.
+  MCSection *S = Ctx.GetSection(Section);
+  if (S == 0)
+    S = MCSection::Create(Section, Ctx);
+  
+  Out.SwitchSection(S);
   return false;
 }
 
@@ -657,7 +663,12 @@ bool AsmParser::ParseDirectiveSectionSwitch(const char *Section,
     SectionStr += Directives;
   }
   
-  Out.SwitchSection(Ctx.GetSection(Section));
+  // FIXME: Arch specific.
+  MCSection *S = Ctx.GetSection(Section);
+  if (S == 0)
+    S = MCSection::Create(Section, Ctx);
+  
+  Out.SwitchSection(S);
   return false;
 }
 
index 11d8b963d1a15a52f01787f67a00125e41d950dd..44a8319cd6b003f405435626af917a817027ac29 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Support/CommandLine.h"
@@ -189,8 +190,8 @@ static int AssembleInput(const char *ProgName) {
   OwningPtr<MCStreamer> Str(createAsmStreamer(Ctx, outs()));
 
   // FIXME: Target hook & command line option for initial section.
-  Str.get()->SwitchSection(Ctx.GetSection("__TEXT,__text,"
-                                          "regular,pure_instructions"));
+  Str.get()->SwitchSection(MCSection::Create("__TEXT,__text,"
+                                             "regular,pure_instructions", Ctx));
 
   AsmParser Parser(SrcMgr, Ctx, *Str.get());
   OwningPtr<TargetAsmParser> TAP(GetTargetAsmParser(ProgName, Parser));