================ @@ -52,12 +52,17 @@ llvm::StringRef GetAsString(const llvm::json::Value &value); /// \param[in] key /// The key to use when extracting the value /// +/// \param[in] defaultValue +/// The default value to return if the key is not present +/// /// \return /// A llvm::StringRef that contains the string value for the -/// specified \a key, or an empty string if there is no key that +/// specified \a key, or the default value if there is no key that /// matches or if the value is not a string. -llvm::StringRef GetString(const llvm::json::Object &obj, llvm::StringRef key); -llvm::StringRef GetString(const llvm::json::Object *obj, llvm::StringRef key); +llvm::StringRef GetString(const llvm::json::Object &obj, llvm::StringRef key, + llvm::StringRef defaultValue = ""); +llvm::StringRef GetString(const llvm::json::Object *obj, llvm::StringRef key, + llvm::StringRef defaultValue = ""); ---------------- clayborg wrote:
Setting `defaultValue` to `""` is different from what it was doing previously when it used to return `lldb::StringRef()`. The latter will return a StringRef with NULL and zero size, where "" will return something with a valid pointer and zero size. So this should be: ``` llvm::StringRef GetString(const llvm::json::Object &obj, llvm::StringRef key, llvm::StringRef defaultValue = llvm::StringRef()); llvm::StringRef GetString(const llvm::json::Object *obj, llvm::StringRef key, llvm::StringRef defaultValue = llvm::StringRef()); ``` https://github.com/llvm/llvm-project/pull/69238 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits