Skip to content

Commit 8e39eb9

Browse files
committed
C++: Fix incorrect dbscheme assumptions on proxy classes
1 parent 13e8853 commit 8e39eb9

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

cpp/ql/lib/semmle/code/cpp/Class.qll

+13-4
Original file line numberDiff line numberDiff line change
@@ -1076,13 +1076,19 @@ class VirtualBaseClass extends Class {
10761076
}
10771077

10781078
/**
1079-
* The proxy class (where needed) associated with a template parameter, as
1080-
* in the following code:
1081-
* ```
1079+
* The proxy class (where needed) associated with a template parameter or a
1080+
* decltype, as in the following code:
1081+
* ```cpp
10821082
* template <typename T>
10831083
* struct S : T { // the type of this T is a proxy class
10841084
* ...
10851085
* };
1086+
*
1087+
* template <typename T>
1088+
* concept C =
1089+
* decltype(std::span{std::declval<T&>()})::extent
1090+
* != std::dynamic_extent;
1091+
* // the type of decltype(std::span{std::declval<T&>()}) is a proxy class
10861092
* ```
10871093
*/
10881094
class ProxyClass extends UserType {
@@ -1093,10 +1099,13 @@ class ProxyClass extends UserType {
10931099
/** Gets the location of the proxy class. */
10941100
override Location getLocation() { result = this.getTemplateParameter().getDefinitionLocation() }
10951101

1096-
/** Gets the template parameter for which this is the proxy class. */
1102+
/** Gets the template parameter for which this is the proxy class, if any. */
10971103
TypeTemplateParameter getTemplateParameter() {
10981104
is_proxy_class_for(underlyingElement(this), unresolveElement(result))
10991105
}
1106+
1107+
/** Gets the decltype for which this is the proxy class, if any. */
1108+
Decltype getDecltype() { is_proxy_class_for(underlyingElement(this), unresolveElement(result)) }
11001109
}
11011110

11021111
// Unpacks "array of ... of array of t" into t.

cpp/ql/lib/semmlecode.cpp.dbscheme

+3-1
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,11 @@ class_template_argument_value(
847847
int arg_value: @expr ref
848848
);
849849

850+
@user_or_decltype = @usertype | @decltype;
851+
850852
is_proxy_class_for(
851853
unique int id: @usertype ref,
852-
unique int templ_param_id: @usertype ref
854+
int templ_param_id: @user_or_decltype ref
853855
);
854856

855857
type_mentions(

0 commit comments

Comments
 (0)