Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e98d42

Browse files
committed
C++: Turn more "short" comments into "long"
The autoformatter is opinionated about comment styles and assumes that "short" comments attach to the following item while "long" comments are items themselves. I found top-level short comments with the following two commands and then searched the output for empty lines that came after the comment. git grep -A1 '^/\* .*\*/' cpp/ql/src git grep -A1 '^//' 'cpp/ql/src/**/*.ql*'
1 parent 95f5363 commit 8e98d42

22 files changed

Lines changed: 96 additions & 52 deletions

File tree

cpp/ql/src/Likely Bugs/OO/NonVirtualDestructorInBaseClass.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
*/
1212
import cpp
1313

14-
// find classes with virtual functions that have a destructor that is not virtual and for which there exists a derived class
15-
// when calling the destructor of a derived class the destructor in the base class may not be called
14+
/*
15+
* Find classes with virtual functions that have a destructor that is not virtual and for which there exists a derived class
16+
* when calling the destructor of a derived class the destructor in the base class may not be called
17+
*/
1618

1719
from Class c
1820
where exists(VirtualFunction f | f.getDeclaringType() = c)

cpp/ql/src/jsf/4.09 Style/AV Rule 45.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
*/
1111
import cpp
1212

13-
// INTERPRETATION: just check for the absence of camel-case, ie
14-
// forbid 'aB' in identifier names
13+
/*
14+
* INTERPRETATION: just check for the absence of camel-case, ie
15+
* forbid 'aB' in identifier names
16+
*/
1517

1618
from Declaration d, string name, string lowerCase, string upperCase, int pos
1719
where name = d.getName() and

cpp/ql/src/jsf/4.09 Style/AV Rule 53.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
*/
1111
import cpp
1212

13-
// Interpretation: use .h, never .H, .hpp or other variants. What else could be meant by 'header file'?
13+
/*
14+
* Interpretation: use .h, never .H, .hpp or other variants. What else could be
15+
* meant by 'header file'?
16+
*/
1417

1518
from File f
1619
where (f.getExtension().toLowerCase() = "h" or f.getExtension().toLowerCase() = "hpp")

cpp/ql/src/jsf/4.10 Classes/AV Rule 78.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
*/
1212
import cpp
1313

14-
// find classes with virtual functions that have a destructor that is not virtual and for which there exists a derived class
15-
// when calling the destructor of a derived class the destructor in the base class may not be called
14+
/*
15+
* Find classes with virtual functions that have a destructor that is not virtual and for which there exists a derived class
16+
* when calling the destructor of a derived class the destructor in the base class may not be called
17+
*/
1618

1719
from Class c
1820
where exists(VirtualFunction f | f.getDeclaringType() = c)

cpp/ql/src/jsf/4.10 Classes/AV Rule 82.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
*/
1313
import cpp
1414

15+
/*
16+
* Applies to all assignment operators, not just the copy assignment operator.
17+
*/
18+
1519
predicate callOnThis(FunctionCall fc) {
1620
// `this->f(...)`
1721
fc.getQualifier() instanceof ThisExpr or
@@ -88,8 +92,6 @@ predicate assignOperatorWithWrongResult(Operator op, string msg) {
8892
and msg = "Assignment operator in class " + op.getDeclaringType().getName() + " does not return a reference to *this."
8993
}
9094

91-
// Applies to all assignment operators, not just a copy assignment operator
92-
9395
from Operator op, string msg
9496
where assignOperatorWithWrongType(op, msg)
9597
or assignOperatorWithWrongResult(op, msg)

cpp/ql/src/jsf/4.15 Declarations and Definitions/AV Rule 138.ql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ import cpp
2222
* NOTE: only applies to C++; rules for C are different.
2323
*/
2424

25-
// FOR FUTURE REFERENCE ONLY - CURRENTLY USELESS BECAUSE OF POPULATOR LIMITATIONS
26-
// We need to have all the declarations of a variable to make this work; the extractor
27-
// does not currently provide that.
25+
/*
26+
* FOR FUTURE REFERENCE ONLY - CURRENTLY USELESS BECAUSE OF POPULATOR LIMITATIONS
27+
* We need to have all the declarations of a variable to make this work; the extractor
28+
* does not currently provide that.
29+
*/
2830

2931
predicate externalLinkage(Variable v) {
3032
v.getADeclarationEntry().hasSpecifier("extern")

cpp/ql/src/jsf/4.18 Constants/AV Rule 151.1.ql

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
*/
1010
import cpp
1111

12-
// Interpretation (from the example in AV151.1):
13-
// rather than doing points-to to find writes into string literals, the
14-
// check forbids assigning to non-const string variables, which prevents it.
15-
// Casting the const-ness of the variable away is still possible; ideally it
16-
// should be prevented but it doesn't seem worth the effort since it will likely
17-
// flag another rule.
12+
/*
13+
* Interpretation (from the example in AV151.1):
14+
* rather than doing points-to to find writes into string literals, the
15+
* check forbids assigning to non-const string variables, which prevents it.
16+
*
17+
* Casting the const-ness of the variable away is still possible; ideally it
18+
* should be prevented but it doesn't seem worth the effort since it will likely
19+
* flag another rule.
20+
*/
1821

1922
class NonConstStringType extends DerivedType {
2023
NonConstStringType() {

cpp/ql/src/jsf/4.20 Unions and Bit Fields/AV Rule 153.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*/
1010
import cpp
1111

12-
// see MISRA Rule 9-5-1
12+
/*
13+
* See MISRA Rule 9-5-1
14+
*/
1315

1416
from Union u
1517
where u.fromSource()

cpp/ql/src/jsf/4.20 Unions and Bit Fields/AV Rule 156.ql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
*/
1212
import cpp
1313

14-
// TODO: what about the "shall only be accessed" part?
15-
// TODO: implement better check for namelessness (at the moment we rely on the fact
16-
// that the frontend creates dummy names of the form "(unnamed X)" for nameless members)
14+
/*
15+
* TODO: what about the "shall only be accessed" part?
16+
* TODO: implement better check for namelessness (at the moment we rely on the fact
17+
* that the frontend creates dummy names of the form "(unnamed X)" for nameless members)
18+
*/
1719

1820
from Declaration m
1921
where m.isMember() and m.getName().matches("(%") and

cpp/ql/src/jsf/4.21 Operators/AV Rule 157.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
import cpp
1313

14-
// see MISRA Rule 5-14-1
14+
/*
15+
* See MISRA Rule 5-14-1
16+
*/
1517

1618
from BinaryLogicalOperation blo
1719
where blo.fromSource() and

0 commit comments

Comments
 (0)