CPP: Autoformat 'Critical'.

This commit is contained in:
Geoffrey White
2019-04-17 14:17:24 +01:00
parent 45a35a8572
commit e395f5215f
34 changed files with 654 additions and 635 deletions

View File

@@ -7,6 +7,7 @@
* @tags maintainability
* external/cwe/cwe-563
*/
import cpp
// Sometimes it is useful to have a class which is instantiated (on the stack)
@@ -15,22 +16,19 @@ import cpp
// sometimes locking is done this way.
//
// Obviously, such instantiations should not be treated as unused values.
class ScopeUtilityClass extends Class
{
Call getAUse()
{
result = this.getAConstructor().getACallToThisFunction()
}
class ScopeUtilityClass extends Class {
Call getAUse() { result = this.getAConstructor().getACallToThisFunction() }
}
from LocalScopeVariable v, ControlFlowNode def
where definition(v, def)
and not definitionUsePair(v, def, _)
and not v.isStatic()
and not v.getAnAccess().isAddressOfAccess()
where
definition(v, def) and
not definitionUsePair(v, def, _) and
not v.isStatic() and
not v.getAnAccess().isAddressOfAccess() and
// parameter initializers are not in the call-graph at the moment
and not v.(Parameter).getInitializer().getExpr() = def
and not v.getType().getUnderlyingType() instanceof ReferenceType
and not exists(ScopeUtilityClass util | def = util.getAUse())
and not def.isInMacroExpansion()
not v.(Parameter).getInitializer().getExpr() = def and
not v.getType().getUnderlyingType() instanceof ReferenceType and
not exists(ScopeUtilityClass util | def = util.getAUse()) and
not def.isInMacroExpansion()
select def, "Variable '" + v.getName() + "' is assigned a value that is never used"