llvm-project/lldb/unittests
Raphael Isemann 22447a61d4 [lldb] Mark the implicit copy constructor as deleted when a move constructor is provided.
Summary:
CXXRecordDecls that have a move constructor but no copy constructor need to
have their implicit copy constructor marked as deleted (see C++11 [class.copy]p7, p18)
Currently we don't do that when building an AST with ClangASTContext which causes
Sema to realise that the AST is malformed and asserting when trying to create an implicit
copy constructor for us in the expression:
```
Assertion failed: ((data().DefaultedCopyConstructorIsDeleted || needsOverloadResolutionForCopyConstructor())
    && "Copy constructor should not be deleted"), function setImplicitCopyConstructorIsDeleted, file include/clang/AST/DeclCXX.h, line 828.
```

In the test case there is a class `NoCopyCstr` that should have its copy constructor marked as
deleted (as it has a move constructor). When we end up trying to tab complete in the
`IndirectlyDeletedCopyCstr` constructor, Sema realises that the `IndirectlyDeletedCopyCstr`
has no implicit copy constructor and tries to create one for us. It then realises that
`NoCopyCstr` also has no copy constructor it could find via lookup. However because we
haven't marked the FieldDecl as having a deleted copy constructor the
`needsOverloadResolutionForCopyConstructor()` returns false and the assert fails.
`needsOverloadResolutionForCopyConstructor()` would return true if during the time we
added the `NoCopyCstr` FieldDecl to `IndirectlyDeletedCopyCstr` we would have actually marked
it as having a deleted copy constructor (which would then mark the copy constructor of
`IndirectlyDeletedCopyCstr ` as needing overload resolution and Sema is happy).

This patch sets the correct mark when we complete our CXXRecordDecls (which is the time when
we know whether a copy constructor has been declared). In theory we don't have to do this if
we had a Sema around when building our debug info AST but at the moment we don't have this
so this has to do the job for now.

Reviewers: shafik

Reviewed By: shafik

Subscribers: aprantl, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72694
2020-01-20 14:34:07 +01:00
..
Breakpoint Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Core [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
DataFormatter [lldb][NFC] Cleanup includes in FormatManagerTests.cpp 2019-12-11 11:33:19 +01:00
Disassembler When disassembling Aarch64 target and vendor Apple, set the cpu to 2019-03-07 03:16:45 +00:00
Editline [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
Expression Fix a buffer-size bug when the first DW_OP_piece is undefined 2020-01-16 16:47:59 -08:00
Host [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
Interpreter [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
Language [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
ObjectFile [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
Platform Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Process [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
ScriptInterpreter [Lldb/Lua] Generate Lua Bindings 2019-12-21 11:28:41 -08:00
Signals Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Symbol [lldb] Mark the implicit copy constructor as deleted when a move constructor is provided. 2020-01-20 14:34:07 +01:00
SymbolFile [lldb] Remove default llvm::Triple argument from ClangASTContext constructor 2020-01-08 12:05:51 +01:00
Target [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
TestingSupport [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
UnwindAssembly Fix the unwinding plan augmentation from x86 assembly 2019-10-10 13:23:09 +00:00
Utility RangeDataVector: Support custom sorting for D63540 2020-01-10 15:14:38 +01:00
debugserver [lldb] Fix JSON parser to allow empty arrays 2019-11-18 15:12:55 +01:00
tools [lldb] [unittest] Skip TestStopReplyContainsThreadPcs on NetBSD 2019-11-18 22:36:02 +01:00
CMakeLists.txt [FormatManager] Add a unittest for GetCandidateLanguages() 2019-12-10 13:42:59 -08:00
gtest_common.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00