MC: Use MachO::SectionType for MCSectionMachO::getType's return type
[oota-llvm.git] / lib / MC / MCParser / DarwinAsmParser.cpp
index 3b86390da4296a781b3438697e3bf7ea2dd76b0b..10fca7043efccb8cc319563bc93b0128846d6d1c 100644 (file)
@@ -8,14 +8,15 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCParser/MCAsmParserExtension.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCParser/MCAsmLexer.h"
+#include "llvm/MC/MCParser/MCAsmParser.h"
 #include "llvm/MC/MCSectionMachO.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
-#include "llvm/MC/MCParser/MCAsmLexer.h"
-#include "llvm/MC/MCParser/MCAsmParser.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
 using namespace llvm;
@@ -25,6 +26,13 @@ namespace {
 /// \brief Implementation of directive handling which is shared across all
 /// Darwin targets.
 class DarwinAsmParser : public MCAsmParserExtension {
+  template<bool (DarwinAsmParser::*HandlerMethod)(StringRef, SMLoc)>
+  void addDirectiveHandler(StringRef Directive) {
+    MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair(
+        this, HandleDirective<DarwinAsmParser, HandlerMethod>);
+    getParser().addDirectiveHandler(Directive, Handler);
+  }
+
   bool ParseSectionSwitch(const char *Segment, const char *Section,
                           unsigned TAA = 0, unsigned ImplicitAlign = 0,
                           unsigned StubSize = 0);
@@ -36,175 +44,149 @@ public:
     // Call the base implementation.
     this->MCAsmParserExtension::Initialize(Parser);
 
-    Parser.AddDirectiveHandler(this, ".desc", MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveDesc));
-    Parser.AddDirectiveHandler(this, ".lsym", MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveLsym));
-    Parser.AddDirectiveHandler(this, ".subsections_via_symbols",
-                               MCAsmParser::DirectiveHandler(
-                        &DarwinAsmParser::ParseDirectiveSubsectionsViaSymbols));
-    Parser.AddDirectiveHandler(this, ".dump", MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveDumpOrLoad));
-    Parser.AddDirectiveHandler(this, ".load", MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveDumpOrLoad));
-    Parser.AddDirectiveHandler(this, ".section", MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveSection));
-    Parser.AddDirectiveHandler(this, ".secure_log_unique",
-                               MCAsmParser::DirectiveHandler(
-                             &DarwinAsmParser::ParseDirectiveSecureLogUnique));
-    Parser.AddDirectiveHandler(this, ".secure_log_reset",
-                               MCAsmParser::DirectiveHandler(
-                             &DarwinAsmParser::ParseDirectiveSecureLogReset));
-    Parser.AddDirectiveHandler(this, ".tbss",
-                               MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveTBSS));
-    Parser.AddDirectiveHandler(this, ".zerofill",
-                               MCAsmParser::DirectiveHandler(
-                                 &DarwinAsmParser::ParseDirectiveZerofill));
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveDesc>(".desc");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveIndirectSymbol>(
+      ".indirect_symbol");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveLsym>(".lsym");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveSubsectionsViaSymbols>(
+      ".subsections_via_symbols");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveDumpOrLoad>(".dump");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveDumpOrLoad>(".load");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveSection>(".section");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectivePushSection>(
+      ".pushsection");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectivePopSection>(
+      ".popsection");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectivePrevious>(".previous");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveSecureLogUnique>(
+      ".secure_log_unique");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveSecureLogReset>(
+      ".secure_log_reset");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveTBSS>(".tbss");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveZerofill>(".zerofill");
+
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveDataRegion>(
+      ".data_region");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveDataRegionEnd>(
+      ".end_data_region");
 
     // Special section directives.
