Skip to content

Commit 49f6ac7

Browse files
committed
CPP: Clean up Class, ClassDerivation and ClassTemplateSpecialization QLDoc.
1 parent 2b40849 commit 49f6ac7

File tree

1 file changed

+70
-22
lines changed

1 file changed

+70
-22
lines changed

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

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,13 @@ class Class extends UserType {
465465
}
466466

467467
/**
468-
* Gets a class derivation of this class, for example the "public B"
469-
* in "class D : public B { ... };".
468+
* Gets a class derivation of this class, for example the `public B` in the
469+
* following code:
470+
* ```
471+
* class D : public B {
472+
* ...
473+
* };
474+
* ```
470475
*/
471476
ClassDerivation getADerivation() {
472477
exists(ClassDerivation d | d.getDerivedClass() = this and d = result)
@@ -518,7 +523,12 @@ class Class extends UserType {
518523

519524
/**
520525
* Holds if this class has a virtual class derivation, for example the
521-
* "virtual public B" in "class D : virtual public B { ... };".
526+
* `virtual public B` in the following code:
527+
* ```
528+
* class D : virtual public B {
529+
* ...
530+
* };
531+
* ```
522532
*/
523533
predicate hasVirtualBaseClass(Class base) {
524534
exists(ClassDerivation cd |
@@ -542,7 +552,12 @@ class Class extends UserType {
542552

543553
/**
544554
* Holds if this class has a private class derivation, for example the
545-
* "private B" in "class D : private B { ... };".
555+
* `private B` in the following code:
556+
* ```
557+
* class D : private B {
558+
* ...
559+
* };
560+
* ```
546561
*/
547562
predicate hasPrivateBaseClass(Class base) {
548563
exists(ClassDerivation cd |
@@ -554,7 +569,12 @@ class Class extends UserType {
554569

555570
/**
556571
* Holds if this class has a public class derivation, for example the
557-
* "public B" in "class D : public B { ... };".
572+
* `public B` in the following code:
573+
* ```
574+
* class D : public B {
575+
* ...
576+
* };
577+
* ```
558578
*/
559579
predicate hasPublicBaseClass(Class base) {
560580
exists(ClassDerivation cd |
@@ -566,7 +586,12 @@ class Class extends UserType {
566586

567587
/**
568588
* Holds if this class has a protected class derivation, for example the
569-
* "protected B" in "class D : protected B { ... };".
589+
* `protected B` in the following code:
590+
* ```
591+
* class D : protected B {
592+
* ...
593+
* };
594+
* ```
570595
*/
571596
predicate hasProtectedBaseClass(Class base) {
572597
exists(ClassDerivation cd |
@@ -748,41 +773,59 @@ class Class extends UserType {
748773
}
749774

750775
/**
751-
* A class derivation, for example the "public B" in
752-
* "class D : public B { ... };".
776+
* A class derivation, for example the `public B` in the following code:
777+
* ```
778+
* class D : public B {
779+
* ...
780+
* };
781+
* ```
753782
*/
754783
class ClassDerivation extends Locatable, @derivation {
755784
/**
756785
* Gets the class/struct from which we are actually deriving, resolving a
757-
* typedef if necessary. For example, the base class in the following
758-
* would be B:
786+
* typedef if necessary. For example, the base class in the following code
787+
* would be `B`:
788+
* ```
789+
* struct B {
790+
* };
759791
*
760-
* struct B {};
761792
* typedef B T;
762-
* struct D : T {};
793+
*
794+
* struct D : T {
795+
* };
796+
* ```
763797
*/
764798
Class getBaseClass() {
765799
result = getBaseType().getUnderlyingType()
766800
}
767801

768802
/**
769803
* Gets the type from which we are deriving, without resolving any
770-
* typedef. For example, the base type in the following would be T:
804+
* typedef. For example, the base type in the following code would be `T`:
805+
* ```
806+
* struct B {
807+
* };
771808
*
772-
* struct B {};
773809
* typedef B T;
774-
* struct D : T {};
810+
*
811+
* struct D : T {
812+
* };
813+
* ```
775814
*/
776815
Type getBaseType() {
777816
derivations(underlyingElement(this),_,_,unresolveElement(result),_)
778817
}
779818

780819
/**
781820
* Gets the class that is doing the deriving. For example, the derived
782-
* class in the following would be D:
821+
* class in the following code would be `D`:
822+
* ```
823+
* struct B {
824+
* };
783825
*
784-
* struct B {};
785-
* struct D : B {};
826+
* struct D : B {
827+
* };
828+
* ```
786829
*/
787830
Class getDerivedClass() {
788831
derivations(underlyingElement(this),unresolveElement(result),_,_,_)
@@ -791,13 +834,18 @@ class ClassDerivation extends Locatable, @derivation {
791834
/**
792835
* Gets the index of the derivation in the derivation list for the
793836
* derived class (indexed from 0). For example, the index of the
794-
* derivation of B2 in "struct D : B1, B2 { ... };" would be 1.
837+
* derivation of `B2` in the following code would be `1`:
838+
* ```
839+
* struct D : B1, B2 {
840+
* ...
841+
* };
842+
* ```
795843
*/
796844
int getIndex() {
797845
derivations(underlyingElement(this),_,result,_,_)
798846
}
799847

800-
/** Gets a specifier (for example "public") applied to the derivation. */
848+
/** Gets a specifier (for example `public`) applied to the derivation. */
801849
Specifier getASpecifier() {
802850
derspecifiers(underlyingElement(this),unresolveElement(result))
803851
}
@@ -963,8 +1011,8 @@ class ClassTemplateInstantiation extends Class {
9631011
*/
9641012
abstract class ClassTemplateSpecialization extends Class {
9651013
/**
966-
* Gets the primary template for the specialization, for example
967-
* S<T,int> -> S<T,U>.
1014+
* Gets the primary template for the specialization, for example on
1015+
* `S<T,int>`, the result is `S<T,U>`.
9681016
*/
9691017
TemplateClass getPrimaryTemplate() {
9701018
// Ignoring template arguments, the primary template has the same name

0 commit comments

Comments
 (0)