adlint 1.0.0 → 1.2.0

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.
Files changed (54) hide show
  1. data/AUTHORS +3 -2
  2. data/ChangeLog +208 -63
  3. data/MANIFEST +4 -0
  4. data/NEWS +24 -5
  5. data/etc/conf.d/fallback/traits.erb +1 -1
  6. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +1 -1
  7. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +1 -1
  8. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +1 -1
  9. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +1 -1
  10. data/etc/mesg.d/en_US/messages.yml +3 -3
  11. data/etc/mesg.d/ja_JP/messages.yml +4 -4
  12. data/lib/adlint/c/builtin.rb +3 -3
  13. data/lib/adlint/c/ctrlexpr.rb +7 -11
  14. data/lib/adlint/c/expr.rb +548 -363
  15. data/lib/adlint/c/interp.rb +233 -525
  16. data/lib/adlint/c/mediator.rb +1 -0
  17. data/lib/adlint/c/message.rb +144 -1
  18. data/lib/adlint/c/object.rb +15 -6
  19. data/lib/adlint/c/parser.rb +170 -128
  20. data/lib/adlint/c/parser.y +36 -0
  21. data/lib/adlint/c/phase.rb +4 -0
  22. data/lib/adlint/c/seqp.rb +72 -0
  23. data/lib/adlint/c/syntax.rb +254 -3
  24. data/lib/adlint/c.rb +1 -0
  25. data/lib/adlint/cpp/code.rb +2 -2
  26. data/lib/adlint/cpp/eval.rb +29 -13
  27. data/lib/adlint/cpp/message.rb +71 -70
  28. data/lib/adlint/cpp/message_shima.rb +100 -0
  29. data/lib/adlint/cpp/phase.rb +4 -0
  30. data/lib/adlint/cpp/syntax.rb +5 -1
  31. data/lib/adlint/cpp.rb +1 -0
  32. data/lib/adlint/message.rb +6 -3
  33. data/lib/adlint/traits.rb +1 -1
  34. data/lib/adlint/version.rb +5 -5
  35. data/share/demo/Makefile +3 -1
  36. data/share/demo/bad_line/bad_line.c +27 -0
  37. data/share/demo/sequence_point/sequence_point.c +31 -0
  38. data/share/doc/adlint_on_vim_en.png +0 -0
  39. data/share/doc/adlint_on_vim_ja.png +0 -0
  40. data/share/doc/developers_guide_ja.html +3 -3
  41. data/share/doc/developers_guide_ja.texi +1 -1
  42. data/share/doc/users_guide_en.html +3118 -41
  43. data/share/doc/users_guide_en.texi +3090 -37
  44. data/share/doc/users_guide_ja.html +3120 -47
  45. data/share/doc/users_guide_ja.texi +3106 -65
  46. data/share/sample/ctags-5.8/adlint/GNUmakefile +13 -1
  47. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +14 -2
  48. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +14 -4
  49. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +14 -1
  50. data/share/sample/flex-2.5.35/adlint/GNUmakefile +13 -1
  51. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +14 -2
  52. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -4
  53. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +14 -1
  54. metadata +6 -2
@@ -68,232 +68,304 @@ module C #:nodoc:
68
68
 
69
69
  extend Pluggable
70
70
 
71
+ def self.def_plugin_and_notifier(event_name, *arg_names)
72
+ class_eval <<-EOS
73
+ def_plugin :on_#{event_name}
74
+ def notify_#{event_name}(#{arg_names.join(",")})
75
+ unless @suppress_notification
76
+ on_#{event_name}.invoke(#{arg_names.join(",")})
77
+ end
78
+ end
79
+ EOS
80
+ end
81
+ private_class_method :def_plugin_and_notifier
82
+
71
83
  # NOTE: Notified when the interpreter evaluates an initializer of
72
84
  # variable-definition.
73
- def_plugin :on_variable_initialized
85
+ def_plugin_and_notifier :variable_initialized,
86
+ :variable_definition, :variable, :init_variable
74
87
 
75
88
  # NOTE: Notified when the interpreter evaluates a variable-definition.
76
- def_plugin :on_variable_defined
89
+ def_plugin_and_notifier :variable_defined, :variable_definition, :variable
77
90
 
78
91
  # NOTE: Notified when the interpreter evaluates a function-declaration.
79
- def_plugin :on_function_declared
92
+ def_plugin_and_notifier :function_declared,
93
+ :function_declaration, :function
80
94
 
81
95
  # NOTE: Notified when the interpreter evaluates a variable-declaration.
82
- def_plugin :on_variable_declared
96
+ def_plugin_and_notifier :variable_declared,
97
+ :variable_declaration, :variable
83
98
 
84
99
  # NOTE: Notified when the interpreter evaluates a struct-type-declaration.
85
- def_plugin :on_struct_declared
100
+ def_plugin_and_notifier :struct_declared, :struct_type_declaration
86
101
 
87
102
  # NOTE: Notified when the interpreter evaluates a union-type-declaration.
88
- def_plugin :on_union_declared
103
+ def_plugin_and_notifier :union_declared, :union_type_declaration
89
104
 
90
105
  # NOTE: Notified when the interpreter evaluates a enum-type-declaration.
91
- def_plugin :on_enum_declared
106
+ def_plugin_and_notifier :enum_declared, :enum_type_declaration
92
107
 
93
108
  # NOTE: Notified when the interpreter evaluates a typedef-declaration.
94
- def_plugin :on_typedef_declared
109
+ def_plugin_and_notifier :typedef_declared, :typedef_declaration
95
110
 
96
111
  # NOTE: Notified when the interpreter starts execution of a
97
112
  # function-definition.
98
- def_plugin :on_function_started
113
+ def_plugin_and_notifier :function_started, :function_definition
99
114
 
100
115
  # NOTE: Notified when the interpreter ends execution of a
