// 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() {
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.
class LLLexer {
const char *CurPtr;
- MemoryBuffer *CurBuf;
+ StringRef CurBuf;
SMDiagnostic &ErrorInfo;
SourceMgr &SM;
LLVMContext &Context;
APSInt APSIntVal;
public:
- explicit LLLexer(MemoryBuffer *StartBuf, SourceMgr &SM, SMDiagnostic &,
+ explicit LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
LLVMContext &C);
~LLLexer() {}
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();
// 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();
}