mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Match more SPDX-License-Identifer lines
This commit is contained in:
parent
f58d58738e
commit
2916206cab
@ -6,6 +6,7 @@ Language Features:
|
||||
|
||||
|
||||
Compiler Features:
|
||||
* Parser: Extend parsing rule for ``SPDX-License-Identifier``.
|
||||
* SMTChecker: Function definitions can be annotated with the custom Natspec tag ``custom:smtchecker abstract-function-nondet`` to be abstracted by a nondeterministic value when called.
|
||||
* Standard JSON / combined JSON: New artifact "functionDebugData" that contains bytecode offsets of entry points of functions and potentially more information in the future.
|
||||
* Yul Optimizer: Evaluate ``keccak256(a, c)``, when the value at memory location ``a`` is known at compile time and ``c`` is a constant ``<= 32``.
|
||||
@ -47,7 +48,6 @@ Compiler Features:
|
||||
* Yul EVM Code Transform: Stack Optimization: Reuse slots of unused function arguments and defer allocating stack slots for return variables until after expression statements and assignments that do not reference them.
|
||||
* Yul Optimizer: Added a new step FunctionSpecializer, that specializes a function with its literal arguments.
|
||||
|
||||
|
||||
Bugfixes:
|
||||
* Antlr Grammar: Fix parsing of import paths involving properly distinguishing between empty and non-empty string literals in general.
|
||||
* AST Output: Fix ``kind`` field of ``ModifierInvocation`` for base constructor calls.
|
||||
@ -100,7 +100,6 @@ Compiler Features:
|
||||
* Optimizer: Simple inlining when jumping to small blocks that jump again after a few side-effect free opcodes.
|
||||
* NatSpec: Allow and export all tags that start with ``@custom:``.
|
||||
|
||||
|
||||
Bugfixes:
|
||||
* AST: Added ``referencedDeclaration`` for enum members.
|
||||
* Code Generator: Fix internal error when functions are passed as parameters of other callables, when the function types can be implicitly converted, but not identical.
|
||||
|
||||
@ -2052,7 +2052,10 @@ bool Parser::variableDeclarationStart()
|
||||
optional<string> Parser::findLicenseString(std::vector<ASTPointer<ASTNode>> const& _nodes)
|
||||
{
|
||||
// We circumvent the scanner here, because it skips non-docstring comments.
|
||||
static regex const licenseRegex("SPDX-License-Identifier:\\s*([a-zA-Z0-9 ()+.-]+)");
|
||||
// This matches the entire line starting with the SPDX-License-Identifier.
|
||||
static regex const licenseLineRegex("SPDX-License-Identifier:\\s*([^\n])\\s*(\\*/)?");
|
||||
// This is the actual allowed format for the license tag.
|
||||
static regex const licenseRegex("^([a-zA-Z0-9 ()+.-]*)$");
|
||||
|
||||
// Search inside all parts of the source not covered by parsed nodes.
|
||||
// This will leave e.g. "global comments".
|
||||
@ -2070,12 +2073,26 @@ optional<string> Parser::findLicenseString(std::vector<ASTPointer<ASTNode>> cons
|
||||
vector<string> matches;
|
||||
for (auto const& [start, end]: sequencesToSearch)
|
||||
{
|
||||
smatch match;
|
||||
if (regex_search(start, end, match, licenseRegex))
|
||||
smatch lineMatch;
|
||||
if (regex_search(start, end, lineMatch, licenseLineRegex))
|
||||
{
|
||||
string license{boost::trim_copy(string(match[1]))};
|
||||
if (!license.empty())
|
||||
matches.emplace_back(std::move(license));
|
||||
string license{boost::trim_copy(string(lineMatch[1]))};
|
||||
smatch licenseMatch;
|
||||
if (regex_search(license, licenseMatch, licenseRegex))
|
||||
{
|
||||
license = string(licenseMatch[1]);
|
||||
if (!license.empty())
|
||||
matches.emplace_back(std::move(license));
|
||||
}
|
||||
else
|
||||
{
|
||||
parserError(
|
||||
5406_error,
|
||||
{-1, -1, m_scanner->charStream()},
|
||||
"SPDX license identifier is ill-formatted. "
|
||||
"Please see https://spdx.org for more information."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,4 +2,4 @@
|
||||
contract C {}
|
||||
// SPDX-License-Identifier: MIT
|
||||
// ----
|
||||
// ParserError 3716: Multiple SPDX license identifiers found in source file. Use "AND" or "OR" to combine multiple licenses. Please see https://spdx.org for more information.
|
||||
// Warning 1878: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||
contract C {}
|
||||
// ----
|
||||
// Warning 1878: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user