mirror of
https://github.com/github/codeql.git
synced 2025-12-23 12:16:33 +01:00
Merge pull request #7884 from rdmarsh2/rdmarsh2/template-implicit-copy-constructor
C++: fix hasImplicitCopyConstructor for templates
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* `hasImplicitCopyConstructor` and `hasImplicitCopyAssignmentOperator` now correctly handle implicitly-deleted operators in templates.
|
||||
@@ -251,6 +251,16 @@ class Class extends UserType {
|
||||
not this.implicitCopyConstructorDeleted() and
|
||||
forall(CopyConstructor cc | cc = this.getAMemberFunction() |
|
||||
cc.isCompilerGenerated() and not cc.isDeleted()
|
||||
) and
|
||||
(
|
||||
not this instanceof ClassTemplateInstantiation
|
||||
or
|
||||
this.(ClassTemplateInstantiation).getTemplate().hasImplicitCopyConstructor()
|
||||
) and
|
||||
(
|
||||
not this instanceof PartialClassTemplateSpecialization
|
||||
or
|
||||
this.(PartialClassTemplateSpecialization).getPrimaryTemplate().hasImplicitCopyConstructor()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -266,6 +276,18 @@ class Class extends UserType {
|
||||
not this.implicitCopyAssignmentOperatorDeleted() and
|
||||
forall(CopyAssignmentOperator ca | ca = this.getAMemberFunction() |
|
||||
ca.isCompilerGenerated() and not ca.isDeleted()
|
||||
) and
|
||||
(
|
||||
not this instanceof ClassTemplateInstantiation
|
||||
or
|
||||
this.(ClassTemplateInstantiation).getTemplate().hasImplicitCopyAssignmentOperator()
|
||||
) and
|
||||
(
|
||||
not this instanceof PartialClassTemplateSpecialization
|
||||
or
|
||||
this.(PartialClassTemplateSpecialization)
|
||||
.getPrimaryTemplate()
|
||||
.hasImplicitCopyAssignmentOperator()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
| difference::Base | can | does NOT | have implicit copy assignment |
|
||||
| difference::OnlyAssign | can | does | have implicit copy assignment |
|
||||
| difference::OnlyCtor | can NOT | does NOT | have implicit copy assignment |
|
||||
| instantiated_explicit_ctor::Wrapper<int> | can | does | have implicit copy assignment |
|
||||
| moves::MoveAssign | can NOT | does NOT | have implicit copy assignment |
|
||||
| moves::MoveCtor | can NOT | does NOT | have implicit copy assignment |
|
||||
| private_cc::C | can | does NOT | have implicit copy assignment |
|
||||
|
||||
@@ -131,3 +131,21 @@ namespace difference {
|
||||
class OnlyAssign : Base {
|
||||
};
|
||||
}
|
||||
|
||||
namespace instantiated_explicit_ctor {
|
||||
template<class T>
|
||||
class Wrapper {
|
||||
public:
|
||||
Wrapper(Wrapper<T> &other) {
|
||||
m_t = other.m_t;
|
||||
}
|
||||
|
||||
Wrapper() {
|
||||
m_t = 0;
|
||||
}
|
||||
private:
|
||||
T m_t;
|
||||
};
|
||||
|
||||
Wrapper<int> wrapped_int;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
| difference::Base | can | does NOT | have implicit copy constructor |
|
||||
| difference::OnlyAssign | can NOT | does NOT | have implicit copy constructor |
|
||||
| difference::OnlyCtor | can | does | have implicit copy constructor |
|
||||
| instantiated_explicit_ctor::Wrapper<int> | can | does NOT | have implicit copy constructor |
|
||||
| moves::MoveAssign | can NOT | does NOT | have implicit copy constructor |
|
||||
| moves::MoveCtor | can NOT | does NOT | have implicit copy constructor |
|
||||
| private_cc::C | can | does NOT | have implicit copy constructor |
|
||||
|
||||
@@ -86,5 +86,9 @@
|
||||
| copy.cpp:131:9:131:9 | OnlyAssign | deleted | |
|
||||
| copy.cpp:131:9:131:9 | operator= | | |
|
||||
| copy.cpp:131:9:131:9 | operator= | | |
|
||||
| copy.cpp:137:9:137:9 | operator= | | |
|
||||
| copy.cpp:139:5:139:11 | Wrapper | | |
|
||||
| copy.cpp:143:5:143:5 | Wrapper | | |
|
||||
| copy.cpp:143:5:143:11 | Wrapper | | |
|
||||
| file://:0:0:0:0 | operator= | | |
|
||||
| file://:0:0:0:0 | operator= | | |
|
||||
|
||||
Reference in New Issue
Block a user