adlint 1.6.0 → 1.8.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 (50) hide show
  1. data/ChangeLog +389 -37
  2. data/INSTALL +3 -0
  3. data/MANIFEST +7 -0
  4. data/NEWS +50 -10
  5. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
  6. data/etc/mesg.d/en_US/messages.yml +7 -7
  7. data/etc/mesg.d/ja_JP/messages.yml +4 -4
  8. data/lib/adlint/c/branch.rb +4 -4
  9. data/lib/adlint/c/code.rb +11 -13
  10. data/lib/adlint/c/enum.rb +0 -2
  11. data/lib/adlint/c/environ.rb +13 -7
  12. data/lib/adlint/c/expr.rb +5 -1
  13. data/lib/adlint/c/interp.rb +10 -6
  14. data/lib/adlint/c/mediator.rb +1 -0
  15. data/lib/adlint/c/message.rb +294 -111
  16. data/lib/adlint/c/message_shima.rb +63 -0
  17. data/lib/adlint/c/metric.rb +25 -13
  18. data/lib/adlint/c/object.rb +168 -31
  19. data/lib/adlint/c/parser.rb +3 -3
  20. data/lib/adlint/c/phase.rb +20 -3
  21. data/lib/adlint/c/syntax.rb +175 -17
  22. data/lib/adlint/c/value.rb +199 -126
  23. data/lib/adlint/cpp/asm.rb +4 -4
  24. data/lib/adlint/cpp/constexpr.rb +1 -1
  25. data/lib/adlint/cpp/eval.rb +6 -4
  26. data/lib/adlint/cpp/message.rb +100 -7
  27. data/lib/adlint/cpp/phase.rb +12 -1
  28. data/lib/adlint/cpp/source.rb +2 -2
  29. data/lib/adlint/cpp/subst.rb +2 -4
  30. data/lib/adlint/lang.rb +5 -3
  31. data/lib/adlint/ld/metric.rb +1 -1
  32. data/lib/adlint/version.rb +2 -2
  33. data/share/demo/Makefile +5 -0
  34. data/share/demo/bad_include/bad_include.c +13 -0
  35. data/share/demo/bad_include/test'1'.h +0 -0
  36. data/share/demo/bad_include/test'2'.h +0 -0
  37. data/share/demo/incomplete_ifelse/incomplete_ifelse.c +29 -0
  38. data/share/demo/inline_asm/inline_asm.c +25 -0
  39. data/share/demo/invalid_call/invalid_call.c +12 -4
  40. data/share/demo/logical_expr/logical_expr.c +73 -0
  41. data/share/demo/register_vars/register_vars.c +12 -0
  42. data/share/demo/typedef_each_src/typedef_each_src.c +9 -0
  43. data/share/demo/wrap_around/wrap_around.c +17 -0
  44. data/share/doc/developers_guide_ja.html +3 -3
  45. data/share/doc/developers_guide_ja.texi +1 -1
  46. data/share/doc/users_guide_en.html +137 -102
  47. data/share/doc/users_guide_en.texi +121 -86
  48. data/share/doc/users_guide_ja.html +118 -91
  49. data/share/doc/users_guide_ja.texi +103 -76
  50. metadata +10 -3
data/NEWS CHANGED
@@ -21,6 +21,50 @@
21
21
 
22
22
  ++
23
23
 
