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
e3ae6faf
Commit
e3ae6faf
authored
3 years ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[analysis-scripts] build: improve handling of missing closing braces
parent
66cad154
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
share/analysis-scripts/function_finder.py
+12
-5
12 additions, 5 deletions
share/analysis-scripts/function_finder.py
with
12 additions
and
5 deletions
share/analysis-scripts/function_finder.py
+
12
−
5
View file @
e3ae6faf
...
...
@@ -112,6 +112,13 @@ def compute_closing_braces(file_lines):
# note: lines contain '\n', so they are never empty
if
line
[
0
]
==
'
}
'
:
braces
.
append
(
i
)
# Special heuristics: if the last line contains whitespace + '}',
# assume it closes a function.
last_line_number
=
len
(
file_lines
)
+
1
if
file_lines
!=
[]
and
not
(
last_line_number
in
braces
):
last_line
=
file_lines
[
-
1
].
lstrip
()
if
len
(
last_line
)
>=
1
and
last_line
[
0
]
==
'
}
'
:
braces
.
append
(
last_line_number
)
return
braces
# Returns the first element of [line_numbers] greater than [n], or [None]
...
...
@@ -120,11 +127,11 @@ def compute_closing_braces(file_lines):
#
# [line_numbers] must be sorted in ascending order.
def
get_first_line_after
(
line_numbers
,
n
):
#for line in line_numbers
:
#
if line > n:
# return line
#
assert Fals
e
return
line_numbers
[
bisect
.
bisect_left
(
line_numbers
,
n
)]
try
:
return
line_numbers
[
bisect
.
bisect_left
(
line_numbers
,
n
)]
except
IndexError
:
#
could not find line (e.g. for closing braces); return Non
e
return
None
# Returns a list of tuples (fname, is_def, line_start, line_end, terminator_offset)
# for each function definition or declaration.
...
...
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