101
116
  # function-definition.
102
- def_plugin :on_function_ended
117
+ def_plugin_and_notifier :function_ended, :function_definition
103
118
 
104
119
  # NOTE: Notified when the interpreter evaluates a parameter-definition at
105
120
  # beginning of execution of a function-definition.
106
- def_plugin :on_parameter_defined
121
+ def_plugin_and_notifier :parameter_defined,
122
+ :parameter_definition, :variable
107
123
 
108
124
  # NOTE: Notified when the interpreter evaluates an expression which results
109
125
  # a named variable.
110
- def_plugin :on_variable_referred
126
+ def_plugin_and_notifier :variable_referred, :object_specifier, :variable
111
127
 
112
128
  # NOTE: Notified when the interpreter evaluates an expression which results
113
129
  # a constant temporary variable.
114
- def_plugin :on_constant_referred
130
+ def_plugin_and_notifier :constant_referred, :constant_specifier, :variable
115
131
 
116
132
  # NOTE: Notified when the interpreter refer to a value of a variable while
117
133
  # evaluating an expression.
118
- def_plugin :on_variable_value_referred
134
+ def_plugin_and_notifier :variable_value_referred, :expression, :variable
119
135
 
120
136
  # NOTE: Notified when the interpreter overwrite a value of a variable while
121
137
  # evaluating an expression.
122
- def_plugin :on_variable_value_updated
138
+ def_plugin_and_notifier :variable_value_updated, :expression, :variable
123
139
 
124
140
  # NOTE: Notified when the interpreter refer to a function object while
125
141
  # evaluating an expression.
126
- def_plugin :on_function_referred
142
+ def_plugin_and_notifier :function_referred, :expression, :function
127
143
 
128
144
  # NOTE: Notified when the interpreter evaluates a sizeof-expression.
129
- def_plugin :on_sizeof_expr_evaled
145
+ def_plugin_and_notifier :sizeof_expr_evaled,
146
+ :expression, :operand_variable, :result_variable
130
147
 
131
148
  # NOTE: Notified when the interpreter evaluates a sizeof-type-expression.
132
- def_plugin :on_sizeof_type_expr_evaled
149
+ def_plugin_and_notifier :sizeof_type_expr_evaled,
150
+ :expression, :type, :result_variable
133
151
 
134
152
  # NOTE: Notified when the interpreter evaluates a cast-expression.
135
- def_plugin :on_explicit_conv_performed
153
+ def_plugin_and_notifier :explicit_conv_performed,
154
+ :expression, :original_variable, :result_variable
136
155
 
137
156
  # NOTE: Notified when the interpreter performs an implicit type conversion
138
157
  # while evaluating an expression.
139
- def_plugin :on_implicit_conv_performed
158
+ def_plugin_and_notifier :implicit_conv_performed,
159
+ :initializer_or_expression, :original_variable,
160
+ :result_variable
140
161
 
141
162
  # NOTE: Notified when the interpreter evaluates an
142
163
  # array-subscript-expression.
143
- def_plugin :on_array_subscript_expr_evaled
164
+ def_plugin_and_notifier :array_subscript_expr_evaled,
165
+ :array_subscript_expression,
166
+ :array_or_pointer_variable, :subscript_variable,
167
+ :array_variable, :result_variable
144
168
 
145
169
  # NOTE: Notified when the interpreter evaluates a function-call-expression.
146
- def_plugin :on_function_call_expr_evaled
170
+ def_plugin_and_notifier :function_call_expr_evaled,
171
+ :function_call_expression, :function,
172
+ :arg_variables, :result_variable
147
173
 
148
174
  # NOTE: Notified when the interpreter evaluates an
149
175
  # unary-arithmetic-expression.
150
- def_plugin :on_unary_arithmetic_expr_evaled
176
+ def_plugin_and_notifier :unary_arithmetic_expr_evaled,
177
+ :unary_arithmetic_expression, :operand_variable,
178
+ :result_variable
151
179
 
152
180
  # NOTE: Notified when the interpreter evaluates a
153
181
  # multiplicative-expression.
154
- def_plugin :on_multiplicative_expr_evaled
182
+ def_plugin_and_notifier :multiplicative_expr_evaled,
183
+ :multiplicative_expression, :lhs_variable,
184
+ :rhs_variable, :result_variable
155
185
 
156
186
  # NOTE: Notified when the interpreter evaluates an additive-expression.
157
- def_plugin :on_additive_expr_evaled
187
+ def_plugin_and_notifier :additive_expr_evaled,
188
+ :additive_expression, :lhs_variable, :rhs_variable,
189
+ :result_variable
158
190
 
159
191
  # NOTE: Notified when the interpreter evaluates a shift-expression.
160
- def_plugin :on_shift_expr_evaled
192
+ def_plugin_and_notifier :shift_expr_evaled,
193
+ :shift_expression, :lhs_variable, :rhs_variable,
194
+ :result_variable
161
195
 
162
196
  # NOTE: Notified when the interpreter evaluates a relational-expression.
163
- def_plugin :on_relational_expr_evaled
197
+ def_plugin_and_notifier :relational_expr_evaled,
198
+ :relational_expression, :lhs_variable,
199
+ :rhs_variable, :result_variable
164
200
 
165
201
  # NOTE: Notified when the interpreter evaluates an equality-expression.
166
- def_plugin :on_equality_expr_evaled
202
+ def_plugin_and_notifier :equality_expr_evaled,
203
+ :equality_expression, :lhs_variable, :rhs_variable,
204
+ :result_variable
167
205
 
168
206
  # NOTE: Notified when the interpreter evaluates a bitwise and-expression.
169
- def_plugin :on_and_expr_evaled
207
+ def_plugin_and_notifier :and_expr_evaled,
208
+ :and_expression, :lhs_variable, :rhs_variable,
209
+ :result_variable
170
210
 
