mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Add getTemplateClass to DeductionGuide
This commit is contained in:
2305
cpp/downgrades/e197626a6ebccd052d5c891975fccf8aebcc9803/old.dbscheme
Normal file
2305
cpp/downgrades/e197626a6ebccd052d5c891975fccf8aebcc9803/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
|||||||
|
description: Add relation between deduction guides and class templates
|
||||||
|
compatibility: full
|
||||||
|
deduction_guide_for_class.rel: delete
|
||||||
4
cpp/ql/lib/change-notes/2024-08-01-deduction-guide.md
Normal file
4
cpp/ql/lib/change-notes/2024-08-01-deduction-guide.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: feature
|
||||||
|
---
|
||||||
|
* A `getTemplateClass` predicate was added to the `DeductionGuide` class to get the class template for which the deduction guide is a guide.
|
||||||
@@ -898,4 +898,11 @@ class UserDefinedLiteral extends Function {
|
|||||||
*/
|
*/
|
||||||
class DeductionGuide extends Function {
|
class DeductionGuide extends Function {
|
||||||
DeductionGuide() { functions(underlyingElement(this), _, 8) }
|
DeductionGuide() { functions(underlyingElement(this), _, 8) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the class template for which this is a deduction guide.
|
||||||
|
*/
|
||||||
|
TemplateClass getTemplateClass() {
|
||||||
|
deduction_guide_for_class(underlyingElement(this), unresolveElement(result))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -409,6 +409,11 @@ function_defaulted(unique int id: @function ref);
|
|||||||
|
|
||||||
function_prototyped(unique int id: @function ref)
|
function_prototyped(unique int id: @function ref)
|
||||||
|
|
||||||
|
deduction_guide_for_class(
|
||||||
|
int id: @function ref,
|
||||||
|
int class_template: @usertype ref
|
||||||
|
)
|
||||||
|
|
||||||
member_function_this_type(
|
member_function_this_type(
|
||||||
unique int id: @function ref,
|
unique int id: @function ref,
|
||||||
int this_type: @type ref
|
int this_type: @type ref
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
|||||||
|
description: Add relation between deduction guides and class templates
|
||||||
|
compatibility: partial
|
||||||
18
cpp/ql/test/library-tests/deduction_guides/test.cpp
Normal file
18
cpp/ql/test/library-tests/deduction_guides/test.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// semmle-extractor-options: -std=c++20
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct C {
|
||||||
|
C(const T);
|
||||||
|
};
|
||||||
|
|
||||||
|
C(const double) -> C<int>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
C(const T) -> C<int>;
|
||||||
|
|
||||||
|
void test() {
|
||||||
|
new C<char>(0);
|
||||||
|
new C<int>(0);
|
||||||
|
new C(0.0f);
|
||||||
|
new C(0.0);
|
||||||
|
}
|
||||||
3
cpp/ql/test/library-tests/deduction_guides/test.expected
Normal file
3
cpp/ql/test/library-tests/deduction_guides/test.expected
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
| file://:0:0:0:0 | C | test.cpp:4:8:4:8 | C<T> |
|
||||||
|
| test.cpp:5:5:5:5 | (unnamed deduction guide) | test.cpp:4:8:4:8 | C<T> |
|
||||||
|
| test.cpp:11:1:11:1 | C | test.cpp:4:8:4:8 | C<T> |
|
||||||
4
cpp/ql/test/library-tests/deduction_guides/test.ql
Normal file
4
cpp/ql/test/library-tests/deduction_guides/test.ql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import cpp
|
||||||
|
|
||||||
|
from DeductionGuide d
|
||||||
|
select d, d.getTemplateClass()
|
||||||
Reference in New Issue
Block a user