mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into HEAD
This commit is contained in:
@@ -34,10 +34,9 @@ using namespace solidity::frontend;
|
||||
|
||||
bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)
|
||||
{
|
||||
m_errorOccured = false;
|
||||
auto errorWatcher = m_errorReporter.errorWatcher();
|
||||
_sourceUnit.accept(*this);
|
||||
|
||||
return !m_errorOccured;
|
||||
return errorWatcher.ok();
|
||||
}
|
||||
|
||||
bool DocStringAnalyser::visit(ContractDefinition const& _contract)
|
||||
@@ -57,6 +56,31 @@ bool DocStringAnalyser::visit(FunctionDefinition const& _function)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DocStringAnalyser::visit(VariableDeclaration const& _variable)
|
||||
{
|
||||
if (_variable.isStateVariable())
|
||||
{
|
||||
static set<string> const validPublicTags = set<string>{"dev", "notice", "return", "title", "author"};
|
||||
if (_variable.isPublic())
|
||||
parseDocStrings(_variable, _variable.annotation(), validPublicTags, "public state variables");
|
||||
else
|
||||
{
|
||||
parseDocStrings(_variable, _variable.annotation(), validPublicTags, "non-public state variables");
|
||||
if (_variable.annotation().docTags.count("notice") > 0)
|
||||
m_errorReporter.warning(
|
||||
9098_error, _variable.documentation()->location(),
|
||||
"Documentation tag on non-public state variables will be disallowed in 0.7.0. You will need to use the @dev tag explicitly."
|
||||
);
|
||||
}
|
||||
if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0)
|
||||
m_errorReporter.warning(
|
||||
4822_error, _variable.documentation()->location(),
|
||||
"Documentation tag @title and @author is only allowed on contract definitions. It will be disallowed in 0.7.0."
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DocStringAnalyser::visit(ModifierDefinition const& _modifier)
|
||||
{
|
||||
handleCallable(_modifier, _modifier, _modifier.annotation());
|
||||
@@ -127,8 +151,7 @@ void DocStringAnalyser::parseDocStrings(
|
||||
DocStringParser parser;
|
||||
if (_node.documentation() && !_node.documentation()->text()->empty())
|
||||
{
|
||||
if (!parser.parse(*_node.documentation()->text(), m_errorReporter))
|
||||
m_errorOccured = true;
|
||||
parser.parse(*_node.documentation()->text(), m_errorReporter);
|
||||
_annotation.docTags = parser.tags();
|
||||
}
|
||||
|
||||
@@ -144,7 +167,20 @@ void DocStringAnalyser::parseDocStrings(
|
||||
if (docTag.first == "return")
|
||||
{
|
||||
returnTagsVisited++;
|
||||
if (auto* function = dynamic_cast<FunctionDefinition const*>(&_node))
|
||||
if (auto* varDecl = dynamic_cast<VariableDeclaration const*>(&_node))
|
||||
{
|
||||
if (!varDecl->isPublic())
|
||||
appendError(
|
||||
_node.documentation()->location(),
|
||||
"Documentation tag \"@" + docTag.first + "\" is only allowed on public state-variables."
|
||||
);
|
||||
if (returnTagsVisited > 1)
|
||||
appendError(
|
||||
_node.documentation()->location(),
|
||||
"Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables."
|
||||
);
|
||||
}
|
||||
else if (auto* function = dynamic_cast<FunctionDefinition const*>(&_node))
|
||||
{
|
||||
string content = docTag.second.content;
|
||||
string firstWord = content.substr(0, content.find_first_of(" \t"));
|
||||
@@ -172,6 +208,5 @@ void DocStringAnalyser::parseDocStrings(
|
||||
|
||||
void DocStringAnalyser::appendError(SourceLocation const& _location, string const& _description)
|
||||
{
|
||||
m_errorOccured = true;
|
||||
m_errorReporter.docstringParsingError(7816_error, _location, _description);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
private:
|
||||
bool visit(ContractDefinition const& _contract) override;
|
||||
bool visit(FunctionDefinition const& _function) override;
|
||||
bool visit(VariableDeclaration const& _variable) override;
|
||||
bool visit(ModifierDefinition const& _modifier) override;
|
||||
bool visit(EventDefinition const& _event) override;
|
||||
|
||||
@@ -67,6 +68,12 @@ private:
|
||||
StructurallyDocumentedAnnotation& _annotation
|
||||
);
|
||||
|
||||
void handleDeclaration(
|
||||
Declaration const& _declaration,
|
||||
StructurallyDocumented const& _node,
|
||||
StructurallyDocumentedAnnotation& _annotation
|
||||
);
|
||||
|
||||
void parseDocStrings(
|
||||
StructurallyDocumented const& _node,
|
||||
StructurallyDocumentedAnnotation& _annotation,
|
||||
@@ -76,7 +83,6 @@ private:
|
||||
|
||||
void appendError(langutil::SourceLocation const& _location, std::string const& _description);
|
||||
|
||||
bool m_errorOccured = false;
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,8 +44,9 @@ namespace solidity::frontend
|
||||
|
||||
bool ReferencesResolver::resolve(ASTNode const& _root)
|
||||
{
|
||||
auto errorWatcher = m_errorReporter.errorWatcher();
|
||||
_root.accept(*this);
|
||||
return !m_errorOccurred;
|
||||
return errorWatcher.ok();
|
||||
}
|
||||
|
||||
bool ReferencesResolver::visit(Block const& _block)
|
||||
@@ -267,19 +268,16 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
|
||||
|
||||
void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description)
|
||||
{
|
||||
m_errorOccurred = true;
|
||||
m_errorReporter.declarationError(8532_error, _location, _description);
|
||||
}
|
||||
|
||||
void ReferencesResolver::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _ssl, string const& _description)
|
||||
{
|
||||
m_errorOccurred = true;
|
||||
m_errorReporter.declarationError(3881_error, _location, _ssl, _description);
|
||||
}
|
||||
|
||||
void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description)
|
||||
{
|
||||
m_errorOccurred = true;
|
||||
m_errorReporter.fatalDeclarationError(6546_error, _location, _description);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ private:
|
||||
/// Stack of return parameters.
|
||||
std::vector<ParameterList const*> m_returnParameters;
|
||||
bool const m_resolveInsideCode;
|
||||
bool m_errorOccurred = false;
|
||||
|
||||
InlineAssemblyAnnotation* m_yulAnnotation = nullptr;
|
||||
bool m_yulInsideFunction = false;
|
||||
|
||||
Reference in New Issue
Block a user