171
211
  # NOTE: Notified when the interpreter evaluates an exclusive-or-expression.
172
- def_plugin :on_exclusive_or_expr_evaled
212
+ def_plugin_and_notifier :exclusive_or_expr_evaled,
213
+ :exclusive_or_expression, :lhs_variable,
214
+ :rhs_variable, :result_variable
173
215
 
174
216
  # NOTE: Notified when the interpreter evaluates a bitwise
175
217
  # inclusive-or-expression.
176
- def_plugin :on_inclusive_or_expr_evaled
218
+ def_plugin_and_notifier :inclusive_or_expr_evaled,
219
+ :inclusive_or_expression, :lhs_variable,
220
+ :rhs_variable, :result_variable
177
221
 
178
222
  # NOTE: Notified when the interpreter evaluates a logical-and-expression.
179
- def_plugin :on_logical_and_expr_evaled
223
+ def_plugin_and_notifier :logical_and_expr_evaled,
224
+ :logical_and_expression, :lhs_variable,
225
+ :rhs_variable, :result_variable
180
226
 
181
227
  # NOTE: Notified when the interpreter evaluates a logical-or-expression.
182
- def_plugin :on_logical_or_expr_evaled
228
+ def_plugin_and_notifier :logical_or_expr_evaled,
229
+ :logical_or_expression, :lhs_variable,
230
+ :rhs_variable, :result_variable
183
231
 
184
232
  # NOTE: Notified when the interpreter evaluates a conditional-expression.
185
- def_plugin :on_conditional_expr_evaled
233
+ def_plugin_and_notifier :conditional_expr_evaled,
234
+ :conditional_expression, :condition_variable,
235
+ :result_variable
186
236
 
187
237
  # NOTE: Notified when the interpreter evaluates an indirection-expression.
188
- def_plugin :on_indirection_expr_evaled
238
+ def_plugin_and_notifier :indirection_expr_evaled,
239
+ :indirection_expression, :pointer_variable,
240
+ :dereferenced_variable
189
241
 
190
242
  # NOTE: Notified when the interpreter evaluates a
191
243
  # member-access-by-value-expression or a
192
244
  # member-access-by-pointer-expression.
193
- def_plugin :on_member_access_expr_evaled
245
+ def_plugin_and_notifier :member_access_expr_evaled,
246
+ :member_access_expression, :outer_variable,
247
+ :member_variable
194
248
 
195
249
  # NOTE: Notified when the interpreter evaluates a
196
250
  # prefix-increment-expression.
197
- def_plugin :on_prefix_increment_expr_evaled
251
+ def_plugin_and_notifier :prefix_increment_expr_evaled,
252
+ :prefix_increment_expression, :operand_variable,
253
+ :original_value
198
254
 
199
255
  # NOTE: Notified when the interpreter evaluates a
200
256
  # postfix-increment-expression.
201
- def_plugin :on_postfix_increment_expr_evaled
257
+ def_plugin_and_notifier :postfix_increment_expr_evaled,
258
+ :postfix_increment_expression, :operand_variable,
259
+ :result_variable
202
260
 
203
261
  # NOTE: Notified when the interpreter evaluates a
204
262
  # prefix-decrement-expression.
205
- def_plugin :on_prefix_decrement_expr_evaled
263
+ def_plugin_and_notifier :prefix_decrement_expr_evaled,
264
+ :prefix_decrement_expression, :operand_variable,
265
+ :original_value
206
266
 
207
267
  # NOTE: Notified when the interpreter evaluates a
208
268
  # postfix-decrement-expression.
209
- def_plugin :on_postfix_decrement_expr_evaled
269
+ def_plugin_and_notifier :postfix_decrement_expr_evaled,
270
+ :postfix_decrement_expression, :operand_variable,
271
+ :result_variable
210
272
 
211
273
  # NOTE: Notified when the interpreter evaluates a
212
274
  # simple-assignment-expression or a compound-assignment-expression.
213
- def_plugin :on_assignment_expr_evaled
275
+ def_plugin_and_notifier :assignment_expr_evaled,
276
+ :assignment_expression, :lhs_variable,
277
+ :rhs_variable
214
278
 
215
279
  # NOTE: Notified when the interpreter starts execution of a
216
280
  # while-statement.
217
- def_plugin :on_while_stmt_started
281
+ def_plugin_and_notifier :while_stmt_started, :while_statement
218
282
 
219
283
  # NOTE: Notified when the interpreter ends execution of a while-statement.
220
- def_plugin :on_while_stmt_ended
284
+ def_plugin_and_notifier :while_stmt_ended, :while_statement
221
285
 
222
286
  # NOTE: Notified when the interpreter starts execution of a do-statement.
223
- def_plugin :on_do_stmt_started
287
+ def_plugin_and_notifier :do_stmt_started, :do_statement
224
288
 
225
289
  # NOTE: Notified when the interpreter ends execution of a do-statement.
226
- def_plugin :on_do_stmt_ended
290
+ def_plugin_and_notifier :do_stmt_ended, :do_statement
227
291
 
228
292
  # NOTE: Notified when the interpreter starts execution of a for-statement.
229
- def_plugin :on_for_stmt_started
293
+ def_plugin_and_notifier :for_stmt_started, :for_statement
230
294
 
231
295
  # NOTE: Notified when the interpreter ends execution of a for-statement.
232
- def_plugin :on_for_stmt_ended
296
+ def_plugin_and_notifier :for_stmt_ended, :for_statement
233
297
 
234
298
  # NOTE: Notified when the interpreter starts execution of a
235
299
  # c99-for-statement.
236
- def_plugin :on_c99_for_stmt_started
300
+ def_plugin_and_notifier :c99_for_stmt_started, :c99_for_statement
237
301
 
238
302
  # NOTE: Notified when the interpreter ends execution of a
