Skip to content

Commit 10824f9

Browse files
committed
C++: add method qldoc in Class.qll
1 parent f24c4e5 commit 10824f9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,15 @@ class Class extends UserType {
458458
exists(ClassDerivation d | d.getDerivedClass() = this and d = result)
459459
}
460460

461+
/**
462+
* Gets class derivation number `index` of this class/struct, for example the
463+
* `public B` is derivation 1 in the following code:
464+
* ```
465+
* class D : public A, public B, public C {
466+
* ...
467+
* };
468+
* ```
469+
*/
461470
ClassDerivation getDerivation(int index) {
462471
exists(ClassDerivation d | d.getDerivedClass() = this and d.getIndex() = index and d = result)
463472
}
@@ -900,6 +909,22 @@ class AbstractClass extends Class {
900909
class TemplateClass extends Class {
901910
TemplateClass() { usertypes(underlyingElement(this), _, 6) }
902911

912+
/**
913+
* Gets a class instantiated from this template.
914+
*
915+
* For example for `MyTemplateClass<T>` in the following code, the results are
916+
* `MyTemplateClass<int>` and `MyTemplateClass<long>`:
917+
* ```
918+
* template<class T>
919+
* class MyTemplateClass {
920+
* ...
921+
* };
922+
*
923+
* MyTemplateClass<int> instance;
924+
*
925+
* MyTemplateClass<long> instance;
926+
* ```
927+
*/
903928
Class getAnInstantiation() {
904929
result.isConstructedFrom(this) and
905930
exists(result.getATemplateArgument())

0 commit comments

Comments
 (0)