[Lldb-commits] [PATCH] D70393: [lldb] Fix NSURL data formatter truncation issue in Swift
Martin Svensson via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 20 06:11:34 PST 2019
poya updated this revision to Diff 230248.
poya added a comment.
Remove helper function
Hardcode quote character to " with assert to catch future changes
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70393/new/
https://reviews.llvm.org/D70393
Files:
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
Index: lldb/source/Plugins/Language/ObjC/Cocoa.cpp
===================================================================
--- lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -694,32 +694,42 @@
CompilerType type(valobj.GetCompilerType());
ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset_text, type, true));
ValueObjectSP base(valobj.GetSyntheticChildAtOffset(offset_base, type, true));
- if (!text)
- return false;
- if (text->GetValueAsUnsigned(0) == 0)
+ if (!text || text->GetValueAsUnsigned(0) == 0)
return false;
+
+ StreamString base_summary;
+ if (base && base->GetValueAsUnsigned(0)) {
+ if (!NSURLSummaryProvider(*base, base_summary, options))
+ base_summary.Clear();
+ }
+ if (base_summary.Empty())
+ return NSStringSummaryProvider(*text, stream, options);
+
StreamString summary;
- if (!NSStringSummaryProvider(*text, summary, options))
+ if (!NSStringSummaryProvider(*text, summary, options) || summary.Empty())
return false;
- if (base && base->GetValueAsUnsigned(0)) {
- std::string summary_str = summary.GetString();
-
- if (!summary_str.empty())
- summary_str.pop_back();
- summary_str += " -- ";
- StreamString base_summary;
- if (NSURLSummaryProvider(*base, base_summary, options) &&
- !base_summary.Empty()) {
- llvm::StringRef base_str = base_summary.GetString();
- if (base_str.size() > 2)
- base_str = base_str.drop_front(2);
- summary_str += base_str;
+
+ const char quote_char = '"';
+ std::string prefix, suffix;
+ if (Language *language = Language::FindPlugin(options.GetLanguage())) {
+ if (!language->GetFormatterPrefixSuffix(valobj, ConstString("NSString"),
+ prefix, suffix)) {
+ prefix.clear();
+ suffix.clear();
}
- summary.Clear();
- summary.PutCString(summary_str);
}
- if (!summary.Empty()) {
- stream.PutCString(summary.GetString());
+ // @"A" -> @"A
+ llvm::StringRef summary_str = summary.GetString();
+ bool back_consumed = summary_str.consume_back(quote_char + suffix);
+ assert(back_consumed); UNUSED_IF_ASSERT_DISABLED(back_consumed);
+ // @"B" -> B"
+ llvm::StringRef base_summary_str = base_summary.GetString();
+ bool front_consumed = base_summary_str.consume_front(prefix + quote_char);
+ assert(front_consumed); UNUSED_IF_ASSERT_DISABLED(front_consumed);
+ // @"A -- B"
+ if (!summary_str.empty() && !base_summary_str.empty()) {
+ stream.Printf("%s -- %s", summary_str.str().c_str(),
+ base_summary_str.str().c_str());
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70393.230248.patch
Type: text/x-patch
Size: 2647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191120/88674c2b/attachment-0001.bin>
More information about the lldb-commits
mailing list