239
303
  # c99-for-statement.
240
- def_plugin :on_c99_for_stmt_ended
304
+ def_plugin_and_notifier :c99_for_stmt_ended, :c99_for_statement
241
305
 
242
306
  # NOTE: Notified when the interpreter evaluates a goto-statement.
243
- def_plugin :on_goto_stmt_evaled
307
+ def_plugin_and_notifier :goto_stmt_evaled, :goto_statement, :label_name
244
308
 
245
309
  # NOTE: Notified when the interpreter evaluates a return-statement.
246
- def_plugin :on_return_stmt_evaled
310
+ def_plugin_and_notifier :return_stmt_evaled,
311
+ :return_statement, :result_variable
247
312
 
248
313
  # NOTE: Notified when the interpreter evaluates a controlling expression of
249
314
  # the if-statement.
250
- def_plugin :on_if_ctrlexpr_evaled
315
+ def_plugin_and_notifier :if_ctrlexpr_evaled, :if_statement, :ctrlexpr_value
251
316
 
252
317
  # NOTE: Notified when the interpreter evaluates a controlling expression of
253
318
  # the if-else-statement.
254
- def_plugin :on_if_else_ctrlexpr_evaled
319
+ def_plugin_and_notifier :if_else_ctrlexpr_evaled,
320
+ :if_else_statement, :ctrlexpr_value
255
321
 
256
322
  # NOTE: Notified when the interpreter evaluates a controlling expression of
257
323
  # the while-statement.
258
- def_plugin :on_while_ctrlexpr_evaled
324
+ def_plugin_and_notifier :while_ctrlexpr_evaled,
325
+ :while_statement, :ctrlexpr_value
259
326
 
260
327
  # NOTE: Notified when the interpreter evaluates a controlling expression of
261
328
  # the do-statement.
262
- def_plugin :on_do_ctrlexpr_evaled
329
+ def_plugin_and_notifier :do_ctrlexpr_evaled, :do_statement, :ctrlexpr_value
263
330
 
264
331
  # NOTE: Notified when the interpreter evaluates a controlling expression of
265
332
  # the for-statement.
266
- def_plugin :on_for_ctrlexpr_evaled
333
+ def_plugin_and_notifier :for_ctrlexpr_evaled,
334
+ :for_statement, :ctrlexpr_value
267
335
 
268
336
  # NOTE: Notified when the interpreter evaluates a controlling expression of
269
337
  # the c99-for-statement.
270
- def_plugin :on_c99_for_ctrlexpr_evaled
338
+ def_plugin_and_notifier :c99_for_ctrlexpr_evaled,
339
+ :c99_for_statement, :ctrlexpr_value
271
340
 
272
341
  # NOTE: Notified when the interpreter defines a generic-label.
273
- def_plugin :on_label_defined
342
+ def_plugin_and_notifier :label_defined, :generic_labeled_statement
274
343
 
275
344
  # NOTE: Notified when the interpreter starts execution of a
276
345
  # compound-statement.
277
- def_plugin :on_block_started
346
+ def_plugin_and_notifier :block_started, :compound_statement
278
347
 
279
348
  # NOTE: Notified when the interpreter ends execution of a
280
349
  # compound-statement.
281
- def_plugin :on_block_ended
350
+ def_plugin_and_notifier :block_ended, :compound_statement
282
351
 
283
352
  # NOTE: Notified when the interpreter forks execution paths of a
284
353
  # function-definition.
285
- def_plugin :on_branch_started
354
+ def_plugin_and_notifier :branch_started, :branch
286
355
 
287
356
  # NOTE: Notified when the interpreter joins execution paths of a
288
357
  # function-definition.
289
- def_plugin :on_branch_ended
358
+ def_plugin_and_notifier :branch_ended, :branch
290
359
 
291
360
  # NOTE: Notified when the interpreter starts execution of a
292
361
  # translation-unit.
293
- def_plugin :on_translation_unit_started
362
+ def_plugin_and_notifier :translation_unit_started, :translation_unit
294
363
 
295
364
  # NOTE: Notified when the interpreter ends execution of a translation-unit.
296
- def_plugin :on_translation_unit_ended
365
+ def_plugin_and_notifier :translation_unit_ended, :translation_unit
366
+
367
+ # NOTE: Notified when control reaches to a sequence-point.
368
+ def_plugin_and_notifier :sequence_point_reached, :sequence_point
297
369
 
298
370
  def execute(node, *options)
299
371
  if options.include?(:suppress_notification)
@@ -332,467 +404,6 @@ module C #:nodoc:
332
404
  ScalarValue.of(object.binding.memory.address)
333
405
  end
334
406
 
