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

Skip to content

Commit 29c8353

Browse files
committed
C++: Fixes from Geoffrey's review round 3
1 parent c872576 commit 29c8353

3 files changed

Lines changed: 53 additions & 24 deletions

File tree

cpp/ql/src/semmle/code/cpp/exprs/Assignment.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class AssignRemExpr extends AssignArithmeticOperation, @assignremexpr {
9898
}
9999

100100
/**
101-
* A non-overloaded bitwise assignment operation.
102-
`&=`, `|=`, `^=`, `<<=` and `>>=`
101+
* A non-overloaded bitwise assignment operation:
102+
* `&=`, `|=`, `^=`, `<<=`, and `>>=`.
103103
*/
104104
abstract class AssignBitwiseOperation extends AssignOperation {
105105
}

cpp/ql/src/semmle/code/cpp/exprs/Expr.qll

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -285,33 +285,61 @@ class Expr extends StmtParent, @expr {
285285
* Using the C++11 terminology, this predicate selects expressions whose value category is lvalue.
286286
*/
287287
predicate isLValue() {
288-
this instanceof StringLiteral /* C++ n3337 - 5.1.1 clause 1 */
289-
or this.(ParenthesisExpr).getExpr().isLValue() /* C++ n3337 - 5.1.1 clause 6 */
290-
or (this instanceof VariableAccess and not this instanceof FieldAccess) /* C++ n3337 - 5.1.1 clauses 8 and 9, variables and data members */
291-
or exists(FunctionAccess fa | fa = this | /* C++ n3337 - 5.1.1 clauses 8 and 9, functions */
288+
// C++ n3337 - 5.1.1 clause 1
289+
this instanceof StringLiteral
290+
or
291+
// C++ n3337 - 5.1.1 clause 6
292+
this.(ParenthesisExpr).getExpr().isLValue()
293+
or
294+
// C++ n3337 - 5.1.1 clauses 8 and 9, variables and data members
295+
(this instanceof VariableAccess and not this instanceof FieldAccess)
296+
or
297+
// C++ n3337 - 5.1.1 clauses 8 and 9, functions
298+
exists(FunctionAccess fa | fa = this |
292299
fa.getTarget().isStatic()
293-
or not fa.getTarget().isMember()
300+
or
301+
not fa.getTarget().isMember()
294302
)
295-
or this instanceof ArrayExpr /* C++ n3337 - 5.2.1 clause 1 */
296-
or this.getType() instanceof ReferenceType /* C++ n3337 - 5.2.2 clause 10
297-
5.2.5 clause 4, no bullet point
298-
5.2.7 clauses 2 and 5
299-
5.2.9 clause 1
300-
5.2.10 clause 1
301-
5.2.11 clause 1
302-
5.4 clause 1 */
303-
or this.(FieldAccess).getQualifier().isLValue() /* C++ n3337 - 5.2.5 clause 4, 2nd bullet point */
304-
or this instanceof TypeidOperator /* C++ n3337 - 5.2.8 clause 1 */
305-
or this instanceof PointerDereferenceExpr /* C++ n3337 - 5.3.1 clause 1 */
306-
or this instanceof PrefixIncrExpr /* C++ n3337 - 5.3.2 clause 1 */
307-
or this instanceof PrefixDecrExpr /* C++ n3337 - 5.3.2 clause 2 */
308-
or exists(ConditionalExpr ce | ce = this | /* C++ n3337 - 5.16 clause 4 */
303+
or
304+
// C++ n3337 - 5.2.1 clause 1
305+
this instanceof ArrayExpr
306+
or
307+
// C++ n3337 - 5.2.2 clause 10
308+
// 5.2.5 clause 4, no bullet point
309+
// 5.2.7 clauses 2 and 5
310+
// 5.2.9 clause 1
311+
// 5.2.10 clause 1
312+
// 5.2.11 clause 1
313+
// 5.4 clause 1
314+
this.getType() instanceof ReferenceType
315+
or
316+
// C++ n3337 - 5.2.5 clause 4, 2nd bullet point
317+
this.(FieldAccess).getQualifier().isLValue()
318+
or
319+
// C++ n3337 - 5.2.8 clause 1
320+
this instanceof TypeidOperator
321+
or
322+
// C++ n3337 - 5.3.1 clause 1
323+
this instanceof PointerDereferenceExpr
324+
or
325+
// C++ n3337 - 5.3.2 clause 1
326+
this instanceof PrefixIncrExpr
327+
or
328+
// C++ n3337 - 5.3.2 clause 2
329+
this instanceof PrefixDecrExpr
330+
or
331+
// C++ n3337 - 5.16 clause 4
332+
exists(ConditionalExpr ce | ce = this |
309333
ce.getThen().isLValue() and
310334
ce.getElse().isLValue() and
311335
ce.getThen().getType() = ce.getElse().getType()
312336
)
313-
or this instanceof Assignment /* C++ n3337 - 5.17 clause 1 */
314-
or this.(CommaExpr).getRightOperand().isLValue() /* C++ n3337 - 5.18 clause 1 */
337+
or
338+
// C++ n3337 - 5.17 clause 1
339+
this instanceof Assignment
340+
or
341+
// C++ n3337 - 5.18 clause 1
342+
this.(CommaExpr).getRightOperand().isLValue()
315343
}
316344

317345
/**

cpp/ql/src/semmle/code/cpp/internal/QualifiedName.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
private import semmle.code.cpp.Declaration as D
21
/**
32
* INTERNAL: Do not use. Provides classes and predicates for getting names of
43
* declarations, especially qualified names. Import this library `private` and
@@ -12,6 +11,8 @@ private import semmle.code.cpp.Declaration as D
1211
* their qualified names and parameters match.
1312
*/
1413

14+
private import semmle.code.cpp.Declaration as D
15+
1516
class Namespace extends @namespace {
1617
string toString() { result = "QualifiedName Namespace" }
1718

0 commit comments

Comments
 (0)