Added the AsmToken::Hash enum constant to MCAsmLexer.h in preparation of
supporting other targets.  Changed the code to pass MCAsmInfo to the parser
and the lexer.  Then changed the lexer to use CommentString from MCAsmInfo
instead of a literal '#' character.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81046 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index 84131c7..bf3c017 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -82,6 +82,18 @@
                              "Assemble a .s file (default)"),
                   clEnumValEnd));
 
+static const Target *GetTarget(const char *ProgName) {
+  // Get the target specific parser.
+  std::string Error;
+  const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
+  if (TheTarget)
+    return TheTarget;
+
+  errs() << ProgName << ": error: unable to get target for '" << TripleName
+         << "', see --version and --triple.\n";
+  return 0;
+}
+
 static int AsLexInput(const char *ProgName) {
   std::string ErrorMessage;
   MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
@@ -104,7 +116,14 @@
   // it later.
   SrcMgr.setIncludeDirs(IncludeDirs);
 
-  AsmLexer Lexer(SrcMgr);
+  const Target *TheTarget = GetTarget(ProgName);
+  if (!TheTarget)
+    return 1;
+
+  const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
+  assert(MAI && "Unable to create target asm info!");
+
+  AsmLexer Lexer(SrcMgr, *MAI);
   
   bool Error = false;
   
@@ -162,18 +181,6 @@
   return Error;
 }
 
-static const Target *GetTarget(const char *ProgName) {
-  // Get the target specific parser.
-  std::string Error;
-  const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
-  if (TheTarget)
-    return TheTarget;
-
-  errs() << ProgName << ": error: unable to get target for '" << TripleName
-         << "', see --version and --triple.\n";
-  return 0;
-}
-
 static formatted_raw_ostream *GetOutputStream() {
   if (OutputFilename == "")
     OutputFilename = "-";
@@ -239,10 +246,10 @@
   OwningPtr<MCCodeEmitter> CE;
   OwningPtr<MCStreamer> Str;
 
-  if (FileType == OFT_AssemblyFile) {
-    const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
-    assert(MAI && "Unable to create target asm info!");
+  const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
+  assert(MAI && "Unable to create target asm info!");
 
+  if (FileType == OFT_AssemblyFile) {
     AP.reset(TheTarget->createAsmPrinter(*Out, *TM, MAI, true));
     if (ShowEncoding)
       CE.reset(TheTarget->createCodeEmitter(*TM));
@@ -253,7 +260,7 @@
     Str.reset(createMachOStreamer(Ctx, *Out, CE.get()));
   }
 
-  AsmParser Parser(SrcMgr, Ctx, *Str.get());
+  AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI);
   OwningPtr<TargetAsmParser> TAP(TheTarget->createAsmParser(Parser));
   if (!TAP) {
     errs() << ProgName