335
- def notify_variable_initialized(variable_definition,
336
- variable, init_variable)
337
- unless @suppress_notification
338
- on_variable_initialized.invoke(variable_definition,
339
- variable, init_variable)
340
- end
341
- end
342
-
343
- def notify_variable_defined(variable_definition, variable)
344
- unless @suppress_notification
345
- on_variable_defined.invoke(variable_definition, variable)
346
- end
347
- end
348
-
349
- def notify_function_declared(function_declaration, function)
350
- unless @suppress_notification
351
- on_function_declared.invoke(function_declaration, function)
352
- end
353
- end
354
-
355
- def notify_variable_declared(variable_declaration, variable)
356
- unless @suppress_notification
357
- on_variable_declared.invoke(variable_declaration, variable)
358
- end
359
- end
360
-
361
- def notify_struct_declared(struct_type_declaration)
362
- unless @suppress_notification
363
- on_struct_declared.invoke(struct_type_declaration)
364
- end
365
- end
366
-
367
- def notify_union_declared(union_type_declaration)
368
- unless @suppress_notification
369
- on_union_declared.invoke(union_type_declaration)
370
- end
371
- end
372
-
373
- def notify_enum_declared(enum_type_declaration)
374
- unless @suppress_notification
375
- on_enum_declared.invoke(enum_type_declaration)
376
- end
377
- end
378
-
379
- def notify_typedef_declared(typedef_declaration)
380
- unless @suppress_notification
381
- on_typedef_declared.invoke(typedef_declaration)
382
- end
383
- end
384
-
385
- def notify_function_started(function_definition)
386
- unless @suppress_notification
387
- on_function_started.invoke(function_definition)
388
- end
389
- end
390
-
391
- def notify_function_ended(function_definition)
392
- unless @suppress_notification
393
- on_function_ended.invoke(function_definition)
394
- end
395
- end
396
-
397
- def notify_parameter_defined(parameter_definition, variable)
398
- unless @suppress_notification
399
- on_parameter_defined.invoke(parameter_definition, variable)
400
- end
401
- end
402
-
403
- def notify_variable_referred(object_specifier, variable)
404
- unless @suppress_notification
405
- on_variable_referred.invoke(object_specifier, variable)
406
- end
407
- end
408
-
409
- def notify_constant_referred(constant_specifier, variable)
410
- unless @suppress_notification
411
- on_constant_referred.invoke(constant_specifier, variable)
412
- end
413
- end
414
-
415
- def notify_variable_value_referred(expression, variable)
416
- unless @suppress_notification
417
- on_variable_value_referred.invoke(expression, variable)
418
- end
419
- end
420
-
421
- def notify_variable_value_updated(expression, variable)
422
- unless @suppress_notification
423
- on_variable_value_updated.invoke(expression, variable)
424
- end
425
- end
426
-
427
- def notify_function_referred(expression, function)
428
- unless @suppress_notification
429
- on_function_referred.invoke(expression, function)
430
- end
431
- end
432
-
433
- def notify_sizeof_expr_evaled(expression,
434
- operand_variable, result_variable)
435
- unless @suppress_notification
436
- on_sizeof_expr_evaled.invoke(expression,
437
- operand_variable, result_variable)
438
- end
439
- end
440
-
441
- def notify_sizeof_type_expr_evaled(expression, type, result_variable)
442
- unless @suppress_notification
443
- on_sizeof_type_expr_evaled.invoke(expression, type, result_variable)
444
- end
445
- end
446
-
447
- def notify_explicit_conv_performed(expression,
448
- original_variable, result_variable)
449
- unless @suppress_notification
450
- on_explicit_conv_performed.invoke(expression,
451
- original_variable, result_variable)
452
- end
453
- end
454
-
455
- def notify_implicit_conv_performed(initializer_or_expression,
456
- original_variable, result_variable)
457
- unless @suppress_notification
458
- on_implicit_conv_performed.invoke(initializer_or_expression,
459
- original_variable, result_variable)
460
- end
461
- end
462
-
463
- def notify_array_subscript_expr_evaled(array_subscript_expression,
464
- array_or_pointer_variable,
465
- subscript_variable,
466
- array_variable, result_variable)
467
- unless @suppress_notification
468
- on_array_subscript_expr_evaled.invoke(array_subscript_expression,
469
- array_or_pointer_variable,
470
- subscript_variable,
471
- array_variable, result_variable)
472
- end
473
- end
474
-
475
- def notify_function_call_expr_evaled(function_call_expression, function,
476
- arg_variables, result_variable)
477
- unless @suppress_notification
478
- on_function_call_expr_evaled.invoke(function_call_expression, function,
479
- arg_variables, result_variable)
480
- end
481
- end
482
-
483
- def notify_unary_arithmetic_expr_evaled(unary_arithmetic_expression,
484
- operand_variable, result_variable)
485
- unless @suppress_notification
486
- on_unary_arithmetic_expr_evaled.invoke(unary_arithmetic_expression,
487
- operand_variable,
488
- result_variable)
489
- end
490
- end
491
-
492
- def notify_multiplicative_expr_evaled(multiplicative_expression,
493
- lhs_variable, rhs_variable,
494
- result_variable)
495
- unless @suppress_notification
496
- on_multiplicative_expr_evaled.invoke(multiplicative_expression,
497
- lhs_variable, rhs_variable,
498
- result_variable)
499
- end
500
- end
501
-
502
- def notify_additive_expr_evaled(additive_expression,
503
- lhs_variable, rhs_variable,
504
- result_variable)
505
- unless @suppress_notification
506
- on_additive_expr_evaled.invoke(additive_expression,
507
- lhs_variable, rhs_variable,
508
- result_variable)
509
- end
510
- end
511
-
512
- def notify_shift_expr_evaled(shift_expression,
513
- lhs_variable, rhs_variable, result_variable)
514
- unless @suppress_notification
515
- on_shift_expr_evaled.invoke(shift_expression,
516
- lhs_variable, rhs_variable,
517
- result_variable)
518
- end
519
- end
520
-
521
- def notify_relational_expr_evaled(relational_expression,
522
- lhs_variable, rhs_variable,
523
- result_variable)
524
- unless @suppress_notification
525
- on_relational_expr_evaled.invoke(relational_expression,
526
- lhs_variable, rhs_variable,
527
- result_variable)
528
- end
529
- end
530
-
531
- def notify_equality_expr_evaled(equality_expression,
532
- lhs_variable, rhs_variable,
533
- result_variable)
534
- unless @suppress_notification
535
- on_equality_expr_evaled.invoke(equality_expression,
536
- lhs_variable, rhs_variable,
537
- result_variable)
538
- end
539
- end
540
-
541
- def notify_and_expr_evaled(and_expression,
542
- lhs_variable, rhs_variable, result_variable)
543
- unless @suppress_notification
544
- on_and_expr_evaled.invoke(and_expression,
545
- lhs_variable, rhs_variable, result_variable)
546
- end
547
- end
548
-
549
- def notify_exclusive_or_expr_evaled(exclusive_or_expression,
550
- lhs_variable, rhs_variable,
551
- result_variable)
552
- unless @suppress_notification
553
- on_exclusive_or_expr_evaled.invoke(exclusive_or_expression,
554
- lhs_variable, rhs_variable,
555
- result_variable)
556
- end
557
- end
558
-
559
- def notify_inclusive_or_expr_evaled(inclusive_or_expression,
560
- lhs_variable, rhs_variable,
561
- result_variable)
562
- unless @suppress_notification
563
- on_inclusive_or_expr_evaled.invoke(inclusive_or_expression,
564
- lhs_variable, rhs_variable,
565
- result_variable)
566
- end
567
- end
568
-
569
- def notify_logical_and_expr_evaled(logical_and_expression,
570
- lhs_variable, rhs_variable,
571
- result_variable)
572
- unless @suppress_notification
573
- on_logical_and_expr_evaled.invoke(logical_and_expression,
574
- lhs_variable, rhs_variable,
575
- result_variable)
576
- end
577
- end
578
-
579
- def notify_logical_or_expr_evaled(logical_or_expression,
580
- lhs_variable, rhs_variable,
581
- result_variable)
582
- unless @suppress_notification
583
- on_logical_or_expr_evaled.invoke(logical_or_expression,
584
- lhs_variable, rhs_variable,
585
- result_variable)
586
- end
587
- end
588
-
589
- def notify_conditional_expr_evaled(conditional_expression,
590
- condition_variable, result_variable)
591
- unless @suppress_notification
592
- on_conditional_expr_evaled.invoke(conditional_expression,
593
- condition_variable, result_variable)
594
- end
595
- end
596
-
597
- def notify_indirection_expr_evaled(indirection_expression,
598
- pointer_variable, dereferenced_variable)
599
- unless @suppress_notification
600
- on_indirection_expr_evaled.invoke(indirection_expression,
601
- pointer_variable,
602
- dereferenced_variable)
603
- end
604
- end
605
-
606
- def notify_member_access_expr_evaled(member_access_expression,
607
- outer_variable, member_variable)
608
- unless @suppress_notification
609
- on_member_access_expr_evaled.invoke(member_access_expression,
610
- outer_variable, member_variable)
611
- end
612
- end
613
-
614
- def notify_prefix_increment_expr_evaled(prefix_increment_expression,
615
- operand_variable, original_value)
616
- unless @suppress_notification
617
- on_prefix_increment_expr_evaled.invoke(prefix_increment_expression,
618
- operand_variable,
619
- original_value)
620
- end
621
- end
622
-
623
- def notify_postfix_increment_expr_evaled(postfix_increment_expression,
624
- operand_variable, result_variable)
625
- unless @suppress_notification
626
- on_postfix_increment_expr_evaled.invoke(postfix_increment_expression,
627
- operand_variable,
628
- result_variable)
629
- end
630
- end
631
-
632
- def notify_prefix_decrement_expr_evaled(prefix_decrement_expression,
633
- operand_variable, original_value)
634
- unless @suppress_notification
635
- on_prefix_decrement_expr_evaled.invoke(prefix_decrement_expression,
636
- operand_variable,
637
- original_value)
638
- end
639
- end
640
-
641
- def notify_postfix_decrement_expr_evaled(postfix_decrement_expression,
642
- operand_variable, result_variable)
643
- unless @suppress_notification
644
- on_postfix_decrement_expr_evaled.invoke(postfix_decrement_expression,
645
- operand_variable,
646
- result_variable)
647
- end
648
- end
649
-
650
- def notify_assignment_expr_evaled(assignment_expression,
651
- lhs_variable, rhs_variable)
652
- unless @suppress_notification
653
- on_assignment_expr_evaled.invoke(assignment_expression,
654
- lhs_variable, rhs_variable)
655
- end
656
- end
657
-
658
- def notify_while_stmt_started(while_statement)
659
- unless @suppress_notification
660
- on_while_stmt_started.invoke(while_statement)
661
- end
662
- end
663
-
664
- def notify_while_stmt_ended(while_statement)
665
- unless @suppress_notification
666
- on_while_stmt_ended.invoke(while_statement)
667
- end
668
- end
669
-
670
- def notify_do_stmt_started(do_statement)
671
- unless @suppress_notification
672
- on_do_stmt_started.invoke(do_statement)
673
- end
674
- end
675
-
676
- def notify_do_stmt_ended(do_statement)
677
- unless @suppress_notification
678
- on_do_stmt_ended.invoke(do_statement)
679
- end
680
- end
681
-
682
- def notify_for_stmt_started(for_statement)
683
- unless @suppress_notification
684
- on_for_stmt_started.invoke(for_statement)
685
- end
686
- end
687
-
688
- def notify_for_stmt_ended(for_statement)
689
- unless @suppress_notification
690
- on_for_stmt_ended.invoke(for_statement)
691
- end
692
- end
693
-
694
- def notify_c99_for_stmt_started(c99_for_statement)
695
- unless @suppress_notification
696
- on_c99_for_stmt_started.invoke(c99_for_statement)
697
- end
698
- end
699
-
700
- def notify_c99_for_stmt_ended(c99_for_statement)
701
- unless @suppress_notification
702
- on_c99_for_stmt_ended.invoke(c99_for_statement)
703
- end
704
- end
705
-
706
- def notify_goto_stmt_evaled(goto_statement, label_name)
707
- unless @suppress_notification
708
- on_goto_stmt_evaled.invoke(goto_statement, label_name)
709
- end
710
- end
711
-
712
- def notify_return_stmt_evaled(return_statement, result_variable)
713
- unless @suppress_notification
714
- on_return_stmt_evaled.invoke(return_statement, result_variable)
715
- end
716
- end
717
-
718
- def notify_if_ctrlexpr_evaled(if_statement, ctrlexpr_value)
719
- unless @suppress_notification
720
- on_if_ctrlexpr_evaled.invoke(if_statement, ctrlexpr_value)
721
- end
722
- end
723
-
724
- def notify_if_else_ctrlexpr_evaled(if_else_statement, ctrlexpr_value)
725
- unless @suppress_notification
726
- on_if_else_ctrlexpr_evaled.invoke(if_else_statement, ctrlexpr_value)
727
- end
728
- end
729
-
730
- def notify_while_ctrlexpr_evaled(while_statement, ctrlexpr_value)
731
- unless @suppress_notification
732
- on_while_ctrlexpr_evaled.invoke(while_statement, ctrlexpr_value)
733
- end
734
- end
735
-
736
- def notify_do_ctrlexpr_evaled(do_statement, ctrlexpr_value)
737
- unless @suppress_notification
738
- on_do_ctrlexpr_evaled.invoke(do_statement, ctrlexpr_value)
739
- end
740
- end
741
-
742
- def notify_for_ctrlexpr_evaled(for_statement, ctrlexpr_value)
743
- unless @suppress_notification
744
- on_for_ctrlexpr_evaled.invoke(for_statement, ctrlexpr_value)
745
- end
746
- end
747
-
748
- def notify_c99_for_ctrlexpr_evaled(c99_for_statement, ctrlexpr_value)
749
- unless @suppress_notification
750
- on_c99_for_ctrlexpr_evaled.invoke(c99_for_statement, ctrlexpr_value)
751
- end
752
- end
753
-
754
- def notify_label_defined(generic_labeled_statement)
755
- unless @suppress_notification
756
- on_label_defined.invoke(generic_labeled_statement)
757
- end
758
- end
759
-
760
- def notify_block_started(compound_statement)
761
- unless @suppress_notification
762
- on_block_started.invoke(compound_statement)
763
- end
764
- end
765
-
766
- def notify_block_ended(compound_statement)
767
- unless @suppress_notification
768
- on_block_ended.invoke(compound_statement)
769
- end
770
- end
771
-
772
- def notify_branch_started(branch)
773
- unless @suppress_notification
774
- on_branch_started.invoke(branch)
775
- end
776
- end
777
-
778
- def notify_branch_ended(branch)
779
- unless @suppress_notification
780
- on_branch_ended.invoke(branch)
781
- end
782
- end
783
-
784
- def notify_translation_unit_started(translation_unit)
785
- unless @suppress_notification
786
- on_translation_unit_started.invoke(translation_unit)
787
- end
788
- end
789
-
790
- def notify_translation_unit_ended(translation_unit)
791
- unless @suppress_notification
792
- on_translation_unit_ended.invoke(translation_unit)
793
- end
794
- end
795
-
796
407
  def _suppress_notification=(suppress_notification)
