[Lldb-commits] [lldb] r375151 - [lldb] Don't emit artificial constructor declarations as global functions
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 17 11:16:50 PDT 2019
Author: teemperor
Date: Thu Oct 17 11:16:50 2019
New Revision: 375151
URL: http://llvm.org/viewvc/llvm-project?rev=375151&view=rev
Log:
[lldb] Don't emit artificial constructor declarations as global functions
Summary:
When we have a artificial constructor DIE, we currently create from that a global function with the name of that class.
That ends up causing a bunch of funny errors such as "must use 'struct' tag to refer to type 'Foo' in this scope" when
doing `Foo f`. Also causes that constructing a class via `Foo()` actually just calls that global function.
The fix is that when we have an artificial method decl, we always treat it as handled even if we don't create a CXXMethodDecl
for it (which we never do for artificial methods at the moment).
Fixes rdar://55757491 and probably some other radars.
Reviewers: aprantl, vsk, shafik
Reviewed By: aprantl
Subscribers: jingham, shafik, labath, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68130
Added:
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp
Modified:
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py?rev=375151&r1=375150&r2=375151&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py Thu Oct 17 11:16:50 2019
@@ -49,3 +49,7 @@ class ExprCommandCallOverriddenMethod(Te
# 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"])
Modified: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp?rev=375151&r1=375150&r2=375151&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/main.cpp Thu Oct 17 11:16:50 2019
@@ -11,6 +11,7 @@ public:
int main() {
Base realbase;
+ realbase.foo();
Derived d;
Base *b = &d;
return 0; // Set breakpoint here
Added: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py?rev=375151&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/TestIgnoreArtificialConstructors.py Thu Oct 17 11:16:50 2019
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), None)
Added: lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp?rev=375151&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/commands/expression/ignore-artificial-constructors/main.cpp Thu Oct 17 11:16:50 2019
@@ -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 = {}"])
+}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=375151&r1=375150&r2=375151&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Oct 17 11:16:50 2019
@@ -1007,8 +1007,11 @@ TypeSP DWARFASTParserClang::ParseTypeFro
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);
More information about the lldb-commits
mailing list