-    Parser.AddDirectiveHandler(this, ".const",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveConst));
-    Parser.AddDirectiveHandler(this, ".const_data",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveConstData));
-    Parser.AddDirectiveHandler(this, ".constructor",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveConstructor));
-    Parser.AddDirectiveHandler(this, ".cstring",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveCString));
-    Parser.AddDirectiveHandler(this, ".data",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveData));
-    Parser.AddDirectiveHandler(this, ".destructor",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveDestructor));
-    Parser.AddDirectiveHandler(this, ".dyld",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveDyld));
-    Parser.AddDirectiveHandler(this, ".fvmlib_init0",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveFVMLibInit0));
-    Parser.AddDirectiveHandler(this, ".fvmlib_init1",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveFVMLibInit1));
-    Parser.AddDirectiveHandler(this, ".lazy_symbol_pointer",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveLazySymbolPointers));
-    Parser.AddDirectiveHandler(this, ".literal16",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveLiteral16));
-    Parser.AddDirectiveHandler(this, ".literal4",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveLiteral4));
-    Parser.AddDirectiveHandler(this, ".literal8",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveLiteral8));
-    Parser.AddDirectiveHandler(this, ".mod_init_func",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveModInitFunc));
-    Parser.AddDirectiveHandler(this, ".mod_term_func",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveModTermFunc));
-    Parser.AddDirectiveHandler(this, ".non_lazy_symbol_pointer",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveNonLazySymbolPointers));
-    Parser.AddDirectiveHandler(this, ".objc_cat_cls_meth",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCCatClsMeth));
-    Parser.AddDirectiveHandler(this, ".objc_cat_inst_meth",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCCatInstMeth));
-    Parser.AddDirectiveHandler(this, ".objc_category",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCCategory));
-    Parser.AddDirectiveHandler(this, ".objc_class",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCClass));
-    Parser.AddDirectiveHandler(this, ".objc_class_names",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCClassNames));
-    Parser.AddDirectiveHandler(this, ".objc_class_vars",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCClassVars));
-    Parser.AddDirectiveHandler(this, ".objc_cls_meth",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCClsMeth));
-    Parser.AddDirectiveHandler(this, ".objc_cls_refs",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCClsRefs));
-    Parser.AddDirectiveHandler(this, ".objc_inst_meth",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCInstMeth));
-    Parser.AddDirectiveHandler(this, ".objc_instance_vars",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCInstanceVars));
-    Parser.AddDirectiveHandler(this, ".objc_message_refs",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCMessageRefs));
-    Parser.AddDirectiveHandler(this, ".objc_meta_class",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCMetaClass));
-    Parser.AddDirectiveHandler(this, ".objc_meth_var_names",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCMethVarNames));
-    Parser.AddDirectiveHandler(this, ".objc_meth_var_types",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCMethVarTypes));
-    Parser.AddDirectiveHandler(this, ".objc_module_info",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCModuleInfo));
-    Parser.AddDirectiveHandler(this, ".objc_protocol",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCProtocol));
-    Parser.AddDirectiveHandler(this, ".objc_selector_strs",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCSelectorStrs));
-    Parser.AddDirectiveHandler(this, ".objc_string_object",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCStringObject));
-    Parser.AddDirectiveHandler(this, ".objc_symbols",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveObjCSymbols));
-    Parser.AddDirectiveHandler(this, ".picsymbol_stub",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectivePICSymbolStub));
-    Parser.AddDirectiveHandler(this, ".static_const",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveStaticConst));
-    Parser.AddDirectiveHandler(this, ".static_data",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveStaticData));
-    Parser.AddDirectiveHandler(this, ".symbol_stub",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveSymbolStub));
-    Parser.AddDirectiveHandler(this, ".tdata",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveTData));
-    Parser.AddDirectiveHandler(this, ".text",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveText));
-    Parser.AddDirectiveHandler(this, ".thread_init_func",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveThreadInitFunc));
-    Parser.AddDirectiveHandler(this, ".tlv",
-                               MCAsmParser::DirectiveHandler(
-                 &DarwinAsmParser::ParseSectionDirectiveTLV));
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveBss>(".bss");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveConst>(".const");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveConstData>(
+      ".const_data");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveConstructor>(
+      ".constructor");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveCString>(
+      ".cstring");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveData>(".data");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveDestructor>(
+      ".destructor");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveDyld>(".dyld");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveFVMLibInit0>(
+      ".fvmlib_init0");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveFVMLibInit1>(
+      ".fvmlib_init1");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveLazySymbolPointers>(
+        ".lazy_symbol_pointer");
+    addDirectiveHandler<&DarwinAsmParser::ParseDirectiveLinkerOption>(
+      ".linker_option");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveLiteral16>(
+      ".literal16");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveLiteral4>(
+      ".literal4");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveLiteral8>(
+      ".literal8");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveModInitFunc>(
+      ".mod_init_func");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveModTermFunc>(
+      ".mod_term_func");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveNonLazySymbolPointers>(
+        ".non_lazy_symbol_pointer");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCCatClsMeth>(
+      ".objc_cat_cls_meth");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCCatInstMeth>(
+      ".objc_cat_inst_meth");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCCategory>(
+      ".objc_category");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCClass>(
+      ".objc_class");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCClassNames>(
+      ".objc_class_names");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCClassVars>(
+      ".objc_class_vars");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCClsMeth>(
+      ".objc_cls_meth");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCClsRefs>(
+      ".objc_cls_refs");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCInstMeth>(
+      ".objc_inst_meth");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveObjCInstanceVars>(
+        ".objc_instance_vars");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCMessageRefs>(
+      ".objc_message_refs");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCMetaClass>(
+      ".objc_meta_class");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveObjCMethVarNames>(
+        ".objc_meth_var_names");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveObjCMethVarTypes>(
+        ".objc_meth_var_types");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCModuleInfo>(
+      ".objc_module_info");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCProtocol>(
+      ".objc_protocol");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveObjCSelectorStrs>(
+        ".objc_selector_strs");
+    addDirectiveHandler<
+      &DarwinAsmParser::ParseSectionDirectiveObjCStringObject>(
+        ".objc_string_object");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveObjCSymbols>(
+      ".objc_symbols");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectivePICSymbolStub>(
+      ".picsymbol_stub");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveStaticConst>(
+      ".static_const");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveStaticData>(
+      ".static_data");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveSymbolStub>(
+      ".symbol_stub");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveTData>(".tdata");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveText>(".text");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveThreadInitFunc>(
+      ".thread_init_func");
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveTLV>(".tlv");
+
+    addDirectiveHandler<&DarwinAsmParser::ParseSectionDirectiveIdent>(".ident");
   }
 
   bool ParseDirectiveDesc(StringRef, SMLoc);
