[Lldb-commits] [PATCH] D23884: Add StructuredData unit tests; remove JSON parsing string copy

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 26 09:00:11 PDT 2016


clayborg added a comment.

Looking closer at the JSON parser llvm::StringRef isn't the right thing to use when parsing JSON. The parser will often remove desensitizing characters from say a string like:

  "hello \"world\""

And when parsing a token in JSONParser::GetToken, we can't just hand out a llvm::StringRef do this data in memory. The function prototype is:

  JSONParser::Token
  JSONParser::GetToken (std::string &value)

This would mean we would need "value" to be able to have a new backing store in case the values don't match what is in the JSON text buffer which would defeat the purpose of using llvm::StringRef. We could make a struct like:

  struct ParseString
  {
      llvm::StringRef value;
      std::string backing_store;
  };

But then the code becomes more complex for no real benefit.


https://reviews.llvm.org/D23884





More information about the lldb-commits mailing list