mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
CPP: Autoformat 'Critical'.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user