797
408
  # NOTE: This method is called only from ControllingExpression.
798
409
  @suppress_notification = suppress_notification
@@ -879,6 +490,8 @@ module C #:nodoc:
879
490
 
880
491
  function = define_explicit_function(node)
881
492
  notify_function_declared(node, function)
493
+
494
+ evaluate_sequence_point(node.init_declarator.declarator)
882
495
  end
883
496
 
884
497
  def visit_variable_declaration(node)
@@ -892,6 +505,8 @@ module C #:nodoc:
892
505
 
893
506
  variable = declare_variable(node)
894
507
  notify_variable_declared(node, variable)
508
+
509
+ evaluate_sequence_point(node.declarator)
895
510
  end
896
511
 
897
512
  def visit_variable_definition(node)
@@ -915,6 +530,8 @@ module C #:nodoc:
915
530
  notify_implicit_conv_performed(initializer, init_variable, converted)
916
531
  end
917
532
 
533
+ notify_variable_value_referred(node, init_variable)
534
+
918
535
  variable = define_variable(node, converted.value.to_defined_value)
919
536
  notify_variable_defined(node, variable)
920
537
  notify_variable_initialized(node, variable, init_variable)
@@ -922,6 +539,8 @@ module C #:nodoc:
922
539
  variable = define_variable(node)
