Warn on unused local variables

Analyze functions for all local variables, parameters, and named
return variables which are never used in the function, and issue
a warning.
This commit is contained in:
Rhett Aultman
2017-05-03 11:26:21 +02:00
committed by chriseth
parent c09f071ff6
commit a40c8cfb68
5 changed files with 205 additions and 36 deletions
+6
View File
@@ -61,6 +61,8 @@ private:
virtual void endVisit(FunctionDefinition const& _function) override;
virtual bool visit(ExpressionStatement const& _statement) override;
virtual bool visit(VariableDeclaration const& _variable) override;
virtual bool visit(Identifier const& _identifier) override;
virtual bool visit(MemberAccess const& _memberAccess) override;
@@ -71,6 +73,10 @@ private:
/// Flag that indicates whether a public function does not contain the "payable" modifier.
bool m_nonPayablePublic = false;
std::map<VariableDeclaration const*, int> m_localVarUseCount;
bool m_inFunction = false;
};
}