24
+ === \AdLint 1.8.0 is released (2012-04-27)
25
+
26
+ ==== Changes since the 1.6.0 release
27
+
28
+ * Add W0607 detection
29
+ * Add W0608 detection
30
+ * Add W0625 detection
31
+ * Add W0632 detection
32
+ * Add W0633 detection
33
+ * Add W0634 detection
34
+ * Add W0642 detection
35
+ * Add W0711 detection
36
+ * Add W0712 detection
37
+ * Add W0713 detection
38
+ * Add W0714 detection
39
+ * Add W0715 detection
40
+ * Add W0832 detection
41
+ * Fix W0629 detection not to warn when the translation-unit local function is
42
+ referred to derive a pointer to the function
43
+ * Fix W0459 and W0460 detections not to warn about inner variables owned by a
44
+ temporary variable
45
+ * Fix W0461 and W0462 detections not to warn when the length omitted array
46
+ parameter is specified as an argument.
47
+ * Fix W1031 detection not to warn when the storage-class-specifier of the
48
+ object declaration is explicitly specified and the storage-class-specifier of
49
+ following object definition is omitted
50
+ * Fix W0581, W0582, W0583 and W0584 detections not to warn when the
51
+ corresponding types of argument and parameter are array-array or
52
+ array-pointer pair
53
+ * Fix W0581 detection to warn when the number of arguments in current function
54
+ call is greater than the number of arguments in previous function calls
55
+ * Fix W0582, W0583 and W0584 detections to warn when the number of parameters
56
+ is greater than the number of arguments
57
+ * Fix abend problem when the pathname of #include_next directive is not in the
58
+ executing environment
59
+ * Support mswin path separator in #include or #include_next directives
60
+ * Fix bad FN_UELS (number of incomplete if-else-if statement chains) metric
61
+ measurement
62
+ * Improve value version management of the abstract interpreter
63
+
64
+ See the file
65
+ {ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
66
+ for more details.
67
+
24
68
  === \AdLint 1.6.0 is released (2012-04-06)
25
69
 
26
70
  ==== Changes since the 1.4.0 release
@@ -49,21 +93,17 @@
49
93
  * Add W1061 detection
50
94
  * Add W1062 detection
51
95
  * Add W1063 detection
52
- * Fix W0027 detection not to warn when a pointer variable is compared
53
- with NULL constant
54
- * Fix W0728, W0729 and W0730 detections not to warn when the target
55
- is a variable of the other enum type
56
- * Fix W0104 detection not to warn about invariant parameter of array
57
- type whose base type is qualified as const
96
+ * Fix W0027 detection not to warn when a pointer variable is compared with NULL
97
+ constant
98
+ * Fix W0728, W0729 and W0730 detections not to warn when the target is a
99
+ variable of the other enum type
100
+ * Fix W0104 detection not to warn about invariant parameter of array type whose
101
+ base type is qualified as const
58
102
  * Fix bad W0031, W0100, W0104, W0459 and W0460 detections
59
103
  * Fix bad FN_UNUV measurement
60
104
  * Update the user's guide in Japanese
61
105
  * Update the user's guide in English
62
106
 
63
- See the file
64
- {ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
65
- for more details.
66
-
67
107
  === \AdLint 1.4.0 is released (2012-03-29)
68
108
 
69
109
  ==== Changes since the 1.2.0 release
@@ -220,7 +220,7 @@
220
220
  #define __GNUC_GNU_INLINE__ 1
221
221
  #define __UINT_FAST8_TYPE__ unsigned char
222
222
  #define __declspec(x) __attribute__((x))
223
- #
223
+
224
224
  #define __const const
225
225
  #define __restrict restrict
226
226
  #define __restrict__ restrict
@@ -36,7 +36,7 @@
36
36
  # X9999: "Your custom message for the fatal error of #9999."
37
37
  # E9999: "Your custom message for the error of #9999."
38
38
 
39
- version: "1.6.0"
39
+ version: "1.8.0"
40
40
 
41
41
  message_definition:
42
42
  X0001: "An unknown exception `%s' is found."
@@ -497,7 +497,7 @@ message_definition:
497
497
  W0535: "A comma operator is used in a 'for' statement."
498
498
  W0538: "This 'default' label is not final label in this 'switch' statement."
499
499
  W0540: "A function which the blank formal argument list is declared. `void' is omitted."
500
- W0541: "This function mixed weaves C code with inline assembly code."
500
+ W0541: "Inline assembly code should be encapsulated by macro."
501
501
  W0542: "There are identifiers in the part of formal argument in a function declaration."
502
502
  W0543: "The identifier of formal argument in this function declaration is different from the past declaration of it."
503
503
  W0544: "The identifier of formal argument in the function declaration is different from the declaration of function pointer."
@@ -562,8 +562,8 @@ message_definition:
562
562
  W0627: "There is a dead letter (only `;') in the following other code."
563
563
  W0628: "A function `%s' is defined, but this is not used in this project."
564
564
  W0629: "A static function `%s()' is not used in this translation unit."
565
- W0632: "If `'' or `/*' use in `#include <%s>', it will unspecify behavior."
566
- W0633: "If `'' or `/*' use in `#include \"%s\"', it will unspecify behavior."
565
+ W0632: "Using ' or \" characters in `#include %s' directive makes undefined behavior."
566
+ W0633: "Using ' character in `#include %s' directive makes undefined behavior."
567
567
  W0634: "`\\' is used in `#include' line. `/' is recommended for the path delimiter."
568
568
  W0635: "The type doesn't match with %sth conversion specifier and the corresponding actual argument."
569
569
  W0636: "An actual argument doesn't exist correspond to %sth conversion specifier."
@@ -614,9 +614,9 @@ message_definition:
614
614
  W0685: "A character preceding the `-' in scanset o `[]' is bigger than a character following the `-'."
615
615
  W0686: "The same characters are described in scanset (characters enclosed by `[]')."
616
616
  W0687: "#undef is using to delete #defined operator."
617
- W0688: "There is no line number in 1 to 32767 ranges after '#line'."
618
- W0689: "#line command syntax doesn't match `#line volatile integer constant value \"string\"'."
619
- W0690: "This is not line number after '#line' value'."
617
+ W0688: "There is no line number in 1 to 32767 ranges after #line directive."
618
+ W0689: "#line directive syntax doesn't match `#line integer constant \"string\"'."
619
+ W0690: "No line number after #line directive."
620
620
  W0691: "The result of `##' operator is not valid preprocessing token."
621
621
  W0692: "A function-like macro doesn't given an actual argument."
622
622
  W0693: "A function-like macro is called by actual argument which its definition is smaller."
@@ -36,7 +36,7 @@
36
36
  # X9999: "Your custom message for the fatal error of #9999."
37
37
  # E9999: "Your custom message for the error of #9999."
38
38
 
39
- version: "1.6.0"
39
+ version: "1.8.0"
40
40
 
41
41
  message_definition:
42
42
  X0001: "不明な例外条件 `%s' を検出しました。"
@@ -497,7 +497,7 @@ message_definition:
497
497
  W0535: "for 文の制御式の中にカンマ演算子が使われています。"
498
498
  W0538: "この default ラベルは、switch 文内の最後のラベルではありません。"
499
499
  W0540: "空の仮引数並びの関数が定義されています。`void' が省略されています。"
500
- W0541: "この関数には C コードとインラインアセンブリコードが混在しています。"
500
+ W0541: "マクロで隠蔽されないインラインアセンブリコードです。"
501
501
  W0542: "関数宣言の仮引数の一部にのみ識別子が存在します。"
502
502
  W0543: "この関数宣言における仮引数の識別子は、以前の宣言の仮引数の識別子と異なります。"
503
503
  W0544: "関数宣言の仮引数の識別子と関数ポインタの宣言の仮引数の識別子が異なります。"
@@ -562,8 +562,8 @@ message_definition:
562
562
  W0627: "一行に、空文(`;' だけの文)が、他のコードの後にあります。"
563
563
  W0628: "関数 `%s' が定義されていますが、このプロジェクトでは使われていません。"
564
564
  W0629: "static 関数 `%s()' は、この翻訳単位の中で使われていません。"
565
- W0632: "`#include <%s>' の中で `''、`\"' または `/*' を使うと、未定義の動作になります。"
566
- W0633: "`#include \"%s\"' の中で `'' や `/*' を使うと、未定義の動作になります。"
565
+ W0632: "`#include %s' の中で ' \" 文字を使うと、未定義の動作になります。"
566
+ W0633: "`#include %s' の中で ' 文字を使うと、未定義の動作になります。"
567
567
  W0634: "`#include' 行の中で `\\' を使っています。パス区切り文字としては `/' を勧めます。"
568
568
  W0635: "%s 番目の変換指定子と、対応する実引数の型が合いません。"
569
569
  W0636: "%s 番目の変換指定子に対応する実引数が存在しません。"
@@ -85,7 +85,7 @@ module C #:nodoc:
85
85
  end
86
86
 
87
87
  def execute(interpreter, expression = nil, &block)
88
- environment.begin_versioning_group if first?
88
+ environment.enter_versioning_group if first?
89
89
  environment.begin_versioning
90
90
 
91
91
  @controlling_expression = ControllingExpression.new(interpreter, self)
@@ -95,7 +95,7 @@ module C #:nodoc:
95
95
 
96
96
  ensure
97
97
  environment.end_versioning(break_with_return?)
98
- environment.end_versioning_group(!@group.complete?) if final?
98
+ environment.leave_versioning_group(!@group.complete?) if final?
99
99
 
100
100
  if final? && @group.complete?
101
101
  rethrow_break_event
@@ -105,8 +105,8 @@ module C #:nodoc:
105
105
  def restart_versioning(&block)
106
106
  @controlling_expression.save_affected_variables
107
107
  environment.end_versioning(false)
108
- environment.end_versioning_group(true)
109
- environment.begin_versioning_group
108
+ environment.leave_versioning_group(true)
109
+ environment.enter_versioning_group
110
110
  environment.begin_versioning
111
111
  yield
112
112
  @controlling_expression.restore_affected_variables
data/lib/adlint/c/code.rb CHANGED
@@ -356,16 +356,15 @@ module C #:nodoc:
356
356
  def do_prepare(context) end
357
357
  def do_execute(context) end
358
358
 
359
- def update_caller(function_definition)
360
- @caller = function_definition
359
+ def update_caller(function_definition, function)
360
+ @caller = function
361
361
  end
362
362
 
363
363
  def extract_function_call(function_call_expression, function,
364
364
  arg_variables, result_variable)
365
365
  if @caller && function.named?
366
366
  CALL(function_call_expression.location,
367
- FunctionIdentifier.new(@caller.identifier.value,
368
- @caller.signature.to_s),
367
+ FunctionIdentifier.new(@caller.name, @caller.signature.to_s),
369
368
  FunctionIdentifier.new(function.name, function.signature.to_s))
370
369
  end
371
370
  end
@@ -387,18 +386,18 @@ module C #:nodoc:
387
386
  def do_prepare(context) end
388
387
  def do_execute(context) end
389
388
 
390
- def update_accessor(function_definition)
391
- @accessor = function_definition
389
+ def update_accessor(function_definition, function)
390
+ @accessor = function
392
391
  end
393
392
 
394
- def clear_accessor(function_definition)
393
+ def clear_accessor(function_definition, function)
395
394
  @accessor = nil
396
395
  end
397
396
 
398
397
  def extract_variable_read(expression, variable)
399
398
  if @accessor && variable.scope.global? && variable.named?
400
399
  XREF_VAR(expression.location,
401
- FunctionIdentifier.new(@accessor.identifier.value,
400
+ FunctionIdentifier.new(@accessor.name,
402
401
  @accessor.signature.to_s),
403
402
  "R", variable.name)
404
403
  end
@@ -407,7 +406,7 @@ module C #:nodoc:
407
406
  def extract_variable_write(expression, variable)
408
407
  if @accessor && variable.scope.global? && variable.named?
409
408
  XREF_VAR(expression.location,
410
- FunctionIdentifier.new(@accessor.identifier.value,
409
+ FunctionIdentifier.new(@accessor.name,
411
410
  @accessor.signature.to_s),
412
411
  "W", variable.name)
413
412
  end
@@ -416,11 +415,10 @@ module C #:nodoc:
416
415
  def extract_function_reference(expression, function)
417
416
  if @accessor && function.named?
418
417
  XREF_FUNC(expression.location,
419
- FunctionIdentifier.new(@accessor.identifier.value,
418
+ FunctionIdentifier.new(@accessor.name,
420
419
  @accessor.signature.to_s),
421
- "R",
422
- FunctionIdentifier.new(function.name,
423
- function.signature.to_s))
420
+ "R", FunctionIdentifier.new(function.name,
421
+ function.signature.to_s))
424
422
  end
425
423
  end
426
424
  end
data/lib/adlint/c/enum.rb CHANGED
@@ -29,8 +29,6 @@
29
29
  #
30
30
  #++
31
31
 
32
- require "adlint/c/syntax"
33
-
34
32
  module AdLint #:nodoc:
35
33
  module C #:nodoc:
36
34
 
@@ -29,6 +29,7 @@
29
29
  #
30
30
  #++
31
31
 
32
+ require "adlint/c/enum"
32
33
  require "adlint/c/object"
33
34
  require "adlint/c/builtin"
34
35
  require "adlint/c/branch"
@@ -108,18 +109,23 @@ module C #:nodoc:
108
109
  @branch_depth -= 1
109
110
  end
110
111
 
111
- def begin_versioning_group
112
- @variable_table.begin_versioning_group
112
+ def enter_versioning_group
113
+ @variable_table.enter_variables_value_versioning_group
113
114
  end
114
115
 
115
- extend Forwardable
116
+ def leave_versioning_group(raise_complement)
117
+ @variable_table.leave_variables_value_versioning_group(raise_complement)
118
+ end
116
119
 
117
- def_delegator :variable_table, :end_versioning_group
118
- def_delegator :variable_table, :begin_versioning
120
+ def begin_versioning
121
+ @variable_table.begin_variables_value_versioning
122
+ end
119
123
 
120
124
  def end_versioning(rollback_this_version)
121
- @variable_table.rollback_latest_version if rollback_this_version
122
- @variable_table.end_versioning
125
+ if rollback_this_version
126
+ @variable_table.rollback_latest_variables_value_version!
127
+ end
128
+ @variable_table.end_variables_value_versioning
123
129
  end
124
130
 
125
131
  private
data/lib/adlint/c/expr.rb CHANGED
@@ -316,7 +316,11 @@ module C #:nodoc:
316
316
  # cross-references.
317
317
  _notify_variable_value_referred(node, object)
318
318
 
319
- temporary_variable(pointer_type(object.type), pointer_value_of(object))
319
+ pointer = temporary_variable(pointer_type(object.type),
320
+ pointer_value_of(object))
321
+
322
+ notify_address_expr_evaled(node, object, pointer)
323
+ pointer
320
324
  end
321
325
 
322
326
  def execute_indirection_expression(node, object)
@@ -114,11 +114,11 @@ module C #:nodoc:
114
114
 
115
115
  # NOTE: Notified when the interpreter starts execution of a
116
116
  # function-definition.
117
- def_plugin_and_notifier :function_started, :function_definition
117
+ def_plugin_and_notifier :function_started, :function_definition, :function
118
118
 
119
119
  # NOTE: Notified when the interpreter ends execution of a
120
120
  # function-definition.
121
- def_plugin_and_notifier :function_ended, :function_definition
121
+ def_plugin_and_notifier :function_ended, :function_definition, :function
122
122
 
123
123
  # NOTE: Notified when the interpreter evaluates a parameter-definition at
124
124
  # beginning of execution of a function-definition.
@@ -238,6 +238,10 @@ module C #:nodoc:
238
238
  :conditional_expression, :condition_variable,
239
239
  :result_variable
240
240
 
241
+ # NOTE: Notified when the interpreter evaluates an address-expression.
242
+ def_plugin_and_notifier :address_expr_evaled,
243
+ :address_expression, :object, :pointer_variable
244
+
241
245
  # NOTE: Notified when the interpreter evaluates an indirection-expression.
242
246
  def_plugin_and_notifier :indirection_expr_evaled,
243
247
  :indirection_expression, :pointer_variable,
@@ -820,7 +824,7 @@ module C #:nodoc:
820
824
  end
821
825
 
822
826
  scoped_eval do
823
- notify_function_started(node)
827
+ notify_function_started(node, function)
824
828
  notify_block_started(node.function_body)
825
829
 
826
830
  node.parameter_definitions.each { |pdef| interpret(pdef) }
@@ -830,7 +834,7 @@ module C #:nodoc:
830
834
  end
831
835
 
832
836
  notify_block_ended(node.function_body)
833
- notify_function_ended(node)
837
+ notify_function_ended(node, function)
834
838
  end
835
839
  ensure
836
840
  interpreter._leave_function(node)
@@ -1187,11 +1191,11 @@ module C #:nodoc:
1187
1191
  }
1188
1192
 
1189
1193
  unless anterior_gotos.empty?
1190
- variable.value.begin_versioning_group
1194
+ variable.value.enter_versioning_group
1191
1195
  variable.value.begin_versioning
1192
1196
  variable.uninitialize!
1193
1197
  variable.value.end_versioning
1194
- variable.value.end_versioning_group(true)
1198
+ variable.value.leave_versioning_group(true)
1195
1199
  end
1196
1200
  end
1197
1201
  end
@@ -211,6 +211,7 @@ module C #:nodoc:
211
211
  def_delegator :interpreter, :notify_logical_and_expr_evaled
212
212
  def_delegator :interpreter, :notify_logical_or_expr_evaled
213
213
  def_delegator :interpreter, :notify_conditional_expr_evaled
214
+ def_delegator :interpreter, :notify_address_expr_evaled
214
215
  def_delegator :interpreter, :notify_indirection_expr_evaled
215
216
  def_delegator :interpreter, :notify_member_access_expr_evaled
216
217
  def_delegator :interpreter, :notify_prefix_increment_expr_evaled