[llvm] r215945 - These classes only need a StringRef, not a MemoryBuffer.

Rafael Espindola rafael.espindola at gmail.com
Mon Aug 18 15:28:29 PDT 2014


Author: rafael
Date: Mon Aug 18 17:28:28 2014
New Revision: 215945

URL: http://llvm.org/viewvc/llvm-project?rev=215945&view=rev
Log:
These classes only need a StringRef, not a MemoryBuffer.

Modified:
    llvm/trunk/lib/AsmParser/LLLexer.cpp
    llvm/trunk/lib/AsmParser/LLLexer.h
    llvm/trunk/lib/AsmParser/LLParser.h
    llvm/trunk/lib/AsmParser/Parser.cpp

Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=215945&r1=215944&r2=215945&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Mon Aug 18 17:28:28 2014
@@ -161,10 +161,10 @@ static const char *isLabelTail(const cha
 // 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.

Modified: llvm/trunk/lib/AsmParser/LLLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.h?rev=215945&r1=215944&r2=215945&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.h (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.h Mon Aug 18 17:28:28 2014
@@ -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() {}
 

Modified: llvm/trunk/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=215945&r1=215944&r2=215945&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.h (original)
+++ llvm/trunk/lib/AsmParser/LLParser.h Mon Aug 18 17:28:28 2014
@@ -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();

Modified: llvm/trunk/lib/AsmParser/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/Parser.cpp?rev=215945&r1=215944&r2=215945&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/Parser.cpp (original)
+++ llvm/trunk/lib/AsmParser/Parser.cpp Mon Aug 18 17:28:28 2014
@@ -29,11 +29,11 @@ Module *llvm::ParseAssembly(std::unique_
 
   // 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();
 }





More information about the llvm-commits mailing list