diff --git a/test/cmdlineTests/storage_layout_specified_location/in.sol b/test/cmdlineTests/storage_layout_specified_location/in.sol new file mode 100644 index 000000000000..eafbfb041c2c --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location/in.sol @@ -0,0 +1,11 @@ +//SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.27; + +contract A layout at 42 { + uint x; + uint y; + int8 z; + bool b; + address addr; + uint[2] array; +} \ No newline at end of file diff --git a/test/cmdlineTests/storage_layout_specified_location/input.json b/test/cmdlineTests/storage_layout_specified_location/input.json new file mode 100644 index 000000000000..852203799f9d --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location/input.json @@ -0,0 +1,16 @@ +{ + "language": "Solidity", + "sources": { + "fileA": { + "urls": ["storage_layout_specified_location/in.sol"] + } + }, + "settings": { + "outputSelection": { + "fileA": { + "A": [ "storageLayout" ], + "": [ "storageLayout" ] + } + } + } +} diff --git a/test/cmdlineTests/storage_layout_specified_location/output.json b/test/cmdlineTests/storage_layout_specified_location/output.json new file mode 100644 index 000000000000..f036092a04b7 --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location/output.json @@ -0,0 +1,93 @@ +{ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ + { + "astId": 4, + "contract": "fileA:A", + "label": "x", + "offset": 0, + "slot": "42", + "type": "t_uint256" + }, + { + "astId": 6, + "contract": "fileA:A", + "label": "y", + "offset": 0, + "slot": "43", + "type": "t_uint256" + }, + { + "astId": 8, + "contract": "fileA:A", + "label": "z", + "offset": 0, + "slot": "44", + "type": "t_int8" + }, + { + "astId": 10, + "contract": "fileA:A", + "label": "b", + "offset": 1, + "slot": "44", + "type": "t_bool" + }, + { + "astId": 12, + "contract": "fileA:A", + "label": "addr", + "offset": 2, + "slot": "44", + "type": "t_address" + }, + { + "astId": 16, + "contract": "fileA:A", + "label": "array", + "offset": 0, + "slot": "45", + "type": "t_array(t_uint256)2_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)2_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[2]", + "numberOfBytes": "64" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_int8": { + "encoding": "inplace", + "label": "int8", + "numberOfBytes": "1" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } + } + } + }, + "sources": { + "fileA": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/storage_layout_specified_location_inheritance/in.sol b/test/cmdlineTests/storage_layout_specified_location_inheritance/in.sol new file mode 100644 index 000000000000..085ca5847def --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_inheritance/in.sol @@ -0,0 +1,14 @@ +//SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.27; + +contract A { + uint x; + uint y; + int8 z; +} + +contract C layout at 42 { + bool b; + address addr; + uint[2] array; +} \ No newline at end of file diff --git a/test/cmdlineTests/storage_layout_specified_location_inheritance/input.json b/test/cmdlineTests/storage_layout_specified_location_inheritance/input.json new file mode 100644 index 000000000000..ac99261de9ee --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_inheritance/input.json @@ -0,0 +1,16 @@ +{ + "language": "Solidity", + "sources": { + "fileA": { + "urls": ["storage_layout_specified_location_inheritance/in.sol"] + } + }, + "settings": { + "outputSelection": { + "fileA": { + "A": [ "storageLayout" ], + "": [ "storageLayout" ] + } + } + } +} diff --git a/test/cmdlineTests/storage_layout_specified_location_inheritance/output.json b/test/cmdlineTests/storage_layout_specified_location_inheritance/output.json new file mode 100644 index 000000000000..8a8afe749b0b --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_inheritance/output.json @@ -0,0 +1,53 @@ +{ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ + { + "astId": 3, + "contract": "fileA:A", + "label": "x", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 5, + "contract": "fileA:A", + "label": "y", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 7, + "contract": "fileA:A", + "label": "z", + "offset": 0, + "slot": "2", + "type": "t_int8" + } + ], + "types": { + "t_int8": { + "encoding": "inplace", + "label": "int8", + "numberOfBytes": "1" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } + } + } + }, + "sources": { + "fileA": { + "id": 0 + } + } +} diff --git a/test/cmdlineTests/storage_layout_specified_location_two_contracts/contractA.sol b/test/cmdlineTests/storage_layout_specified_location_two_contracts/contractA.sol new file mode 100644 index 000000000000..ca7d5c06cf09 --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_two_contracts/contractA.sol @@ -0,0 +1,6 @@ +contract A { + uint32 x; + int y; + bool b; + address a; +} \ No newline at end of file diff --git a/test/cmdlineTests/storage_layout_specified_location_two_contracts/contractB.sol b/test/cmdlineTests/storage_layout_specified_location_two_contracts/contractB.sol new file mode 100644 index 000000000000..07c30ea8be63 --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_two_contracts/contractB.sol @@ -0,0 +1,7 @@ +contract B { + bool b; + address a; + uint x; + int32 y; + int64 z; +} \ No newline at end of file diff --git a/test/cmdlineTests/storage_layout_specified_location_two_contracts/input.json b/test/cmdlineTests/storage_layout_specified_location_two_contracts/input.json new file mode 100644 index 000000000000..e9ebe177c9b0 --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_two_contracts/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": { + "fileA": { + "urls": ["storage_layout_specified_location_two_contracts/contractA.sol"] + }, + "fileB": { + "urls": ["storage_layout_specified_location_two_contracts/contractB.sol"] + } + }, + "settings": { + "outputSelection": { + "fileA": { + "A": [ "storageLayout" ], + "": [ "storageLayout" ] + } + } + } +} diff --git a/test/cmdlineTests/storage_layout_specified_location_two_contracts/output.json b/test/cmdlineTests/storage_layout_specified_location_two_contracts/output.json new file mode 100644 index 000000000000..b8f0274c11eb --- /dev/null +++ b/test/cmdlineTests/storage_layout_specified_location_two_contracts/output.json @@ -0,0 +1,124 @@ +{ + "contracts": { + "fileA": { + "A": { + "storageLayout": { + "storage": [ + { + "astId": 2, + "contract": "fileA:A", + "label": "x", + "offset": 0, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 4, + "contract": "fileA:A", + "label": "y", + "offset": 0, + "slot": "1", + "type": "t_int256" + }, + { + "astId": 6, + "contract": "fileA:A", + "label": "b", + "offset": 0, + "slot": "2", + "type": "t_bool" + }, + { + "astId": 8, + "contract": "fileA:A", + "label": "a", + "offset": 1, + "slot": "2", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_int256": { + "encoding": "inplace", + "label": "int256", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + } + } + } + } + } + }, + "errors": [ + { + "component": "general", + "errorCode": "1878", + "formattedMessage": "Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: \" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information. +--> fileA + +", + "message": "SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: \" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.", + "severity": "warning", + "sourceLocation": { + "end": -1, + "file": "fileA", + "start": -1 + }, + "type": "Warning" + }, + { + "component": "general", + "errorCode": "1878", + "formattedMessage": "Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: \" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information. +--> fileB + +", + "message": "SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: \" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.", + "severity": "warning", + "sourceLocation": { + "end": -1, + "file": "fileB", + "start": -1 + }, + "type": "Warning" + }, + { + "component": "general", + "errorCode": "3420", + "formattedMessage": "Warning: Source file does not specify required compiler version! +--> fileA + +", + "message": "Source file does not specify required compiler version!", + "severity": "warning", + "sourceLocation": { + "end": -1, + "file": "fileA", + "start": -1 + }, + "type": "Warning" + } + ], + "sources": { + "fileA": { + "id": 0 + }, + "fileB": { + "id": 1 + } + } +}