aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2019-01-07 21:37:07 +0800
committerGitHub <noreply@github.com>2019-01-07 21:37:07 +0800
commitff7bc85478126b02a713a46cd2eedb60edbb485b (patch)
treee45477e31470e5202ae18d1e48749be89fea089e
parentc00c0690e83097448db3250b6430043bed41839a (diff)
parent9e61dbad07c690c8f43528d193e1576a59f8558c (diff)
downloaddexon-solidity-ff7bc85478126b02a713a46cd2eedb60edbb485b.tar.gz
dexon-solidity-ff7bc85478126b02a713a46cd2eedb60edbb485b.tar.zst
dexon-solidity-ff7bc85478126b02a713a46cd2eedb60edbb485b.zip
Merge pull request #5741 from ethereum/fix-5730-SourceLocation
Fixes SourceLocation extraction on multiline locations with a too long first line
-rw-r--r--liblangutil/SourceReferenceExtractor.cpp4
-rw-r--r--test/cmdlineTests/too_long_line_multiline.sol13
-rw-r--r--test/cmdlineTests/too_long_line_multiline.sol.err6
-rw-r--r--test/cmdlineTests/too_long_line_multiline.sol.exit1
4 files changed, 23 insertions, 1 deletions
diff --git a/liblangutil/SourceReferenceExtractor.cpp b/liblangutil/SourceReferenceExtractor.cpp
index 4502bb23..1a6dbdb3 100644
--- a/liblangutil/SourceReferenceExtractor.cpp
+++ b/liblangutil/SourceReferenceExtractor.cpp
@@ -58,7 +58,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio
int locationLength = isMultiline ? line.length() - start.column : end.column - start.column;
if (locationLength > 150)
{
- line = line.substr(0, start.column + 35) + " ... " + line.substr(end.column - 35);
+ int const lhs = start.column + 35;
+ int const rhs = (isMultiline ? line.length() : end.column) - 35;
+ line = line.substr(0, lhs) + " ... " + line.substr(rhs);
end.column = start.column + 75;
locationLength = 75;
}
diff --git a/test/cmdlineTests/too_long_line_multiline.sol b/test/cmdlineTests/too_long_line_multiline.sol
new file mode 100644
index 00000000..6609e125
--- /dev/null
+++ b/test/cmdlineTests/too_long_line_multiline.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() returns (byte _b, bytes2 _b2, bytes3 _b3, bytes memory _blit, bytes5 _b5, bytes6 _b6, string memory _str, bytes7 _b7, bytes22 _b22, bytes32 _b32) {
+ _b = 0x12;
+ _b2 = 0x1223;
+ _b5 = hex"043245";
+ _b6 = hex"2345532532";
+ _b7 = hex"03252353253253";
+ _b22 = hex"325235235325325325235325";
+ _b32 = hex"032523532532523532523532523532";
+ _blit = hex"123498";
+ _str = "heidy";
+ }
+}
diff --git a/test/cmdlineTests/too_long_line_multiline.sol.err b/test/cmdlineTests/too_long_line_multiline.sol.err
new file mode 100644
index 00000000..d7412ffe
--- /dev/null
+++ b/test/cmdlineTests/too_long_line_multiline.sol.err
@@ -0,0 +1,6 @@
+too_long_line_multiline.sol:2:5: Error: No visibility specified. Did you intend to add "public"?
+ function f() returns (byte _b, byte ... _b7, bytes22 _b22, bytes32 _b32) {
+ ^ (Relevant source part starts here and spans across multiple lines).
+too_long_line_multiline.sol:1:1: Warning: Source file does not specify required compiler version!
+contract C {
+^ (Relevant source part starts here and spans across multiple lines).
diff --git a/test/cmdlineTests/too_long_line_multiline.sol.exit b/test/cmdlineTests/too_long_line_multiline.sol.exit
new file mode 100644
index 00000000..d00491fd
--- /dev/null
+++ b/test/cmdlineTests/too_long_line_multiline.sol.exit
@@ -0,0 +1 @@
+1