aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-05-22 22:34:29 +0800
committerGitHub <noreply@github.com>2017-05-22 22:34:29 +0800
commit74d2e7311aed67e3bb6fcf1f0fa138bc3d304095 (patch)
treed5a796563e06e32baf41278f6204b39d7c845cd1 /libsolidity/analysis
parent4fd6657eefe8e07d085b65f0521a8aac25670705 (diff)
parent621c3fa22fc5830517ad3174f7ebe2ca67f1f700 (diff)
downloaddexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.tar
dexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.tar.gz
dexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.tar.bz2
dexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.tar.lz
dexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.tar.xz
dexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.tar.zst
dexon-solidity-74d2e7311aed67e3bb6fcf1f0fa138bc3d304095.zip
Merge pull request #2265 from roadriverrail/inline_asm_unused_warning
Analyze InlineAssembly for variable use
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/StaticAnalyzer.cpp25
-rw-r--r--libsolidity/analysis/StaticAnalyzer.h1
2 files changed, 24 insertions, 2 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp
index 369376fa..d273b26e 100644
--- a/libsolidity/analysis/StaticAnalyzer.cpp
+++ b/libsolidity/analysis/StaticAnalyzer.cpp
@@ -21,14 +21,16 @@
*/
#include <libsolidity/analysis/StaticAnalyzer.h>
-#include <memory>
#include <libsolidity/ast/AST.h>
+#include <libsolidity/inlineasm/AsmAnalysis.h>
+#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
+#include <libsolidity/inlineasm/AsmData.h>
+#include <memory>
using namespace std;
using namespace dev;
using namespace dev::solidity;
-
bool StaticAnalyzer::analyze(SourceUnit const& _sourceUnit)
{
_sourceUnit.accept(*this);
@@ -128,3 +130,22 @@ void StaticAnalyzer::warning(SourceLocation const& _location, string const& _des
m_errors.push_back(err);
}
+
+bool StaticAnalyzer::visit(InlineAssembly const& _inlineAssembly)
+{
+ if (!m_currentFunction)
+ return true;
+
+ for (auto const& ref: _inlineAssembly.annotation().externalReferences)
+ {
+ if (auto var = dynamic_cast<VariableDeclaration const*>(ref.second.declaration))
+ {
+ solAssert(!var->name().empty(), "");
+ if (var->isLocalVariable())
+ m_localVarUseCount[var] += 1;
+ }
+ }
+
+ return true;
+}
+
diff --git a/libsolidity/analysis/StaticAnalyzer.h b/libsolidity/analysis/StaticAnalyzer.h
index ab72e7d9..458bab2a 100644
--- a/libsolidity/analysis/StaticAnalyzer.h
+++ b/libsolidity/analysis/StaticAnalyzer.h
@@ -65,6 +65,7 @@ private:
virtual bool visit(Identifier const& _identifier) override;
virtual bool visit(Return const& _return) override;
virtual bool visit(MemberAccess const& _memberAccess) override;
+ virtual bool visit(InlineAssembly const& _inlineAssembly) override;
ErrorList& m_errors;