C++: Apply suggestions from code review

Co-Authored-By: Jonas Jensen <jbj@knef.dk>
This commit is contained in:
Robert Marsh
2019-10-08 10:40:08 -07:00
committed by GitHub
parent d8f539d78b
commit a90e8684e4
3 changed files with 7 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ Using the guards library in C and C++
Overview
--------
The guards library (defined in ``semmle.code.cpp.controlflow.Guards``) provides a class ``GuardCondition`` representing boolean values which are used to make control flow decisions.
The guards library (defined in ``semmle.code.cpp.controlflow.Guards``) provides a class ``GuardCondition`` representing Boolean values that are used to make control flow decisions.
The ``ensuresEq`` and ``ensuresLt`` predicates
----------------------------------------------
@@ -26,4 +26,4 @@ The ``comparesEq`` and ``comparesLt`` predicates help determine if the ``GuardCo
The ``controls`` predicate
------------------------------------------------
The ``controls`` predicate helps determine which blocks are only run when the ``IRGuardCondition`` evaluates a certain way. ``controls(block, testIsTrue)`` holds if ``block`` is only entered if the value of this condition is ``testIsTrue``.
The ``controls`` predicate helps determine which blocks are only run when the ``IRGuardCondition`` evaluates a certain way. ``controls(block, testIsTrue)`` holds if ``block`` is only entered if the value of this condition is ``testIsTrue``.

View File

@@ -5,11 +5,11 @@ Overview
--------
Range analysis determines upper and lower bounds for an expression.
The range analysis library (defined in ``SimpleRangeAnalysis.qll``) provides a set of predicates for determining constant upper and lower bounds on expressions, as well as recognizing integer overflows. For performance, the library performs automatic widening, and may not provide the tightest possible bounds.
The range analysis library (defined in ``semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis``) provides a set of predicates for determining constant upper and lower bounds on expressions, as well as recognizing integer overflows. For performance, the library performs automatic widening and therefore may not provide the tightest possible bounds.
Bounds predicates
-----------------
The ``upperBound`` and ``lowerBound`` predicates provide constant bounds on expressions. No conversions of the argument are included in the bound; if your query needs to take conversions into account, call them on the converted form, such as ``upperBound(expr.getFullyConverted())``.
The ``upperBound`` and ``lowerBound`` predicates provide constant bounds on expressions. No conversions of the argument are included in the bound; in the common case that your query needs to take conversions into account, call them on the converted form, such as ``upperBound(expr.getFullyConverted())``.
Overflow predicates
-------------------

View File

@@ -61,7 +61,7 @@ This query uses the ``GVN`` class to identify calls to ``strncpy`` where the siz
strlen.getTarget().hasGlobalName("strlen") and
globalValueNumber(strncpy.getArgument(0)) != globalValueNumber(sized) and
globalValueNumber(strncpy.getArgument(1)) = globalValueNumber(sized) and
strlen = strncpy.getArgumen(2)
strlen = strncpy.getArgument(2)
sized = strlen.getArgument(0)
select ci, "This call to strncpy is bounded by the size of the source rather than the destination"
@@ -73,11 +73,11 @@ The hash consing library (defined in ``semmle.code.cpp.valuenumbering.HashCons``
The hash consing API
~~~~~~~~~~~~~~~~~~~~
The hash consing library exposes its interface primarily through the ``HashCons`` class. Each instance of ``HashCons`` represents a set of expressions that have the same syntax (including referring to the same variables). To get an expression in the set represented by a particular ``HashCons``, use the ``getAnExpr()`` member predicate.
The hash consing library exposes its interface primarily through the ``HashCons`` class. Each instance of ``HashCons`` represents a set of expressions within one function that have the same syntax (including referring to the same variables). To get an expression in the set represented by a particular ``HashCons``, use the ``getAnExpr()`` member predicate.
.. note::
While the ``HashCons`` class has ``toString`` and ``getLocation`` methods, these are only provided as debugging aids. They give the ``toString`` and ``getLocation`` of an arbitrary ``Instruction`` within the set.
While the ``HashCons`` class has ``toString`` and ``getLocation`` methods, these are only provided as debugging aids. They give the ``toString`` and ``getLocation`` of an arbitrary ``Expr`` within the set.
To get the ``HashCons`` of an ``Expr``, use the ``hashCons`` predicate.