aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2011-12-21 18:16:39 +0000
committerManuel Klimek <klimek@google.com>2011-12-21 18:16:39 +0000
commit84cbb6f00de84fa04012462a28a3636e13834401 (patch)
treeca8fca2df705cb701ef77cea6028b1b3dcb14403 /include
parentedae8e1e4d5bd9b59f18ecef04a248be95d8ca46 (diff)
downloadexternal_llvm-84cbb6f00de84fa04012462a28a3636e13834401.zip
external_llvm-84cbb6f00de84fa04012462a28a3636e13834401.tar.gz
external_llvm-84cbb6f00de84fa04012462a28a3636e13834401.tar.bz2
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
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/JSONParser.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/include/llvm/Support/JSONParser.h b/include/llvm/Support/JSONParser.h
index f4cdfa5..f7cc119 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 <typename AtomT, char StartChar, char EndChar,
JSONAtom::Kind ContainerKind>