+  bool ParseDirectiveIndirectSymbol(StringRef, SMLoc);
   bool ParseDirectiveDumpOrLoad(StringRef, SMLoc);
   bool ParseDirectiveLsym(StringRef, SMLoc);
-  bool ParseDirectiveSection();
+  bool ParseDirectiveLinkerOption(StringRef, SMLoc);
+  bool ParseDirectiveSection(StringRef, SMLoc);
+  bool ParseDirectivePushSection(StringRef, SMLoc);
+  bool ParseDirectivePopSection(StringRef, SMLoc);
+  bool ParseDirectivePrevious(StringRef, SMLoc);
   bool ParseDirectiveSecureLogReset(StringRef, SMLoc);
   bool ParseDirectiveSecureLogUnique(StringRef, SMLoc);
   bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
   bool ParseDirectiveTBSS(StringRef, SMLoc);
   bool ParseDirectiveZerofill(StringRef, SMLoc);
+  bool ParseDirectiveDataRegion(StringRef, SMLoc);
+  bool ParseDirectiveDataRegionEnd(StringRef, SMLoc);
 
   // Named Section Directive
+  bool ParseSectionDirectiveBss(StringRef, SMLoc) {
+    return ParseSectionSwitch("__DATA", "__bss");
+  }
+
   bool ParseSectionDirectiveConst(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__const");
   }