923
540
  notify_variable_defined(node, variable)
924
541
  end
542
+
543
+ evaluate_sequence_point(node.init_declarator.declarator)
925
544
  end
926
545
 
927
546
  def visit_struct_type_declaration(node)
@@ -972,6 +591,8 @@ module C #:nodoc:
972
591
 
973
592
  notify_typedef_declared(node)
974
593
 
594
+ evaluate_sequence_point(node.init_declarator.declarator)
595
+
975
596
  Analyzer.current.info("user type `#{node.identifier.value}' " +
976
597
  "defined at #{node.location.to_s}.")
977
598
  end
@@ -1007,6 +628,12 @@ module C #:nodoc:
1007
628
  def deduct_array_length_from_array_variable(variable_type, array_variable)
1008
629
  variable_type.length ||= array_variable.type.length
1009
630
  end
631
+
632
+ def evaluate_sequence_point(full_declarator)
633
+ if sequence_point = full_declarator.subsequent_sequence_point
634
+ notify_sequence_point_reached(sequence_point)
635
+ end
636
+ end
1010
637
  end
1011
638
 
1012
639
  class InitializerInterpreter
@@ -1341,12 +968,26 @@ module C #:nodoc:
1341
968
  NARROWING, FINAL, IMPLICIT_CONDITION, COMPLETE) do
1342
969
  interpret(node.body_statement)
1343
970
  interpret(node.expression) if node.expression
971
+ # NOTE: To avoid that value of the controlling variable is marked
972
+ # as updated at end of the for-statement. Value of the
973
+ # controlling variable is referred by the controlling
974
+ # expression at the last iteration.
975
+ # FIXME: This re-interpretation of the controlling expression may
976
+ # causes duplicative warning messages.
977
+ interpret(ctrlexpr)
1344
978
  end
