[Lldb-commits] [lldb] [lldb] Support alternatives for scope format entries (PR #137751)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 29 04:06:58 PDT 2025
================
@@ -160,3 +161,48 @@ TEST(FormatEntity, LookupAllEntriesInTree) {
<< "Formatting " << testString << " did not succeed";
}
}
+
+TEST(FormatEntity, ScopeAlt) {
+ StreamString stream;
+ FormatEntity::Entry format;
+ Status status = FormatEntity::Parse("{${frame.pc}|foo}", format);
+ ASSERT_TRUE(status.Success()) << status.AsCString();
+
+ FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+ false, false);
+ EXPECT_EQ(stream.GetString(), "foo");
+}
+
+TEST(FormatEntity, EscapedPipeInScope) {
+ StreamString stream;
+ FormatEntity::Entry format;
+ Status status = FormatEntity::Parse("{foo\\|bar}", format);
+ ASSERT_TRUE(status.Success()) << status.AsCString();
+
+ FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+ false, false);
+ EXPECT_EQ(stream.GetString(), "foo|bar");
+}
+
+TEST(FormatEntity, PipeOutsideScope) {
+ StreamString stream;
+ FormatEntity::Entry format;
+ Status status = FormatEntity::Parse("foo|bar", format);
+ ASSERT_TRUE(status.Success()) << status.AsCString();
+
+ FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+ false, false);
+ EXPECT_EQ(stream.GetString(), "foo|bar");
+}
+
+TEST(FormatEntity, ScopeAltMultiple) {
+ StreamString stream;
+ FormatEntity::Entry format;
+ Status status =
+ FormatEntity::Parse("{${frame.pc}|${function.name}|foo}", format);
+ ASSERT_TRUE(status.Success()) << status.AsCString();
+
+ FormatEntity::Format(format, stream, nullptr, nullptr, nullptr, nullptr,
+ false, false);
+ EXPECT_EQ(stream.GetString(), "foo");
+}
----------------
Michael137 wrote:
Could we also test the following?
1. Nested scopes (e.g., `{ ${foo} | { ${bar} | ${baz} } }`)? Not sure that's a thing or not, but seems like it should work?
2. Pipes between scopes: `{ ${foo} } | { ${bar} }`
3. Empty format between pipes: `{ ${foo} || ${bar} }`
https://github.com/llvm/llvm-project/pull/137751
More information about the lldb-commits
mailing list