These classes only need a StringRef, not a MemoryBuffer.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 18 Aug 2014 22:28:28 +0000 (22:28 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 18 Aug 2014 22:28:28 +0000 (22:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215945 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLLexer.h
lib/AsmParser/LLParser.h
lib/AsmParser/Parser.cpp

index 4a03440caaafa8f016c185084061df1ed649aeee..cb4a9557d43793abe5af079d03a8e863170432d1 100644 (file)
@@ -161,10 +161,10 @@ static const char *isLabelTail(const char *CurPtr) {
 // Lexer definition.
 //===----------------------------------------------------------------------===//
 
-LLLexer::LLLexer(MemoryBuffer *StartBuf, SourceMgr &sm, SMDiagnostic &Err,
+LLLexer::LLLexer(StringRef StartBuf, SourceMgr &sm, SMDiagnostic &Err,
                  LLVMContext &C)
   : CurBuf(StartBuf), ErrorInfo(Err), SM(sm), Context(C), APFloatVal(0.0) {
-  CurPtr = CurBuf->getBufferStart();
+  CurPtr = CurBuf.begin();
 }
 
 int LLLexer::getNextChar() {
@@ -174,7 +174,7 @@ int LLLexer::getNextChar() {
   case 0:
     // A nul character in the stream is either the end of the current buffer or
     // a random nul in the file.  Disambiguate that here.
-    if (CurPtr-1 != CurBuf->getBufferEnd())
+    if (CurPtr-1 != CurBuf.end())
       return 0;  // Just whitespace.
 
     // Otherwise, return end of file.
index 683939fe62db72dcaf4daa627be77105e385adb4..219827fd330d8eba5d15963269616493f03ab0ff 100644 (file)
@@ -28,7 +28,7 @@ namespace llvm {
 
   class LLLexer {
     const char *CurPtr;
-    MemoryBuffer *CurBuf;
+    StringRef CurBuf;
     SMDiagnostic &ErrorInfo;
     SourceMgr &SM;
     LLVMContext &Context;
@@ -43,7 +43,7 @@ namespace llvm {
     APSInt  APSIntVal;
 
   public:
-    explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &,
+    explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
                      LLVMContext &C);
     ~LLLexer() {}
 
index 6a7ff9f92421bd1116e1b1bcde639b9d3b42769f..a3eb8d3ed3869797cb4e8d8c6cb5d57a5e05ac55 100644 (file)
@@ -136,7 +136,7 @@ namespace llvm {
     std::map<unsigned, AttrBuilder> NumberedAttrBuilders;
 
   public:
-    LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
+    LLParser(StringRef F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
       Context(m->getContext()), Lex(F, SM, Err, m->getContext()),
       M(m) {}
     bool Run();
index 4cc94cb270d9af3cd2ef738671b3f5673a1e6093..6cae013b129070fc3ea490313cb6875fd4203340 100644 (file)
@@ -29,11 +29,11 @@ Module *llvm::ParseAssembly(std::unique_ptr<MemoryBuffer> F, Module *M,
 
   // If we are parsing into an existing module, do it.
   if (M)
-    return LLParser(Buf, SM, Err, M).Run() ? nullptr : M;
+    return LLParser(Buf->getBuffer(), SM, Err, M).Run() ? nullptr : M;
 
   // Otherwise create a new module.
   std::unique_ptr<Module> M2(new Module(Buf->getBufferIdentifier(), Context));
-  if (LLParser(Buf, SM, Err, M2.get()).Run())
+  if (LLParser(Buf->getBuffer(), SM, Err, M2.get()).Run())
     return nullptr;
   return M2.release();
 }