From 84cbb6f00de84fa04012462a28a3636e13834401 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Wed, 21 Dec 2011 18:16:39 +0000 Subject: Changes the JSON parser to use the SourceMgr. Diagnostics are now emitted via the SourceMgr and we use MemoryBuffer for buffer management. Switched the code to make use of the trailing '0' that MemoryBuffer guarantees where it makes sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147063 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/JSONParser.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'include/llvm/Support/JSONParser.h') diff --git a/include/llvm/Support/JSONParser.h b/include/llvm/Support/JSONParser.h index f4cdfa5608..f7cc1190cd 100644 --- a/include/llvm/Support/JSONParser.h +++ b/include/llvm/Support/JSONParser.h @@ -23,6 +23,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/SourceMgr.h" namespace llvm { @@ -67,7 +68,7 @@ public: /// /// Parsing is started via parseRoot(). Access to the object returned from /// parseRoot() will parse the input lazily. - JSONParser(StringRef Input); + JSONParser(StringRef Input, SourceMgr *SM); /// \brief Returns the outermost JSON value (either an array or an object). /// @@ -90,9 +91,6 @@ public: /// iterating over the result of 'parseRoot', 'failed' will return true. bool failed() const; - /// \brief Returns an error message when 'failed' returns true. - std::string getErrorMessage() const; - private: /// \brief These methods manage the implementation details of parsing new JSON /// atoms. @@ -147,13 +145,20 @@ private: BumpPtrAllocator ValueAllocator; /// \brief The original input to the parser. - const StringRef Input; + MemoryBuffer *InputBuffer; + + /// \brief The source manager used for diagnostics and buffer management. + SourceMgr *SM; /// \brief The current position in the parse stream. StringRef::iterator Position; - /// \brief If non-empty, an error has occurred. - std::string ErrorMessage; + /// \brief The end position for fast EOF checks without introducing + /// unnecessary dereferences. + StringRef::iterator End; + + /// \brief If true, an error has occurred. + bool Failed; template -- cgit v1.2.3