Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
78218d98
Commit
78218d98
authored
4 years ago
by
Virgile Prevosto
Browse files
Options
Downloads
Patches
Plain Diff
[logic] ensure gcc-10 will not play with utf8 chars when preprocessing
Make MdR tests more robust against choice of pre-processor
parent
948d3da8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/kernel_internals/parsing/logic_preprocess.mll
+28
-1
28 additions, 1 deletion
src/kernel_internals/parsing/logic_preprocess.mll
src/plugins/markdown-report/tests/sarif/oracle/with-libc.sarif
+51
-51
51 additions, 51 deletions
...lugins/markdown-report/tests/sarif/oracle/with-libc.sarif
with
79 additions
and
52 deletions
src/kernel_internals/parsing/logic_preprocess.mll
+
28
−
1
View file @
78218d98
...
...
@@ -62,9 +62,30 @@
let
backslash
=
"__ANNOT_BACKSLASH__"
let
annot_content
=
"__ANNOT_CONTENT__"
let
utf8_prefix
=
"__FC_UTF8_"
let
encode_utf8
c
=
utf8_prefix
^
(
string_of_int
(
Char
.
code
c
))
let
re_backslash
=
Str
.
regexp_string
backslash
let
re_annot_content
=
Str
.
regexp_string
annot_content
let
re_utf8
=
Str
.
regexp
(
utf8_prefix
^
"
\\
([0-9]+
\\
)"
)
let
decode_utf8
s
=
let
res
=
ref
s
in
let
start
=
ref
0
in
try
while
true
do
let
b
=
Str
.
search_forward
re_utf8
!
res
!
start
in
let
e
=
Str
.
match_end
()
in
let
chr
=
Char
.
chr
(
int_of_string
(
Str
.
matched_group
1
!
res
))
in
let
buf
=
Bytes
.
of_string
!
res
in
Bytes
.
set
buf
b
chr
;
Bytes
.
blit
buf
e
buf
(
b
+
1
)
(
String
.
length
!
res
-
e
);
res
:=
Bytes
.
sub_string
buf
0
(
String
.
length
!
res
+
1
+
b
-
e
);
start
:=
b
+
1
;
done
;
assert
false
;
with
Not_found
->
!
res
(* Delimiters for the various annotations in the preprocessing buffer.
We have one delimiter for the beginning of an annotation (to discard
...
...
@@ -115,7 +136,7 @@
ignore_content
()
;
ignore
(
input_line
file
);
(* ignore the #line directive *)
let
with_nl
,
content
=
get_annot
true
in
with_nl
,
replace_backslash
content
with_nl
,
decode_utf8
@@
replace_backslash
content
with
End_of_file
->
Kernel
.
fatal
"too few annotations in result file while pre-processing annotations"
...
...
@@ -184,6 +205,8 @@
add_preprocess_line_info
()
}
let
utf8
=
[
'\128'
-
'\255'
]
rule
main
=
parse
|
(
"#define"
|
"#undef"
)
[
'
'
'\t'
]
*
(([
'
a'
-
'
z''A'
-
'
Z''0'
-
'
9
''
_'
])
*
as
m
)
{
...
...
@@ -388,6 +411,10 @@ and annot = parse
is_newline
:=
CHAR
;
Buffer
.
add_char
preprocess_buffer
'
"';
string annot lexbuf }
| utf8 as c {
Buffer.add_string preprocess_buffer (encode_utf8 c);
annot lexbuf
}
| _ as c { is_newline := CHAR;
Buffer.add_char preprocess_buffer c;
annot lexbuf }
...
...
This diff is collapsed.
Click to expand it.
src/plugins/markdown-report/tests/sarif/oracle/with-libc.sarif
+
51
−
51
View file @
78218d98
...
...
@@ -516,8 +516,8 @@
"startLine": 168,
"startColumn": 4,
"endLine": 170,
"endColumn":
82
,
"byteLength": 1
46
"endColumn":
75
,
"byteLength": 1
32
}
}
}
...
...
@@ -587,8 +587,8 @@
"startLine": 240,
"startColumn": 4,
"endLine": 244,
"endColumn":
70
,
"byteLength": 1
80
"endColumn":
63
,
"byteLength": 1
73
}
}
}
...
...
@@ -1151,7 +1151,7 @@
"startColumn": 4,
"endLine": 121,
"endColumn": 77,
"byteLength": 1
55
"byteLength": 1
48
}
}
}
...
...
@@ -1266,7 +1266,7 @@
"startColumn": 4,
"endLine": 125,
"endColumn": 77,
"byteLength": 1
56
"byteLength": 1
49
}
}
}
...
...
@@ -1455,7 +1455,7 @@
"startColumn": 4,
"endLine": 109,
"endColumn": 59,
"byteLength": 1
25
"byteLength": 1
18
}
}
}
...
...
@@ -1992,8 +1992,8 @@
"startLine": 89,
"startColumn": 4,
"endLine": 90,
"endColumn": 7
9
,
"byteLength": 10
8
"endColumn": 7
2
,
"byteLength": 10
1
}
}
}
...
...
@@ -2202,8 +2202,8 @@
"startLine": 143,
"startColumn": 4,
"endLine": 147,
"endColumn":
70
,
"byteLength": 17
7
"endColumn":
63
,
"byteLength": 17
0
}
}
}
...
...
@@ -2439,7 +2439,7 @@
"startColumn": 4,
"endLine": 59,
"endColumn": 62,
"byteLength": 14
8
"byteLength": 1
3
4
}
}
}
...
...
@@ -2788,7 +2788,7 @@
"startColumn": 4,
"endLine": 185,
"endColumn": 63,
"byteLength": 1
50
"byteLength": 1
43
}
}
}
...
...
@@ -3563,7 +3563,7 @@
"startColumn": 4,
"endLine": 202,
"endColumn": 22,
"byteLength": 1
20
"byteLength": 1
13
}
}
}
...
...
@@ -3655,7 +3655,7 @@
"startColumn": 4,
"endLine": 269,
"endColumn": 29,
"byteLength": 1
67
"byteLength": 1
53
}
}
}
...
...
@@ -3958,7 +3958,7 @@
"startColumn": 4,
"endLine": 97,
"endColumn": 58,
"byteLength": 12
7
"byteLength": 12
0
}
}
}
...
...
@@ -4431,7 +4431,7 @@
"startColumn": 4,
"endLine": 59,
"endColumn": 62,
"byteLength": 14
8
"byteLength": 1
3
4
}
}
}
...
...
@@ -4826,7 +4826,7 @@
"startColumn": 4,
"endLine": 105,
"endColumn": 51,
"byteLength": 1
15
"byteLength": 1
08
}
}
}
...
...
@@ -4849,7 +4849,7 @@
"startColumn": 4,
"endLine": 135,
"endColumn": 38,
"byteLength": 1
92
"byteLength": 1
85
}
}
}
...
...
@@ -5078,8 +5078,8 @@
"startLine": 68,
"startColumn": 4,
"endLine": 70,
"endColumn":
70
,
"byteLength": 15
6
"endColumn":
63
,
"byteLength": 1
3
5
}
}
}
...
...
@@ -5269,8 +5269,8 @@
"startLine": 252,
"startColumn": 4,
"endLine": 256,
"endColumn":
60
,
"byteLength":
208
"endColumn":
53
,
"byteLength":
194
}
}
}
...
...
@@ -5364,7 +5364,7 @@
"startColumn": 4,
"endLine": 269,
"endColumn": 29,
"byteLength": 1
67
"byteLength": 1
53
}
}
}
...
...
@@ -5573,7 +5573,7 @@
"startColumn": 4,
"endLine": 101,
"endColumn": 59,
"byteLength": 1
24
"byteLength": 1
17
}
}
}
...
...
@@ -5739,7 +5739,7 @@
"startColumn": 4,
"endLine": 113,
"endColumn": 51,
"byteLength": 11
8
"byteLength": 11
1
}
}
}
...
...
@@ -5948,7 +5948,7 @@
"startColumn": 4,
"endLine": 117,
"endColumn": 62,
"byteLength": 1
57
"byteLength": 1
43
}
}
}
...
...
@@ -6636,7 +6636,7 @@
"startColumn": 4,
"endLine": 130,
"endColumn": 38,
"byteLength": 1
91
"byteLength": 1
84
}
}
}
...
...
@@ -6731,8 +6731,8 @@
"startLine": 39,
"startColumn": 4,
"endLine": 42,
"endColumn": 7
7
,
"byteLength": 1
84
"endColumn": 7
0
,
"byteLength": 1
70
}
}
}
...
...
@@ -6800,8 +6800,8 @@
"startLine": 155,
"startColumn": 4,
"endLine": 159,
"endColumn":
60
,
"byteLength":
205
"endColumn":
53
,
"byteLength":
191
}
}
}
...
...
@@ -7177,8 +7177,8 @@
"startLine": 143,
"startColumn": 4,
"endLine": 147,
"endColumn":
70
,
"byteLength": 17
7
"endColumn":
63
,
"byteLength": 17
0
}
}
}
...
...
@@ -7246,8 +7246,8 @@
"startLine": 240,
"startColumn": 4,
"endLine": 244,
"endColumn":
70
,
"byteLength": 1
80
"endColumn":
63
,
"byteLength": 1
73
}
}
}
...
...
@@ -7362,7 +7362,7 @@
"startColumn": 4,
"endLine": 82,
"endColumn": 40,
"byteLength": 1
83
"byteLength": 1
69
}
}
}
...
...
@@ -7500,7 +7500,7 @@
"startColumn": 4,
"endLine": 135,
"endColumn": 38,
"byteLength": 1
92
"byteLength": 1
85
}
}
}
...
...
@@ -7592,7 +7592,7 @@
"startColumn": 4,
"endLine": 197,
"endColumn": 41,
"byteLength": 1
88
"byteLength": 1
74
}
}
}
...
...
@@ -7614,8 +7614,8 @@
"startLine": 155,
"startColumn": 4,
"endLine": 159,
"endColumn":
60
,
"byteLength":
205
"endColumn":
53
,
"byteLength":
191
}
}
}
...
...
@@ -8124,8 +8124,8 @@
"startLine": 252,
"startColumn": 4,
"endLine": 256,
"endColumn":
60
,
"byteLength":
208
"endColumn":
53
,
"byteLength":
194
}
}
}
...
...
@@ -8267,7 +8267,7 @@
"startColumn": 4,
"endLine": 185,
"endColumn": 63,
"byteLength": 1
50
"byteLength": 1
43
}
}
}
...
...
@@ -8595,8 +8595,8 @@
"startLine": 39,
"startColumn": 4,
"endLine": 42,
"endColumn": 7
7
,
"byteLength": 1
84
"endColumn": 7
0
,
"byteLength": 1
70
}
}
}
...
...
@@ -8738,7 +8738,7 @@
"startColumn": 4,
"endLine": 87,
"endColumn": 22,
"byteLength": 1
16
"byteLength": 1
09
}
}
}
...
...
@@ -8829,8 +8829,8 @@
"startLine": 68,
"startColumn": 4,
"endLine": 70,
"endColumn":
70
,
"byteLength": 15
6
"endColumn":
63
,
"byteLength": 1
3
5
}
}
}
...
...
@@ -9538,8 +9538,8 @@
"startLine": 168,
"startColumn": 4,
"endLine": 170,
"endColumn":
82
,
"byteLength": 1
46
"endColumn":
75
,
"byteLength": 1
32
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment