[Lldb-commits] [lldb] 569be95 - [lldb] Print newline between found types

Arthur Eubanks via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 17 14:24:30 PDT 2022


Author: Arthur Eubanks
Date: 2022-10-17T14:24:21-07:00
New Revision: 569be95a40893041f8cadf2907a5970a19b1155f

URL: https://github.com/llvm/llvm-project/commit/569be95a40893041f8cadf2907a5970a19b1155f
DIFF: https://github.com/llvm/llvm-project/commit/569be95a40893041f8cadf2907a5970a19b1155f.diff

LOG: [lldb] Print newline between found types

Or else multiple entries end up overlapping on the same line.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D135827

Added: 
    lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
    lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
    lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp

Modified: 
    lldb/source/Commands/CommandObjectTarget.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 59b7dfd74e852..61ac468ec90d8 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1663,8 +1663,8 @@ static size_t LookupTypeInModule(Target *target,
         typedef_type_sp = typedefed_type_sp;
         typedefed_type_sp = typedef_type_sp->GetTypedefType();
       }
+      strm.EOL();
     }
-    strm.EOL();
   }
   return type_list.GetSize();
 }

diff  --git a/lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile b/lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
new file mode 100644
index 0000000000000..3d0b98f13f3d7
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py b/lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
new file mode 100644
index 0000000000000..8268ea15d2207
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
@@ -0,0 +1,16 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookupDuplicate(TestBase):
+
+    def test_namespace_only(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+        self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["2 matches found", "\nid =", "\nid ="])

diff  --git a/lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp b/lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
new file mode 100644
index 0000000000000..2518aafe9fc29
--- /dev/null
+++ b/lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
@@ -0,0 +1,13 @@
+namespace a {
+struct Foo {};
+} // namespace a
+
+namespace b {
+struct Foo {};
+} // namespace b
+
+int main() {
+  a::Foo a;
+  b::Foo b;
+  return 0; // Set breakpoint here
+}


        


More information about the lldb-commits mailing list