1345
979
  when ctrlexpr_value.may_be_true?
1346
980
  branched_eval(effective_ctrlexpr,
1347
981
  NARROWING, FINAL, IMPLICIT_CONDITION) do
1348
982
  interpret(node.body_statement)
1349
983
  interpret(node.expression) if node.expression
984
+ # NOTE: To avoid that value of the controlling variable is marked
985
+ # as updated at end of the for-statement. Value of the
986
+ # controlling variable is referred by the controlling
987
+ # expression at the last iteration.
988
+ # FIXME: This re-interpretation of the controlling expression may
989
+ # causes duplicative warning messages.
990
+ interpret(ctrlexpr)
1350
991
  end
1351
992
  end
1352
993
  else
@@ -1383,12 +1024,26 @@ module C #:nodoc:
1383
1024
  NARROWING, FINAL, IMPLICIT_CONDITION, COMPLETE) do
1384
1025
  interpret(node.body_statement)
1385
1026
  interpret(node.expression) if node.expression
1027
+ # NOTE: To avoid that value of the controlling variable is marked
1028
+ # as updated at end of the for-statement. Value of the
1029
+ # controlling variable is referred by the controlling
1030
+ # expression at the last iteration.
1031
+ # FIXME: This re-interpretation of the controlling expression may
1032
+ # causes duplicative warning messages.
1033
+ interpret(ctrlexpr)
1386
1034
  end
1387
1035
  when ctrlexpr_value.may_be_true?
1388
1036
  branched_eval(effective_ctrlexpr,
1389
1037
  NARROWING, FINAL, IMPLICIT_CONDITION) do
1390
1038
  interpret(node.body_statement)
1391
1039
  interpret(node.expression) if node.expression
1040
+ # NOTE: To avoid that value of the controlling variable is marked
1041
+ # as updated at end of the for-statement. Value of the
1042
+ # controlling variable is referred by the controlling
1043
+ # expression at the last iteration.
1044
+ # FIXME: This re-interpretation of the controlling expression may
1045
+ # causes duplicative warning messages.
1046
+ interpret(ctrlexpr)
1392
1047
  end
1393
1048
  end
1394
1049
  else
@@ -1734,6 +1389,59 @@ module C #:nodoc:
1734
1389
  def initialize(owner)
1735
1390
  super(owner, Expression)
1736
1391
  end
1392
+
1393
+ def self.def_eval_with_sequence_point(method_name)
1394
+ class_eval <<-EOS
1395
+ def #{method_name}(node)
1396
+ super
1397
+ ensure
1398
+ if sequence_point = node.subsequent_sequence_point
1399
+ notify_sequence_point_reached(sequence_point)
1400
+ end
1401
+ end
1402
+ EOS
1403
+ end
1404
+ private_class_method :def_eval_with_sequence_point
1405
+
1406
+ def_eval_with_sequence_point :visit_error_expression
1407
+ def_eval_with_sequence_point :visit_object_specifier
1408
+ def_eval_with_sequence_point :visit_constant_specifier
1409
+ def_eval_with_sequence_point :visit_string_literal_specifier
1410
+ def_eval_with_sequence_point :visit_null_constant_specifier
1411
+ def_eval_with_sequence_point :visit_grouped_expression
1412
+ def_eval_with_sequence_point :visit_array_subscript_expression
1413
+ def_eval_with_sequence_point :visit_function_call_expression
1414
+ def_eval_with_sequence_point :visit_member_access_by_value_expression
1415
+ def_eval_with_sequence_point :visit_member_access_by_pointer_expression
1416
+ def_eval_with_sequence_point :visit_bit_access_by_value_expression
1417
+ def_eval_with_sequence_point :visit_bit_access_by_pointer_expression
1418
+ def_eval_with_sequence_point :visit_postfix_increment_expression
1419
+ def_eval_with_sequence_point :visit_postfix_decrement_expression
1420
+ def_eval_with_sequence_point :visit_compound_literal_expression
1421
+ def_eval_with_sequence_point :visit_prefix_increment_expression
1422
+ def_eval_with_sequence_point :visit_prefix_decrement_expression
1423
+ def_eval_with_sequence_point :visit_address_expression
1424
+ def_eval_with_sequence_point :visit_indirection_expression
1425
+ def_eval_with_sequence_point :visit_unary_arithmetic_expression
1426
+ def_eval_with_sequence_point :visit_sizeof_expression
1427
+ def_eval_with_sequence_point :visit_sizeof_type_expression
1428
+ def_eval_with_sequence_point :visit_alignof_expression
1429
+ def_eval_with_sequence_point :visit_alignof_type_expression
1430
+ def_eval_with_sequence_point :visit_cast_expression
1431
+ def_eval_with_sequence_point :visit_multiplicative_expression
1432
+ def_eval_with_sequence_point :visit_additive_expression
1433
+ def_eval_with_sequence_point :visit_shift_expression
1434
+ def_eval_with_sequence_point :visit_relational_expression
1435
+ def_eval_with_sequence_point :visit_equality_expression
1436
+ def_eval_with_sequence_point :visit_and_expression
1437
+ def_eval_with_sequence_point :visit_exclusive_or_expression
1438
+ def_eval_with_sequence_point :visit_inclusive_or_expression
1439
+ def_eval_with_sequence_point :visit_logical_and_expression
1440
+ def_eval_with_sequence_point :visit_logical_or_expression
1441
+ def_eval_with_sequence_point :visit_conditional_expression
1442
+ def_eval_with_sequence_point :visit_simple_assignment_expression
1443
+ def_eval_with_sequence_point :visit_compound_assignment_expression
1444
+ def_eval_with_sequence_point :visit_comma_separated_expression
1737
1445
  end
1738
1446
 
1739
1447
  end