adlint 1.8.2 → 1.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +192 -0
- data/MANIFEST +1 -0
- data/NEWS +40 -4
- data/etc/mesg.d/en_US/messages.yml +1 -1
- data/etc/mesg.d/ja_JP/messages.yml +1 -1
- data/lib/adlint/c/code.rb +88 -124
- data/lib/adlint/c/conv.rb +4 -4
- data/lib/adlint/c/ctrlexpr.rb +8 -2
- data/lib/adlint/c/domain.rb +405 -5
- data/lib/adlint/c/format.rb +6 -6
- data/lib/adlint/c/message.rb +227 -350
- data/lib/adlint/c/message_shima.rb +1 -2
- data/lib/adlint/c/object.rb +1 -1
- data/lib/adlint/c/type.rb +43 -1
- data/lib/adlint/cpp/util.rb +29 -0
- data/lib/adlint/version.rb +2 -2
- data/share/demo/Makefile +1 -0
- data/share/demo/integer_promotion/integer_promotion.c +17 -0
- data/share/doc/developers_guide_ja.html +3 -3
- data/share/doc/developers_guide_ja.texi +1 -1
- data/share/doc/users_guide_en.html +3 -3
- data/share/doc/users_guide_en.texi +1 -1
- data/share/doc/users_guide_ja.html +3 -3
- data/share/doc/users_guide_ja.texi +1 -1
- metadata +3 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,195 @@
|
|
1
|
+
Fri May 18 22:04:23 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
2
|
+
|
3
|
+
* release.ga : 1.8.10
|
4
|
+
- Fix bad narrowing logic of undefined value domain in order to
|
5
|
+
detect W9001 correctly.
|
6
|
+
- Fix W0635 detection not to warn when the expected type of the
|
7
|
+
conversion specifier is a pointer type and the corresponding
|
8
|
+
argument's type is a pointer type whose base type is cv-qualified.
|
9
|
+
- Fix W0583 detection not to warn when the argument type is a
|
10
|
+
cv-qualified one of the corresponding parameter's type.
|
11
|
+
- Fix W0112 detection not to warn about floating point
|
12
|
+
relational-expressions.
|
13
|
+
- Fix W0117 and W0118 detection not to misunderstand linkage of
|
14
|
+
object definitions.
|
15
|
+
- Fix W0101, W0102, W0103 and W0107 detections not to warn when an
|
16
|
+
address of the parameter array variable (an alias of the caller's
|
17
|
+
array) is going to be saved.
|
18
|
+
- Fix W0828 detection not to warn when the member variable is a type
|
19
|
+
of char array and the corresponding initializer is a
|
20
|
+
string-literal-specifier.
|
21
|
+
- Fix W0635 detection not to warn when the `void *' argument passed
|
22
|
+
as the `%p' conversion specifier.
|
23
|
+
- Fix degraded W0118 detection not to warn when the object
|
24
|
+
declaration is in the header file and the same declaration is in
|
25
|
+
the source file, too.
|
26
|
+
- Fix bad value domain multiplication logic in order to correctly
|
27
|
+
detect W0723 about multiplicative-expressions.
|
28
|
+
- Fix W0771 detection not to warn when declarations of the same
|
29
|
+
object are in a source file.
|
30
|
+
- Fix W0080 detection to warn when the file local static variable is
|
31
|
+
defined without initializer.
|
32
|
+
- Fix bad value domain multiplication logic in order to correctly
|
33
|
+
detect W0608 about multiplicative-expressions.
|
34
|
+
- Fix degraded W0771 detection not to warn when declarations of the
|
35
|
+
same object are in two or more files.
|
36
|
+
- Fix degraded W0118 detection to warn when all declarations of an
|
37
|
+
object are in the source file.
|
38
|
+
|
39
|
+
Fri May 18 21:38:59 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
40
|
+
|
41
|
+
* release.rc : 1.8.9
|
42
|
+
- Fix degraded W0771 detection not to warn when declarations of the
|
43
|
+
same object are in two or more files.
|
44
|
+
- Fix degraded W0118 detection to warn when all declarations of an
|
45
|
+
object are in the source file.
|
46
|
+
|
47
|
+
Fri May 18 21:21:29 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
48
|
+
|
49
|
+
* lib/adlint/c/message.rb : Fix degraded W0118 detection to warn when
|
50
|
+
all declarations of an object are in the source file.
|
51
|
+
|
52
|
+
Fri May 18 21:12:15 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
53
|
+
|
54
|
+
* lib/adlint/c/message.rb : Fix degraded W0771 detection not to warn
|
55
|
+
when declarations of the same object are in two or more files.
|
56
|
+
|
57
|
+
Fri May 18 20:46:33 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
58
|
+
|
59
|
+
* release.rc : 1.8.7
|
60
|
+
- Fix bad value domain multiplication logic in order to correctly
|
61
|
+
detect W0608 about multiplicative-expressions.
|
62
|
+
|
63
|
+
Fri May 18 20:38:30 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
64
|
+
|
65
|
+
* lib/adlint/c/domain.rb : Fix bad value domain multiplication logic in
|
66
|
+
order to correctly detect W0608 about multiplicative-expressions.
|
67
|
+
|
68
|
+
Fri May 18 19:50:35 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
69
|
+
|
70
|
+
* release.rc : 1.8.5
|
71
|
+
- Fix W0828 detection not to warn when the member variable is a type
|
72
|
+
of char array and the corresponding initializer is a
|
73
|
+
string-literal-specifier.
|
74
|
+
- Fix W0635 detection not to warn when the `void *' argument passed
|
75
|
+
as the `%p' conversion specifier.
|
76
|
+
- Fix degraded W0118 detection not to warn when the object
|
77
|
+
declaration is in the header file and the same declaration is in
|
78
|
+
the source file, too.
|
79
|
+
- Fix bad value domain multiplication logic in order to correctly
|
80
|
+
detect W0723 about multiplicative-expressions.
|
81
|
+
- Fix W0771 detection not to warn when declarations of the same
|
82
|
+
object are in a source file.
|
83
|
+
- Fix W0080 detection to warn when the file local static variable is
|
84
|
+
defined without initializer.
|
85
|
+
|
86
|
+
Fri May 18 19:10:56 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
87
|
+
|
88
|
+
* lib/adlint/c/message.rb : Fix W0080 detection to warn when the file
|
89
|
+
local static variable is defined without initializer.
|
90
|
+
|
91
|
+
Fri May 18 18:42:02 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
92
|
+
|
93
|
+
* lib/adlint/c/message.rb : Fix W0771 detection not to warn when
|
94
|
+
declarations of the same object are in a source file.
|
95
|
+
|
96
|
+
Fri May 18 18:25:04 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
97
|
+
|
98
|
+
* lib/adlint/c/domain.rb : Fix bad value domain multiplication logic in
|
99
|
+
order to correctly detect W0723 about multiplicative-expressions.
|
100
|
+
|
101
|
+
Fri May 18 15:58:57 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
102
|
+
|
103
|
+
* lib/adlint/c/message.rb : Fix degraded W0118 detection not to warn
|
104
|
+
when the object declaration is in the header file and the same
|
105
|
+
declaration is in the source file, too.
|
106
|
+
|
107
|
+
Fri May 18 15:30:29 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
108
|
+
|
109
|
+
* lib/adlint/c/type.rb : Fix and refactor bad type similarity check not
|
110
|
+
to misunderstand that the `void *' is not same as `void *'.
|
111
|
+
|
112
|
+
Fri May 18 13:22:41 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
113
|
+
|
114
|
+
* lib/adlint/c/message.rb : Fix W0828 detection not to warn when the
|
115
|
+
member variable is a type of char array and the corresponding
|
116
|
+
initializer is a string-literal-specifier.
|
117
|
+
|
118
|
+
Thu May 17 18:32:49 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
119
|
+
|
120
|
+
* release.rc : 1.8.3
|
121
|
+
- This is RC for the 2nd patch release of the 1.8 series.
|
122
|
+
- Fix bad narrowing logic of undefined value domain in order to
|
123
|
+
detect W9001 correctly.
|
124
|
+
- Fix W0635 detection not to warn when the expected type of the
|
125
|
+
conversion specifier is a pointer type and the corresponding
|
126
|
+
argument's type is a pointer type whose base type is cv-qualified.
|
127
|
+
- Fix W0583 detection not to warn when the argument type is a
|
128
|
+
cv-qualified one of the corresponding parameter's type.
|
129
|
+
- Fix W0112 detection not to warn about floating point
|
130
|
+
relational-expressions.
|
131
|
+
- Fix W0117 and W0118 detection not to misunderstand linkage of
|
132
|
+
object definitions.
|
133
|
+
- Fix W0101, W0102, W0103 and W0107 detections not to warn when an
|
134
|
+
address of the parameter array variable (an alias of the caller's
|
135
|
+
array) is going to be saved.
|
136
|
+
|
137
|
+
Thu May 17 16:08:47 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
138
|
+
|
139
|
+
* lib/adlint/c/type.rb : Add query interface tells whether the
|
140
|
+
receiver type is a type of function parameters or not.
|
141
|
+
|
142
|
+
* lib/adlint/c/message.rb : Fix W0101, W0102, W0103 and W0107
|
143
|
+
detections not to warn when an address of the parameter array
|
144
|
+
variable (an alias of the caller's array) is going to be saved.
|
145
|
+
|
146
|
+
Thu May 17 15:24:49 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
147
|
+
|
148
|
+
* lib/adlint/c/message.rb : Fix scattered object linkage determination
|
149
|
+
logic to use new Object#declared_as_*? method.
|
150
|
+
* lib/adlint/c/code.rb : Ditto.
|
151
|
+
|
152
|
+
Wed May 16 11:57:18 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
153
|
+
|
154
|
+
* lib/adlint/c/object.rb : Fix bad linkage determination of variables
|
155
|
+
in order not to misunderstand that function local variables have
|
156
|
+
external linkages.
|
157
|
+
|
158
|
+
* lib/adlint/c/message.rb : Fix W0117 and W0118 detection not to
|
159
|
+
misunderstand linkage of object definitions.
|
160
|
+
|
161
|
+
Wed May 16 11:33:03 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
162
|
+
|
163
|
+
* lib/adlint/c/ctrlexpr.rb : Fix bad expression evaluation
|
164
|
+
notification not to notify that an equality-expression evaluated
|
165
|
+
when a relational-expression is evaluated.
|
166
|
+
|
167
|
+
Wed May 16 10:53:56 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
168
|
+
|
169
|
+
* lib/adlint/c/type.rb : Fix bad type similarity check not to
|
170
|
+
misunderstand that the pointer or array of non cv-qualified type is
|
171
|
+
not similar to the pointer or array of cv-qualified type.
|
172
|
+
|
173
|
+
Wed May 16 02:25:04 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
174
|
+
|
175
|
+
* share/demo/Makefile : Add `integer_promotion' demo.
|
176
|
+
* share/demo/integer_promotion/integer_promotion.c : Ditto.
|
177
|
+
* MANIFEST : Ditto.
|
178
|
+
|
179
|
+
Tue May 15 18:05:48 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
180
|
+
|
181
|
+
* lib/adlint/c/domain.rb : Fix bad value domain multiplication logic in
|
182
|
+
order not to result NaN when the rhs domain contains 0.
|
183
|
+
|
184
|
+
Tue May 15 15:19:31 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
185
|
+
|
186
|
+
* lib/adlint/c/domain.rb : Fix bad narrowing logic of undefined value
|
187
|
+
domain in order not to mishandle controlling expressions of
|
188
|
+
uninitialized variables.
|
189
|
+
|
190
|
+
* lib/adlint/c/ctrlexpr.rb : Remove redundant ValueDomainManipulator
|
191
|
+
registration.
|
192
|
+
|
1
193
|
Mon May 7 22:56:02 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
2
194
|
|
3
195
|
* release.ga : 1.8.2
|
data/MANIFEST
CHANGED
@@ -148,6 +148,7 @@ share/demo/indirect_recur/indirect_recur_3.c
|
|
148
148
|
share/demo/indirect_recur/indirect_recur_3.h
|
149
149
|
share/demo/indirect_recur/indirect_recur_4.c
|
150
150
|
share/demo/inline_asm/inline_asm.c
|
151
|
+
share/demo/integer_promotion/integer_promotion.c
|
151
152
|
share/demo/intro_demo/intro_demo.c
|
152
153
|
share/demo/intro_demo/intro_demo.h
|
153
154
|
share/demo/intro_demo/useless_header.h
|
data/NEWS
CHANGED
@@ -21,6 +21,46 @@
|
|
21
21
|
|
22
22
|
++
|
23
23
|
|
24
|
+
=== \AdLint 1.8.10 is released (2012-05-18)
|
25
|
+
|
26
|
+
==== Changes since the 1.8.2 release
|
27
|
+
|
28
|
+
* Fix bad narrowing logic of undefined value domain in order to detect W9001
|
29
|
+
correctly
|
30
|
+
* Fix W0635 detection not to warn when the expected type of the conversion
|
31
|
+
specifier is a pointer type and the corresponding argument's type is a
|
32
|
+
pointer type whose base type is cv-qualified
|
33
|
+
* Fix W0583 detection not to warn when the argument type is a cv-qualified one
|
34
|
+
of the corresponding parameter's type
|
35
|
+
* Fix W0112 detection not to warn about floating point relational-expressions.
|
36
|
+
* Fix W0117 and W0118 detection not to misunderstand linkage of object
|
37
|
+
definitions
|
38
|
+
* Fix W0101, W0102, W0103 and W0107 detections not to warn when an address of
|
39
|
+
the parameter array variable (an alias of the caller's array) is going to be
|
40
|
+
saved
|
41
|
+
* Fix W0828 detection not to warn when the member variable is a type of char
|
42
|
+
array and the corresponding initializer is a string-literal-specifier
|
43
|
+
* Fix W0635 detection not to warn when the `void *' argument passed as the `%p'
|
44
|
+
conversion specifier
|
45
|
+
* Fix degraded W0118 detection not to warn when the object declaration is in
|
46
|
+
the header file and the same declaration is in the source file, too
|
47
|
+
* Fix bad value domain multiplication logic in order to correctly detect W0723
|
48
|
+
about multiplicative-expressions
|
49
|
+
* Fix W0771 detection not to warn when declarations of the same object are in a
|
50
|
+
source file
|
51
|
+
* Fix W0080 detection to warn when the file local static variable is defined
|
52
|
+
without initializer
|
53
|
+
* Fix bad value domain multiplication logic in order to correctly detect W0608
|
54
|
+
about multiplicative-expressions
|
55
|
+
* Fix degraded W0771 detection not to warn when declarations of the same object
|
56
|
+
are in two or more files
|
57
|
+
* Fix degraded W0118 detection to warn when all declarations of an object are
|
58
|
+
in the source file
|
59
|
+
|
60
|
+
See the file
|
61
|
+
{ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
|
62
|
+
for more details.
|
63
|
+
|
24
64
|
=== \AdLint 1.8.2 is released (2012-05-08)
|
25
65
|
|
26
66
|
==== Changes since the 1.8.0 release
|
@@ -29,10 +69,6 @@
|
|
29
69
|
object into a pointer in order to resolve a type of the nested
|
30
70
|
array-subscript-expression correctly
|
31
71
|
|
32
|
-
See the file
|
33
|
-
{ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
|
34
|
-
for more details.
|
35
|
-
|
36
72
|
=== \AdLint 1.8.0 is released (2012-04-27)
|
37
73
|
|
38
74
|
==== Changes since the 1.6.0 release
|
data/lib/adlint/c/code.rb
CHANGED
@@ -76,17 +76,16 @@ module C #:nodoc:
|
|
76
76
|
class GVarDeclExtraction < CodeExtraction
|
77
77
|
def initialize(context)
|
78
78
|
super
|
79
|
-
|
80
|
-
|
79
|
+
interp = context[:c_interpreter]
|
80
|
+
interp.on_variable_declared += method(:extract)
|
81
81
|
end
|
82
82
|
|
83
83
|
private
|
84
84
|
def do_prepare(context) end
|
85
85
|
def do_execute(context) end
|
86
86
|
|
87
|
-
def extract(variable_declaration)
|
88
|
-
if
|
89
|
-
variable_declaration.storage_class_specifier.type == :EXTERN
|
87
|
+
def extract(variable_declaration, variable)
|
88
|
+
if variable.declared_as_extern?
|
90
89
|
GVARDCL(variable_declaration.identifier.location,
|
91
90
|
variable_declaration.identifier.value,
|
92
91
|
variable_declaration.type.brief_image)
|
@@ -97,10 +96,10 @@ module C #:nodoc:
|
|
97
96
|
class FuncDeclExtraction < CodeExtraction
|
98
97
|
def initialize(context)
|
99
98
|
super
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
interp = context[:c_interpreter]
|
100
|
+
interp.on_function_declared += method(:extract)
|
101
|
+
interp.on_block_started += method(:enter_block)
|
102
|
+
interp.on_block_ended += method(:leave_block)
|
104
103
|
@block_level = 0
|
105
104
|
end
|
106
105
|
|
@@ -108,33 +107,25 @@ module C #:nodoc:
|
|
108
107
|
def do_prepare(context) end
|
109
108
|
def do_execute(context) end
|
110
109
|
|
111
|
-
def extract(function_declaration)
|
112
|
-
if
|
113
|
-
case function_declaration.storage_class_specifier.type
|
114
|
-
when :EXTERN
|
115
|
-
FUNCDCL(function_declaration.identifier.location, "X",
|
116
|
-
@block_level == 0 ? "F" : "B",
|
117
|
-
FunctionIdentifier.new(function_declaration.identifier.value,
|
118
|
-
function_declaration.signature.to_s))
|
119
|
-
when :STATIC
|
120
|
-
FUNCDCL(function_declaration.identifier.location, "I",
|
121
|
-
@block_level == 0 ? "F" : "B",
|
122
|
-
FunctionIdentifier.new(function_declaration.identifier.value,
|
123
|
-
function_declaration.signature.to_s))
|
124
|
-
end
|
125
|
-
else
|
110
|
+
def extract(function_declaration, function)
|
111
|
+
if function.declared_as_extern?
|
126
112
|
FUNCDCL(function_declaration.identifier.location, "X",
|
127
113
|
@block_level == 0 ? "F" : "B",
|
128
114
|
FunctionIdentifier.new(function_declaration.identifier.value,
|
129
115
|
function_declaration.signature.to_s))
|
116
|
+
else
|
117
|
+
FUNCDCL(function_declaration.identifier.location, "I",
|
118
|
+
@block_level == 0 ? "F" : "B",
|
119
|
+
FunctionIdentifier.new(function_declaration.identifier.value,
|
120
|
+
function_declaration.signature.to_s))
|
130
121
|
end
|
131
122
|
end
|
132
123
|
|
133
|
-
def
|
124
|
+
def enter_block(*)
|
134
125
|
@block_level += 1
|
135
126
|
end
|
136
127
|
|
137
|
-
def
|
128
|
+
def leave_block(*)
|
138
129
|
@block_level -= 1
|
139
130
|
end
|
140
131
|
end
|
@@ -142,11 +133,11 @@ module C #:nodoc:
|
|
142
133
|
class VarDefExtraction < CodeExtraction
|
143
134
|
def initialize(context)
|
144
135
|
super
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
136
|
+
interp = context[:c_interpreter]
|
137
|
+
interp.on_variable_defined += method(:extract_variable)
|
138
|
+
interp.on_parameter_defined += method(:extract_parameter)
|
139
|
+
interp.on_block_started += method(:enter_block)
|
140
|
+
interp.on_block_ended += method(:leave_block)
|
150
141
|
@block_level = 0
|
151
142
|
end
|
152
143
|
|
@@ -154,90 +145,77 @@ module C #:nodoc:
|
|
154
145
|
def do_prepare(context) end
|
155
146
|
def do_execute(context) end
|
156
147
|
|
157
|
-
def extract_variable(variable_definition)
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
VARDEF(variable_definition.identifier.location, "X",
|
184
|
-
@block_level == 0 ? "F" : "B",
|
185
|
-
storage_class_type(
|
186
|
-
variable_definition.storage_class_specifier),
|
187
|
-
variable_definition.identifier.value,
|
188
|
-
variable_definition.type.brief_image)
|
189
|
-
else
|
190
|
-
VARDEF(variable_definition.identifier.location, "I", "B",
|
191
|
-
storage_class_type(
|
192
|
-
variable_definition.storage_class_specifier),
|
193
|
-
variable_definition.identifier.value,
|
194
|
-
variable_definition.type.brief_image)
|
195
|
-
end
|
148
|
+
def extract_variable(variable_definition, variable)
|
149
|
+
case
|
150
|
+
when variable.declared_as_extern?
|
151
|
+
VARDEF(variable_definition.identifier.location, "X",
|
152
|
+
@block_level == 0 ? "F" : "B",
|
153
|
+
storage_class_type(variable_definition.storage_class_specifier),
|
154
|
+
variable_definition.identifier.value,
|
155
|
+
variable_definition.type.brief_image)
|
156
|
+
when variable.declared_as_static?
|
157
|
+
VARDEF(variable_definition.identifier.location, "I",
|
158
|
+
@block_level == 0 ? "F" : "B",
|
159
|
+
storage_class_type(variable_definition.storage_class_specifier),
|
160
|
+
variable_definition.identifier.value,
|
161
|
+
variable_definition.type.brief_image)
|
162
|
+
when variable.declared_as_auto?
|
163
|
+
VARDEF(variable_definition.identifier.location, "I",
|
164
|
+
@block_level == 0 ? "F" : "B",
|
165
|
+
storage_class_type(variable_definition.storage_class_specifier),
|
166
|
+
variable_definition.identifier.value,
|
167
|
+
variable_definition.type.brief_image)
|
168
|
+
when variable.declared_as_register?
|
169
|
+
VARDEF(variable_definition.identifier.location, "I",
|
170
|
+
@block_level == 0 ? "F" : "B",
|
171
|
+
storage_class_type(variable_definition.storage_class_specifier),
|
172
|
+
variable_definition.identifier.value,
|
173
|
+
variable_definition.type.brief_image)
|
196
174
|
end
|
197
175
|
end
|
198
176
|
|
199
|
-
def extract_parameter(parameter_definition)
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
177
|
+
def extract_parameter(parameter_definition, variable)
|
178
|
+
return unless variable.named?
|
179
|
+
|
180
|
+
VARDEF(parameter_definition.identifier.location, "I", "P",
|
181
|
+
storage_class_type(parameter_definition.storage_class_specifier),
|
182
|
+
parameter_definition.identifier.value,
|
183
|
+
parameter_definition.type.brief_image)
|
207
184
|
end
|
208
185
|
|
209
|
-
def
|
186
|
+
def enter_block(*)
|
210
187
|
@block_level += 1
|
211
188
|
end
|
212
189
|
|
213
|
-
def
|
190
|
+
def leave_block(*)
|
214
191
|
@block_level -= 1
|
215
192
|
end
|
216
193
|
|
217
194
|
def storage_class_type(storage_class_specifier)
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
195
|
+
return "N" unless storage_class_specifier
|
196
|
+
|
197
|
+
case storage_class_specifier.type
|
198
|
+
when :AUTO
|
199
|
+
"A"
|
200
|
+
when :REGISTER
|
201
|
+
"R"
|
202
|
+
when :STATIC
|
203
|
+
"S"
|
204
|
+
when :EXTERN
|
205
|
+
"E"
|
206
|
+
else
|
207
|
+
"N"
|
228
208
|
end
|
229
|
-
result
|
230
209
|
end
|
231
210
|
end
|
232
211
|
|
233
212
|
class FuncDefExtraction < CodeExtraction
|
234
213
|
def initialize(context)
|
235
214
|
super
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
visitor.leave_compound_statement += method(:leave_compound_statement)
|
215
|
+
interp = context[:c_interpreter]
|
216
|
+
interp.on_function_started += method(:extract_function)
|
217
|
+
interp.on_block_started += method(:enter_block)
|
218
|
+
interp.on_block_ended += method(:leave_block)
|
241
219
|
@block_level = 0
|
242
220
|
end
|
243
221
|
|
@@ -245,40 +223,26 @@ module C #:nodoc:
|
|
245
223
|
def do_prepare(context) end
|
246
224
|
def do_execute(context) end
|
247
225
|
|
248
|
-
def extract_function(function_definition)
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
function_definition.lines)
|
261
|
-
end
|
262
|
-
else
|
263
|
-
if @block_level == 0
|
264
|
-
FUNCDEF(function_definition.identifier.location, "X", "F",
|
265
|
-
FunctionIdentifier.new(function_definition.identifier.value,
|
266
|
-
function_definition.signature.to_s),
|
267
|
-
function_definition.lines)
|
268
|
-
else
|
269
|
-
FUNCDEF(function_definition.identifier.location, "I", "B",
|
270
|
-
FunctionIdentifier.new(function_definition.identifier.value,
|
271
|
-
function_definition.signature.to_s),
|
272
|
-
function_definition.lines)
|
273
|
-
end
|
226
|
+
def extract_function(function_definition, function)
|
227
|
+
case
|
228
|
+
when function.declared_as_extern?
|
229
|
+
FUNCDEF(function_definition.identifier.location, "X", "F",
|
230
|
+
FunctionIdentifier.new(function_definition.identifier.value,
|
231
|
+
function_definition.signature.to_s),
|
232
|
+
function_definition.lines)
|
233
|
+
when function.declared_as_static?
|
234
|
+
FUNCDEF(function_definition.identifier.location, "I", "F",
|
235
|
+
FunctionIdentifier.new(function_definition.identifier.value,
|
236
|
+
function_definition.signature.to_s),
|
237
|
+
function_definition.lines)
|
274
238
|
end
|
275
239
|
end
|
276
240
|
|
277
|
-
def
|
241
|
+
def enter_block(*)
|
278
242
|
@block_level += 1
|
279
243
|
end
|
280
244
|
|
281
|
-
def
|
245
|
+
def leave_block(*)
|
282
246
|
@block_level -= 1
|
283
247
|
end
|
284
248
|
end
|