[llvm-commits] [llvm] r81256 - in /llvm/trunk: include/llvm/Assembly/Parser.h include/llvm/Support/IRReader.h lib/AsmParser/Parser.cpp

Dan Gohman gohman at apple.com
Tue Sep 8 15:20:35 PDT 2009


Author: djg
Date: Tue Sep  8 17:20:35 2009
New Revision: 81256

URL: http://llvm.org/viewvc/llvm-project?rev=81256&view=rev
Log:
Use MemoryBuffer::getBufferIdentifier() in the AsmPrinter instead
of requiring a name be passed in. This makes it use "<stdin>"
instead of "-" and makes it more consistent with the Bitcode reader.

Modified:
    llvm/trunk/include/llvm/Assembly/Parser.h
    llvm/trunk/include/llvm/Support/IRReader.h
    llvm/trunk/lib/AsmParser/Parser.cpp

Modified: llvm/trunk/include/llvm/Assembly/Parser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/Parser.h?rev=81256&r1=81255&r2=81256&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Assembly/Parser.h (original)
+++ llvm/trunk/include/llvm/Assembly/Parser.h Tue Sep  8 17:20:35 2009
@@ -55,7 +55,6 @@
 /// takes ownership of the MemoryBuffer.
 Module *ParseAssembly(
     MemoryBuffer *F,     ///< The MemoryBuffer containing assembly
-    const std::string &Name, ///< The name of the original source file
     Module *M,           ///< A module to add the assembly too.
     SMDiagnostic &Err,   ///< Error result info.
     LLVMContext &Context

Modified: llvm/trunk/include/llvm/Support/IRReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRReader.h?rev=81256&r1=81255&r2=81256&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/IRReader.h (original)
+++ llvm/trunk/include/llvm/Support/IRReader.h Tue Sep  8 17:20:35 2009
@@ -33,7 +33,6 @@
   /// ModuleProvider. This function *always* takes ownership of the given
   /// MemoryBuffer.
   inline ModuleProvider *getIRModuleProvider(MemoryBuffer *Buffer,
-                                             const std::string &Filename,
                                              SMDiagnostic &Err,
                                              LLVMContext &Context) {
     if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
@@ -41,7 +40,7 @@
       std::string ErrMsg;
       ModuleProvider *MP = getBitcodeModuleProvider(Buffer, Context, &ErrMsg);
       if (MP == 0) {
-        Err = SMDiagnostic(Filename, -1, -1, ErrMsg, "");
+        Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, "");
         // ParseBitcodeFile does not take ownership of the Buffer in the
         // case of an error.
         delete Buffer;
@@ -49,7 +48,7 @@
       return MP;
     }
 
-    Module *M = ParseAssembly(Buffer, Filename, 0, Err, Context);
+    Module *M = ParseAssembly(Buffer, 0, Err, Context);
     if (M == 0)
       return 0;
     return new ExistingModuleProvider(M);
@@ -70,7 +69,7 @@
       return 0;
     }
 
-    return getIRModuleProvider(F, Filename, Err, Context);
+    return getIRModuleProvider(F, Err, Context);
   }
 
   /// If the given MemoryBuffer holds a bitcode image, return a Module
@@ -78,7 +77,6 @@
   /// a Module for it. This function *always* takes ownership of the given
   /// MemoryBuffer.
   inline Module *ParseIR(MemoryBuffer *Buffer,
-                         const std::string &Filename,
                          SMDiagnostic &Err,
                          LLVMContext &Context) {
     if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
@@ -88,11 +86,11 @@
       // ParseBitcodeFile does not take ownership of the Buffer.
       delete Buffer;
       if (M == 0)
-        Err = SMDiagnostic(Filename, -1, -1, ErrMsg, "");
+        Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, "");
       return M;
     }
 
-    return ParseAssembly(Buffer, Filename, 0, Err, Context);
+    return ParseAssembly(Buffer, 0, Err, Context);
   }
 
   /// If the given file holds a bitcode image, return a Module for it.
@@ -109,7 +107,7 @@
       return 0;
     }
 
-    return ParseIR(F, Filename, Err, Context);
+    return ParseIR(F, Err, Context);
   }
 
 }

Modified: llvm/trunk/lib/AsmParser/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/Parser.cpp?rev=81256&r1=81255&r2=81256&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/Parser.cpp (original)
+++ llvm/trunk/lib/AsmParser/Parser.cpp Tue Sep  8 17:20:35 2009
@@ -22,7 +22,6 @@
 using namespace llvm;
 
 Module *llvm::ParseAssembly(MemoryBuffer *F,
-                            const std::string &Name,
                             Module *M,
                             SMDiagnostic &Err,
                             LLVMContext &Context) {
@@ -34,7 +33,7 @@
     return LLParser(F, SM, Err, M).Run() ? 0 : M;
 
   // Otherwise create a new module.
-  OwningPtr<Module> M2(new Module(Name, Context));
+  OwningPtr<Module> M2(new Module(F->getBufferIdentifier(), Context));
   if (LLParser(F, SM, Err, M2.get()).Run())
     return 0;
   return M2.take();
@@ -50,7 +49,7 @@
     return 0;
   }
 
-  return ParseAssembly(F, Filename, 0, Err, Context);
+  return ParseAssembly(F, 0, Err, Context);
 }
 
 Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
@@ -59,5 +58,5 @@
     MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString),
                                "<string>");
 
-  return ParseAssembly(F, "<string>", M, Err, Context);
+  return ParseAssembly(F, M, Err, Context);
 }





More information about the llvm-commits mailing list