[Lldb-commits] [PATCH] D68130: [lldb] Don't emit artificial constructor declarations as global functions

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 17 11:21:31 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6237c9fe6ce9: [lldb] Don't emit artificial constructor declarations as global functions (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68130/new/

https://reviews.llvm.org/D68130

Files:
  lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
  lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp
  lldb/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py
  lldb/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1007,8 +1007,11 @@
                               is_attr_used, attrs.is_artificial);
 
                       type_handled = cxx_method_decl != NULL;
+                      // Artificial methods are always handled even when don't
+                      // create a new declaration for them.
+                      type_handled |= attrs.is_artificial;
 
-                      if (type_handled) {
+                      if (cxx_method_decl) {
                         LinkDeclContextToDIE(
                             ClangASTContext::GetAsDeclContext(cxx_method_decl),
                             die);
Index: lldb/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp
@@ -0,0 +1,10 @@
+struct Foo {
+  // Triggers that we emit an artificial constructor for Foo.
+  virtual ~Foo() = default;
+};
+
+int main() {
+  Foo f;
+  // Try to construct foo in our expression.
+  return 0; //%self.expect("expr Foo()", substrs=["(Foo) $0 = {}"])
+}
Index: lldb/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py
===================================================================
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), None)
Index: lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp
===================================================================
--- lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp
+++ lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp
@@ -11,6 +11,7 @@
 
 int main() {
   Base realbase;
+  realbase.foo();
   Derived d;
   Base *b = &d;
   return 0; // Set breakpoint here
Index: lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -49,3 +49,7 @@
 
         # Test calling the base class.
         self.expect("expr realbase.foo()", substrs=["1"])
+
+        # Test with locally constructed instances.
+        self.expect("expr Base().foo()", substrs=["1"])
+        self.expect("expr Derived().foo()", substrs=["2"])


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68130.225480.patch
Type: text/x-patch
Size: 3100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191017/57478789/attachment.bin>


More information about the lldb-commits mailing list