mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
C++: test template classes with MemberFunction::getTypeOfThis()
This commit is contained in:
@@ -54,3 +54,76 @@ class D {
|
||||
global++;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class InstantiatedTemplateClass {
|
||||
int x;
|
||||
|
||||
public:
|
||||
|
||||
void f1() {
|
||||
// Implicit dereference of `this.`
|
||||
x++;
|
||||
}
|
||||
|
||||
void f2() {
|
||||
// Explicit dereference of `this.`
|
||||
this->x++;
|
||||
}
|
||||
|
||||
int f3() const {
|
||||
// We expect the type of `this` to be const-qualified.
|
||||
return x;
|
||||
}
|
||||
|
||||
int f4() volatile {
|
||||
// We expect the type of `this` to be volatile-qualified.
|
||||
return x;
|
||||
}
|
||||
|
||||
int f5() const volatile {
|
||||
// We expect the type of `this` to be qualified as both const and volatile.
|
||||
return x;
|
||||
}
|
||||
|
||||
void f6() {
|
||||
// No use of `this`, but we still expect to be able to get its type.
|
||||
global++;
|
||||
}
|
||||
|
||||
float f7() const & {
|
||||
// We expect the type of `this` to be const-qualified.
|
||||
return x;
|
||||
}
|
||||
|
||||
float f8() && {
|
||||
// We expect the type of `this` to be unqualified.
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
void instantiate() {
|
||||
InstantiatedTemplateClass<int> x;
|
||||
x.f1();
|
||||
x.f2();
|
||||
x.f3();
|
||||
x.f4();
|
||||
x.f5();
|
||||
x.f6();
|
||||
x.f7();
|
||||
|
||||
float val = InstantiatedTemplateClass<int>().f8();
|
||||
}
|
||||
|
||||
// Since there are no instantiations of this class, we don't expect
|
||||
// MemberFunction::getTypeOfThis() to hold.
|
||||
template<typename T>
|
||||
class UninstantiatedTemplateClass {
|
||||
int x;
|
||||
|
||||
public:
|
||||
|
||||
void f1() {
|
||||
x++;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,6 +6,20 @@ thisExprType
|
||||
| test.cpp:31:12:31:12 | this | file://:0:0:0:0 | const volatile C * |
|
||||
| test.cpp:41:12:41:12 | this | file://:0:0:0:0 | const C * |
|
||||
| test.cpp:46:12:46:12 | this | file://:0:0:0:0 | C * |
|
||||
| test.cpp:66:5:66:5 | this | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:66:5:66:5 | this | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:71:5:71:8 | this | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:71:5:71:8 | this | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:76:12:76:12 | this | file://:0:0:0:0 | const InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:76:12:76:12 | this | file://:0:0:0:0 | const InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:81:12:81:12 | this | file://:0:0:0:0 | volatile InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:81:12:81:12 | this | file://:0:0:0:0 | volatile InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:86:12:86:12 | this | file://:0:0:0:0 | const volatile InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:86:12:86:12 | this | file://:0:0:0:0 | const volatile InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:96:12:96:12 | this | file://:0:0:0:0 | const InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:96:12:96:12 | this | file://:0:0:0:0 | const InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:101:12:101:12 | this | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:101:12:101:12 | this | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
#select
|
||||
| test.cpp:9:8:9:9 | f1 | file://:0:0:0:0 | C * |
|
||||
| test.cpp:14:8:14:9 | f2 | file://:0:0:0:0 | C * |
|
||||
@@ -16,3 +30,19 @@ thisExprType
|
||||
| test.cpp:39:9:39:10 | f7 | file://:0:0:0:0 | const C * |
|
||||
| test.cpp:44:9:44:10 | f8 | file://:0:0:0:0 | C * |
|
||||
| test.cpp:53:8:53:8 | f | file://:0:0:0:0 | D * |
|
||||
| test.cpp:64:8:64:8 | f1 | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:64:8:64:9 | f1 | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:69:8:69:8 | f2 | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:69:8:69:9 | f2 | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:74:7:74:7 | f3 | file://:0:0:0:0 | const InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:74:7:74:8 | f3 | file://:0:0:0:0 | const InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:79:7:79:7 | f4 | file://:0:0:0:0 | volatile InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:79:7:79:8 | f4 | file://:0:0:0:0 | volatile InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:84:7:84:7 | f5 | file://:0:0:0:0 | const volatile InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:84:7:84:8 | f5 | file://:0:0:0:0 | const volatile InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:89:8:89:8 | f6 | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:89:8:89:9 | f6 | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:94:9:94:9 | f7 | file://:0:0:0:0 | const InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:94:9:94:10 | f7 | file://:0:0:0:0 | const InstantiatedTemplateClass<T> * |
|
||||
| test.cpp:99:9:99:9 | f8 | file://:0:0:0:0 | InstantiatedTemplateClass<int> * |
|
||||
| test.cpp:99:9:99:10 | f8 | file://:0:0:0:0 | InstantiatedTemplateClass<T> * |
|
||||
|
||||
Reference in New Issue
Block a user