@@ -213,19 +195,19 @@ public:
   }
   bool ParseSectionDirectiveCString(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT","__cstring",
-                              MCSectionMachO::S_CSTRING_LITERALS);
+                              MachO::S_CSTRING_LITERALS);
   }
   bool ParseSectionDirectiveLiteral4(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__literal4",
-                              MCSectionMachO::S_4BYTE_LITERALS, 4);
+                              MachO::S_4BYTE_LITERALS, 4);
   }
   bool ParseSectionDirectiveLiteral8(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__literal8",
-                              MCSectionMachO::S_8BYTE_LITERALS, 8);
+                              MachO::S_8BYTE_LITERALS, 8);
   }
   bool ParseSectionDirectiveLiteral16(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT","__literal16",
-                              MCSectionMachO::S_16BYTE_LITERALS, 16);
+                              MachO::S_16BYTE_LITERALS, 16);
   }
   bool ParseSectionDirectiveConstructor(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT","__constructor");
@@ -241,15 +223,15 @@ public:
   }
   bool ParseSectionDirectiveSymbolStub(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT","__symbol_stub",
-                              MCSectionMachO::S_SYMBOL_STUBS |
-                              MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
+                              MachO::S_SYMBOL_STUBS |
+                              MachO::S_ATTR_PURE_INSTRUCTIONS,
                               // FIXME: Different on PPC and ARM.
                               0, 16);
   }
   bool ParseSectionDirectivePICSymbolStub(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT","__picsymbol_stub",
-                              MCSectionMachO::S_SYMBOL_STUBS |
-                              MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0, 26);
+                              MachO::S_SYMBOL_STUBS |
+                              MachO::S_ATTR_PURE_INSTRUCTIONS, 0, 26);
   }
   bool ParseSectionDirectiveData(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__data");
@@ -259,124 +241,129 @@ public:
   }
   bool ParseSectionDirectiveNonLazySymbolPointers(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__nl_symbol_ptr",
-                              MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS, 4);
+                              MachO::S_NON_LAZY_SYMBOL_POINTERS, 4);
   }
   bool ParseSectionDirectiveLazySymbolPointers(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__la_symbol_ptr",
-                              MCSectionMachO::S_LAZY_SYMBOL_POINTERS, 4);
+                              MachO::S_LAZY_SYMBOL_POINTERS, 4);
   }
   bool ParseSectionDirectiveDyld(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__dyld");
   }
   bool ParseSectionDirectiveModInitFunc(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__mod_init_func",
-                              MCSectionMachO::S_MOD_INIT_FUNC_POINTERS, 4);
+                              MachO::S_MOD_INIT_FUNC_POINTERS, 4);
   }
   bool ParseSectionDirectiveModTermFunc(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__mod_term_func",
-                              MCSectionMachO::S_MOD_TERM_FUNC_POINTERS, 4);
+                              MachO::S_MOD_TERM_FUNC_POINTERS, 4);
   }
   bool ParseSectionDirectiveConstData(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__const");
   }
   bool ParseSectionDirectiveObjCClass(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__class",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCMetaClass(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__meta_class",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCCatClsMeth(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__cat_cls_meth",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCCatInstMeth(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__cat_inst_meth",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCProtocol(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__protocol",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCStringObject(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__string_object",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCClsMeth(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__cls_meth",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCInstMeth(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__inst_meth",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCClsRefs(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__cls_refs",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP |
-                              MCSectionMachO::S_LITERAL_POINTERS, 4);
+                              MachO::S_ATTR_NO_DEAD_STRIP |
+                              MachO::S_LITERAL_POINTERS, 4);
   }
   bool ParseSectionDirectiveObjCMessageRefs(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__message_refs",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP |
-                              MCSectionMachO::S_LITERAL_POINTERS, 4);
+                              MachO::S_ATTR_NO_DEAD_STRIP |
+                              MachO::S_LITERAL_POINTERS, 4);
   }
   bool ParseSectionDirectiveObjCSymbols(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__symbols",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCCategory(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__category",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCClassVars(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__class_vars",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCInstanceVars(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__instance_vars",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCModuleInfo(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__module_info",
-                              MCSectionMachO::S_ATTR_NO_DEAD_STRIP);
+                              MachO::S_ATTR_NO_DEAD_STRIP);
   }
   bool ParseSectionDirectiveObjCClassNames(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__cstring",
-                              MCSectionMachO::S_CSTRING_LITERALS);
+                              MachO::S_CSTRING_LITERALS);
   }
   bool ParseSectionDirectiveObjCMethVarTypes(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__cstring",
-                              MCSectionMachO::S_CSTRING_LITERALS);
+                              MachO::S_CSTRING_LITERALS);
   }
   bool ParseSectionDirectiveObjCMethVarNames(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__cstring",
-                              MCSectionMachO::S_CSTRING_LITERALS);
+                              MachO::S_CSTRING_LITERALS);
   }
   bool ParseSectionDirectiveObjCSelectorStrs(StringRef, SMLoc) {
     return ParseSectionSwitch("__OBJC", "__selector_strs",
-                              MCSectionMachO::S_CSTRING_LITERALS);
+                              MachO::S_CSTRING_LITERALS);
   }
   bool ParseSectionDirectiveTData(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__thread_data",
-                              MCSectionMachO::S_THREAD_LOCAL_REGULAR);
+                              MachO::S_THREAD_LOCAL_REGULAR);
   }
   bool ParseSectionDirectiveText(StringRef, SMLoc) {
     return ParseSectionSwitch("__TEXT", "__text",
-                              MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS);
+                              MachO::S_ATTR_PURE_INSTRUCTIONS);
   }
   bool ParseSectionDirectiveTLV(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__thread_vars",
-                              MCSectionMachO::S_THREAD_LOCAL_VARIABLES);
+                              MachO::S_THREAD_LOCAL_VARIABLES);
+  }
+  bool ParseSectionDirectiveIdent(StringRef, SMLoc) {
+    // Darwin silently ignores the .ident directive.
+    getParser().eatToEndOfStatement();
+    return false;
   }
   bool ParseSectionDirectiveThreadInitFunc(StringRef, SMLoc) {
     return ParseSectionSwitch("__DATA", "__thread_init",
-                         MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS);
+                         MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS);
   }
 
 };
 
-}
+} // end anonymous namespace
 
 bool DarwinAsmParser::ParseSectionSwitch(const char *Segment,
                                          const char *Section,
@@ -387,7 +374,7 @@ bool DarwinAsmParser::ParseSectionSwitch(const char *Segment,
   Lex();
 
   // FIXME: Arch specific.
-  bool isText = StringRef(Segment) == "__TEXT";  // FIXME: Hack.
+  bool isText = TAA & MachO::S_ATTR_PURE_INSTRUCTIONS;
   getStreamer().SwitchSection(getContext().getMachOSection(
                                 Segment, Section, TAA, StubSize,
                                 isText ? SectionKind::getText()
@@ -397,12 +384,12 @@ bool DarwinAsmParser::ParseSectionSwitch(const char *Segment,
   //
   // FIXME: This isn't really what 'as' does; I think it just uses the implicit
   // alignment on the section (e.g., if one manually inserts bytes into the
-  // section, then just issueing the section switch directive will not realign
+  // section, then just issuing the section switch directive will not realign
   // the section. However, this is arguably more reasonable behavior, and there
   // is no good reason for someone to intentionally emit incorrectly sized
   // values into the implicitly aligned sections.
   if (Align)
-    getStreamer().EmitValueToAlignment(Align, 0, 1, 0);
+    getStreamer().EmitValueToAlignment(Align);
 
   return false;
 }
@@ -411,7 +398,7 @@ bool DarwinAsmParser::ParseSectionSwitch(const char *Segment,
 ///  ::= .desc identifier , expression
 bool DarwinAsmParser::ParseDirectiveDesc(StringRef, SMLoc) {
   StringRef Name;
-  if (getParser().ParseIdentifier(Name))
+  if (getParser().parseIdentifier(Name))
     return TokError("expected identifier in directive");
 
   // Handle the identifier as the key symbol.
@@ -422,7 +409,7 @@ bool DarwinAsmParser::ParseDirectiveDesc(StringRef, SMLoc) {
   Lex();
 
   int64_t DescValue;
-  if (getParser().ParseAbsoluteExpression(DescValue))
+  if (getParser().parseAbsoluteExpression(DescValue))
     return true;
 
   if (getLexer().isNot(AsmToken::EndOfStatement))
@@ -436,6 +423,39 @@ bool DarwinAsmParser::ParseDirectiveDesc(StringRef, SMLoc) {
   return false;
 }
 
+/// ParseDirectiveIndirectSymbol
+///  ::= .indirect_symbol identifier
+bool DarwinAsmParser::ParseDirectiveIndirectSymbol(StringRef, SMLoc Loc) {
+  const MCSectionMachO *Current = static_cast<const MCSectionMachO*>(
+                                       getStreamer().getCurrentSection().first);
+  MachO::SectionType SectionType = Current->getType();
+  if (SectionType != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
+      SectionType != MachO::S_LAZY_SYMBOL_POINTERS &&
+      SectionType != MachO::S_SYMBOL_STUBS)
+    return Error(Loc, "indirect symbol not in a symbol pointer or stub "
+                      "section");
+
+  StringRef Name;
+  if (getParser().parseIdentifier(Name))
+    return TokError("expected identifier in .indirect_symbol directive");
+
+  MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
+
+  // Assembler local symbols don't make any sense here. Complain loudly.
+  if (Sym->isTemporary())
+    return TokError("non-local symbol required in directive");
+
+  if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_IndirectSymbol))
+    return TokError("unable to emit indirect symbol attribute for: " + Name);
+
+  if (getLexer().isNot(AsmToken::EndOfStatement))
+    return TokError("unexpected token in '.indirect_symbol' directive");
+
+  Lex();
+
+  return false;
+}
+
 /// ParseDirectiveDumpOrLoad
 ///  ::= ( .dump | .load ) "filename"
 bool DarwinAsmParser::ParseDirectiveDumpOrLoad(StringRef Directive,
@@ -454,10 +474,35 @@ bool DarwinAsmParser::ParseDirectiveDumpOrLoad(StringRef Directive,
   // FIXME: If/when .dump and .load are implemented they will be done in the
   // the assembly parser and not have any need for an MCStreamer API.
   if (IsDump)
-    Warning(IDLoc, "ignoring directive .dump for now");
+    return Warning(IDLoc, "ignoring directive .dump for now");
   else
-    Warning(IDLoc, "ignoring directive .load for now");
+    return Warning(IDLoc, "ignoring directive .load for now");
+}
+
+/// ParseDirectiveLinkerOption
+///  ::= .linker_option "string" ( , "string" )*
+bool DarwinAsmParser::ParseDirectiveLinkerOption(StringRef IDVal, SMLoc) {
+  SmallVector<std::string, 4> Args;
+  for (;;) {
+    if (getLexer().isNot(AsmToken::String))
+      return TokError("expected string in '" + Twine(IDVal) + "' directive");
+
+    std::string Data;
+    if (getParser().parseEscapedString(Data))
+      return true;
+
+    Args.push_back(Data);
 
+    Lex();
+    if (getLexer().is(AsmToken::EndOfStatement))
+      break;
+
+    if (getLexer().isNot(AsmToken::Comma))
+      return TokError("unexpected token in '" + Twine(IDVal) + "' directive");
+    Lex();
+  }
+
+  getStreamer().EmitLinkerOptions(Args);
   return false;
 }
 
@@ -465,7 +510,7 @@ bool DarwinAsmParser::ParseDirectiveDumpOrLoad(StringRef Directive,
 ///  ::= .lsym identifier , expression
 bool DarwinAsmParser::ParseDirectiveLsym(StringRef, SMLoc) {
   StringRef Name;
-  if (getParser().ParseIdentifier(Name))
+  if (getParser().parseIdentifier(Name))
     return TokError("expected identifier in directive");
 
   // Handle the identifier as the key symbol.
@@ -476,7 +521,7 @@ bool DarwinAsmParser::ParseDirectiveLsym(StringRef, SMLoc) {
   Lex();
 
   const MCExpr *Value;
-  if (getParser().ParseExpression(Value))
+  if (getParser().parseExpression(Value))
     return true;
 
   if (getLexer().isNot(AsmToken::EndOfStatement))
@@ -493,11 +538,11 @@ bool DarwinAsmParser::ParseDirectiveLsym(StringRef, SMLoc) {
 
 /// ParseDirectiveSection:
 ///   ::= .section identifier (',' identifier)*
-bool DarwinAsmParser::ParseDirectiveSection() {
+bool DarwinAsmParser::ParseDirectiveSection(StringRef, SMLoc) {
   SMLoc Loc = getLexer().getLoc();
 
   StringRef SectionName;
-  if (getParser().ParseIdentifier(SectionName))
+  if (getParser().parseIdentifier(SectionName))
     return Error(Loc, "expected identifier after '.section' directive");
 
   // Verify there is a following comma.
@@ -519,10 +564,12 @@ bool DarwinAsmParser::ParseDirectiveSection() {
 
 
   StringRef Segment, Section;
-  unsigned TAA, StubSize;
+  unsigned StubSize;
+  unsigned TAA;
+  bool TAAParsed;
   std::string ErrorStr =
     MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section,
-                                          TAA, StubSize);
+                                          TAA, TAAParsed, StubSize);
 
   if (!ErrorStr.empty())
     return Error(Loc, ErrorStr.c_str());
@@ -536,10 +583,41 @@ bool DarwinAsmParser::ParseDirectiveSection() {
   return false;
 }
 
+/// ParseDirectivePushSection:
+///   ::= .pushsection identifier (',' identifier)*
+bool DarwinAsmParser::ParseDirectivePushSection(StringRef S, SMLoc Loc) {
+  getStreamer().PushSection();
+
+  if (ParseDirectiveSection(S, Loc)) {
+    getStreamer().PopSection();
+    return true;
+  }
+
+  return false;
+}
+
+/// ParseDirectivePopSection:
+///   ::= .popsection
+bool DarwinAsmParser::ParseDirectivePopSection(StringRef, SMLoc) {
+  if (!getStreamer().PopSection())
+    return TokError(".popsection without corresponding .pushsection");
+  return false;
+}
+
+/// ParseDirectivePrevious:
+///   ::= .previous
+bool DarwinAsmParser::ParseDirectivePrevious(StringRef DirName, SMLoc) {
+  MCSectionSubPair PreviousSection = getStreamer().getPreviousSection();
+  if (PreviousSection.first == NULL)
+      return TokError(".previous without corresponding .section");
+  getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second);
+  return false;
+}
+
 /// ParseDirectiveSecureLogUnique
 ///  ::= .secure_log_unique ... message ...
 bool DarwinAsmParser::ParseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
-  StringRef LogMessage = getParser().ParseStringToEndOfStatement();
+  StringRef LogMessage = getParser().parseStringToEndOfStatement();
   if (getLexer().isNot(AsmToken::EndOfStatement))
     return TokError("unexpected token in '.secure_log_unique' directive");
 
@@ -556,7 +634,8 @@ bool DarwinAsmParser::ParseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
   raw_ostream *OS = getContext().getSecureLog();
   if (OS == NULL) {
     std::string Err;
-    OS = new raw_fd_ostream(SecureLogFile, Err, raw_fd_ostream::F_Append);
+    OS = new raw_fd_ostream(SecureLogFile, Err,
+                            sys::fs::F_Append | sys::fs::F_Text);
     if (!Err.empty()) {
        delete OS;
        return Error(IDLoc, Twine("can't open secure log file: ") +
@@ -607,7 +686,7 @@ bool DarwinAsmParser::ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
 bool DarwinAsmParser::ParseDirectiveTBSS(StringRef, SMLoc) {
   SMLoc IDLoc = getLexer().getLoc();
   StringRef Name;
-  if (getParser().ParseIdentifier(Name))
+  if (getParser().parseIdentifier(Name))
     return TokError("expected identifier in directive");
 
   // Handle the identifier as the key symbol.
@@ -619,7 +698,7 @@ bool DarwinAsmParser::ParseDirectiveTBSS(StringRef, SMLoc) {
 
   int64_t Size;
   SMLoc SizeLoc = getLexer().getLoc();
-  if (getParser().ParseAbsoluteExpression(Size))
+  if (getParser().parseAbsoluteExpression(Size))
     return true;
 
   int64_t Pow2Alignment = 0;
@@ -627,7 +706,7 @@ bool DarwinAsmParser::ParseDirectiveTBSS(StringRef, SMLoc) {
   if (getLexer().is(AsmToken::Comma)) {
     Lex();
     Pow2AlignmentLoc = getLexer().getLoc();
-    if (getParser().ParseAbsoluteExpression(Pow2Alignment))
+    if (getParser().parseAbsoluteExpression(Pow2Alignment))
       return true;
   }
 
@@ -650,7 +729,7 @@ bool DarwinAsmParser::ParseDirectiveTBSS(StringRef, SMLoc) {
 
   getStreamer().EmitTBSSSymbol(getContext().getMachOSection(
                                  "__DATA", "__thread_bss",
-                                 MCSectionMachO::S_THREAD_LOCAL_ZEROFILL,
+                                 MachO::S_THREAD_LOCAL_ZEROFILL,
                                  0, SectionKind::getThreadBSS()),
                                Sym, Size, 1 << Pow2Alignment);
 
@@ -662,7 +741,7 @@ bool DarwinAsmParser::ParseDirectiveTBSS(StringRef, SMLoc) {
 ///      , align_expression ]]
 bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
   StringRef Segment;
-  if (getParser().ParseIdentifier(Segment))
+  if (getParser().parseIdentifier(Segment))
     return TokError("expected segment name after '.zerofill' directive");
 
   if (getLexer().isNot(AsmToken::Comma))
@@ -670,7 +749,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
   Lex();
 
   StringRef Section;
-  if (getParser().ParseIdentifier(Section))
+  if (getParser().parseIdentifier(Section))
     return TokError("expected section name after comma in '.zerofill' "
                     "directive");
 
@@ -679,7 +758,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
   if (getLexer().is(AsmToken::EndOfStatement)) {
     // Create the zerofill section but no symbol
     getStreamer().EmitZerofill(getContext().getMachOSection(
-                                 Segment, Section, MCSectionMachO::S_ZEROFILL,
+                                 Segment, Section, MachO::S_ZEROFILL,
                                  0, SectionKind::getBSS()));
     return false;
   }
@@ -690,7 +769,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
 
   SMLoc IDLoc = getLexer().getLoc();
   StringRef IDStr;
-  if (getParser().ParseIdentifier(IDStr))
+  if (getParser().parseIdentifier(IDStr))
     return TokError("expected identifier in directive");
 
   // handle the identifier as the key symbol.
@@ -702,7 +781,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
 
   int64_t Size;
   SMLoc SizeLoc = getLexer().getLoc();
-  if (getParser().ParseAbsoluteExpression(Size))
+  if (getParser().parseAbsoluteExpression(Size))
     return true;
 
   int64_t Pow2Alignment = 0;
@@ -710,7 +789,7 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
   if (getLexer().is(AsmToken::Comma)) {
     Lex();
     Pow2AlignmentLoc = getLexer().getLoc();
-    if (getParser().ParseAbsoluteExpression(Pow2Alignment))
+    if (getParser().parseAbsoluteExpression(Pow2Alignment))
       return true;
   }
 
@@ -737,17 +816,53 @@ bool DarwinAsmParser::ParseDirectiveZerofill(StringRef, SMLoc) {
   //
   // FIXME: Arch specific.
   getStreamer().EmitZerofill(getContext().getMachOSection(
-                               Segment, Section, MCSectionMachO::S_ZEROFILL,
+                               Segment, Section, MachO::S_ZEROFILL,
                                0, SectionKind::getBSS()),
                              Sym, Size, 1 << Pow2Alignment);
 
   return false;
 }
 
+/// ParseDirectiveDataRegion
+///  ::= .data_region [ ( jt8 | jt16 | jt32 ) ]
+bool DarwinAsmParser::ParseDirectiveDataRegion(StringRef, SMLoc) {
+  if (getLexer().is(AsmToken::EndOfStatement)) {
+    Lex();
+    getStreamer().EmitDataRegion(MCDR_DataRegion);
+    return false;
+  }
+  StringRef RegionType;
+  SMLoc Loc = getParser().getTok().getLoc();
+  if (getParser().parseIdentifier(RegionType))
+    return TokError("expected region type after '.data_region' directive");
+  int Kind = StringSwitch<int>(RegionType)
+    .Case("jt8", MCDR_DataRegionJT8)
+    .Case("jt16", MCDR_DataRegionJT16)
+    .Case("jt32", MCDR_DataRegionJT32)
+    .Default(-1);
+  if (Kind == -1)
+    return Error(Loc, "unknown region type in '.data_region' directive");
+  Lex();
+
+  getStreamer().EmitDataRegion((MCDataRegionType)Kind);
+  return false;
+}
+
+/// ParseDirectiveDataRegionEnd
+///  ::= .end_data_region
+bool DarwinAsmParser::ParseDirectiveDataRegionEnd(StringRef, SMLoc) {
+  if (getLexer().isNot(AsmToken::EndOfStatement))
+    return TokError("unexpected token in '.end_data_region' directive");
+
+  Lex();
+  getStreamer().EmitDataRegion(MCDR_DataRegionEnd);
+  return false;
+}
+
 namespace llvm {
 
 MCAsmParserExtension *createDarwinAsmParser() {
   return new DarwinAsmParser;
 }
 
-}
+} // end llvm namespace