adlint 2.6.12 → 2.6.14

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 (77) hide show
  1. data/ChangeLog +77 -0
  2. data/NEWS +17 -4
  3. data/bin/adlint +24 -30
  4. data/bin/adlint_chk +22 -28
  5. data/bin/adlint_cma +20 -26
  6. data/bin/adlint_sma +22 -28
  7. data/bin/adlintize +60 -58
  8. data/etc/mesg.d/c_builtin/en_US/messages.yml +168 -168
  9. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +168 -168
  10. data/etc/mesg.d/core/en_US/messages.yml +1 -1
  11. data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
  12. data/features/code_check/W0119.feature +0 -5
  13. data/features/code_check/W0120.feature +1 -0
  14. data/features/code_check/W0121.feature +0 -5
  15. data/features/code_check/W0123.feature +0 -5
  16. data/features/code_check/W0125.feature +0 -5
  17. data/features/code_check/W0127.feature +0 -5
  18. data/features/code_check/W0128.feature +0 -5
  19. data/features/code_check/W0129.feature +0 -5
  20. data/features/code_check/W0130.feature +0 -5
  21. data/features/code_check/W0132.feature +1 -0
  22. data/features/code_check/W0133.feature +0 -5
  23. data/features/code_check/W0134.feature +0 -5
  24. data/features/code_check/W0135.feature +0 -5
  25. data/features/code_check/W0136.feature +0 -5
  26. data/features/code_check/W0137.feature +0 -5
  27. data/features/code_check/W0138.feature +0 -5
  28. data/features/code_check/W0139.feature +0 -5
  29. data/features/code_check/W0140.feature +0 -5
  30. data/features/code_check/W0141.feature +0 -5
  31. data/features/code_check/W0142.feature +0 -5
  32. data/features/code_check/W0157.feature +0 -5
  33. data/features/code_check/W0161.feature +0 -5
  34. data/features/code_check/W0165.feature +0 -5
  35. data/features/code_check/W0169.feature +0 -5
  36. data/features/code_check/W0177.feature +0 -5
  37. data/features/code_check/W0182.feature +0 -5
  38. data/features/code_check/W0183.feature +0 -5
  39. data/features/code_check/W0184.feature +0 -5
  40. data/features/code_check/W0212.feature +0 -5
  41. data/features/code_check/W0214.feature +0 -5
  42. data/features/code_check/W0221.feature +0 -5
  43. data/features/code_check/W0223.feature +0 -5
  44. data/features/code_check/W0230.feature +0 -5
  45. data/features/code_check/W0232.feature +0 -5
  46. data/features/code_check/W0245.feature +0 -5
  47. data/features/code_check/W0246.feature +0 -5
  48. data/features/code_check/W0247.feature +0 -5
  49. data/features/code_check/W0251.feature +0 -5
  50. data/features/code_check/W0650.feature +0 -4
  51. data/features/code_check/W0703.feature +5 -1
  52. data/features/code_check/W0719.feature +0 -10
  53. data/features/code_check/W0748.feature +0 -5
  54. data/features/code_check/W0751.feature +0 -5
  55. data/features/code_check/W0756.feature +0 -5
  56. data/features/code_check/W0763.feature +0 -5
  57. data/features/code_check/W0787.feature +7 -0
  58. data/features/code_check/W0794.feature +0 -1
  59. data/features/code_check/W1052.feature +0 -2
  60. data/features/support/env.rb +2 -7
  61. data/lib/adlint/c/syntax.rb +10 -16
  62. data/lib/adlint/cpp/macro.rb +96 -0
  63. data/lib/adlint/exam/c_builtin/c_check.rb +954 -817
  64. data/lib/adlint/exam/c_builtin/c_check_shima.rb +17 -19
  65. data/lib/adlint/exam/c_builtin/ld_check.rb +86 -44
  66. data/lib/adlint/message.rb +1 -1
  67. data/lib/adlint/util.rb +8 -8
  68. data/lib/adlint/version.rb +2 -2
  69. data/lib/adlint.rb +8 -0
  70. data/share/doc/developers_guide_ja.html +3 -3
  71. data/share/doc/developers_guide_ja.texi +1 -1
  72. data/share/doc/users_guide_en.html +5055 -5053
  73. data/share/doc/users_guide_en.texi +3817 -3818
  74. data/share/doc/users_guide_ja.html +3787 -3786
  75. data/share/doc/users_guide_ja.texi +3784 -3783
  76. data/spec/spec_helper.rb +3 -11
  77. metadata +2 -2
@@ -818,36 +818,34 @@ module CBuiltin #:nodoc:
818
818
  end
819
819
 
820
820
  private
821
- def check(cast_expression, original_variable, result_variable)
822
- return unless @rvalues
823
- return unless original_variable.type.floating?
824
-
825
- case expression = @rvalues[original_variable]
826
- when C::AdditiveExpression, C::MultiplicativeExpression
827
- if original_variable.type.same_as?(from_type) &&
828
- result_variable.type.same_as?(to_type)
829
- W(message_id, expression.location)
821
+ def check(*, orig_var, result_var)
822
+ if @rvalues && orig_var.type.floating?
823
+ case expr = @rvalues[orig_var]
824
+ when C::AdditiveExpression, C::MultiplicativeExpression
825
+ if orig_var.type.same_as?(from_type) &&
826
+ result_var.type.same_as?(to_type)
827
+ W(message_id, expr.location)
828
+ end
830
829
  end
831
830
  end
832
831
  end
833
832
 
834
- def clear_rvalues(function_definition, function)
833
+ def clear_rvalues(*)
835
834
  @rvalues = {}
836
835
  end
837
836
 
838
- def handle_additive(additive_expression,
839
- lhs_variable, rhs_variable, result_variable)
840
- memorize_rvalue_derivation(result_variable, additive_expression)
837
+ def handle_additive(expr, lhs_var, rhs_var, result_var)
838
+ memorize_rvalue_derivation(result_var, expr)
841
839
  end
842
840
 
843
- def handle_multiplicative(multiplicative_expression,
844
- lhs_variable, rhs_variable, result_variable)
845
- return if multiplicative_expression.operator.type == "%"
846
- memorize_rvalue_derivation(result_variable, multiplicative_expression)
841
+ def handle_multiplicative(expr, lhs_var, rhs_var, result_var)
842
+ unless expr.operator.type == "%"
843
+ memorize_rvalue_derivation(result_var, expr)
844
+ end
847
845
  end
848
846
 
849
- def memorize_rvalue_derivation(rvalue_holder, expression)
850
- @rvalues[rvalue_holder] = expression if @rvalues
847
+ def memorize_rvalue_derivation(rvalue_holder, expr)
848
+ @rvalues[rvalue_holder] = expr if @rvalues
851
849
  end
852
850
 
853
851
  def from_type
@@ -173,29 +173,43 @@ module CBuiltin #:nodoc:
173
173
 
174
174
  def initialize(context)
175
175
  super
176
- context[:ld_function_traversal].on_definition += method(:check_function)
177
- context[:ld_variable_traversal].on_definition += method(:check_variable)
176
+ func_traversal = context[:ld_function_traversal]
177
+ func_traversal.on_declaration += method(:check_function)
178
+ func_traversal.on_definition += method(:check_function)
179
+ var_traversal = context[:ld_variable_traversal]
180
+ var_traversal.on_declaration += method(:check_variable)
181
+ var_traversal.on_definition += method(:check_variable)
178
182
  end
179
183
 
180
184
  private
181
- def check_function(function)
182
- return unless function.extern?
185
+ def check_function(func)
186
+ return unless func.extern?
187
+
183
188
  mapping = @context[:ld_function_mapping]
184
- declarations = mapping.lookup_function_declarations(function.name)
185
- if declarations.size > 1
186
- declarations.each do |declaration|
187
- W(:W0770, declaration.location, declaration.signature)
189
+ similar_dcls = mapping.lookup_function_declarations(func.name)
190
+
191
+ if similar_dcls.size > 1
192
+ W(:W0770, func.location, func.signature)
193
+ similar_dcls.each do |pair_dcl|
194
+ unless pair_dcl == func
195
+ C(:C0001, pair_dcl.location, pair_dcl.signature)
196
+ end
188
197
  end
189
198
  end
190
199
  end
191
200
 
192
- def check_variable(variable)
193
- return unless variable.extern?
201
+ def check_variable(var)
202
+ return unless var.extern?
203
+
194
204
  mapping = @context[:ld_variable_mapping]
195
- declarations = mapping.lookup_variable_declarations(variable.name)
196
- if declarations.size > 1
197
- declarations.each do |declaration|
198
- W(:W0770, declaration.location, declaration.name)
205
+ similar_dcls = mapping.lookup_variable_declarations(var.name)
206
+
207
+ if similar_dcls.size > 1
208
+ W(:W0770, var.location, var.name)
209
+ similar_dcls.each do |pair_dcl|
210
+ unless pair_dcl == var
211
+ C(:C0001, pair_dcl.location, pair_dcl.name)
212
+ end
199
213
  end
200
214
  end
201
215
  end
@@ -215,21 +229,35 @@ module CBuiltin #:nodoc:
215
229
  end
216
230
 
217
231
  private
218
- def check_function(function)
219
- return unless function.extern?
232
+ def check_function(func)
233
+ return unless func.extern?
234
+
220
235
  mapping = @context[:ld_function_mapping]
221
- functions = mapping.lookup_functions(function.name)
222
- if functions.size > 1
223
- functions.each { |func| W(:W0791, func.location, func.signature) }
236
+ similar_funcs = mapping.lookup_functions(func.name)
237
+
238
+ if similar_funcs.size > 1
239
+ W(:W0791, func.location, func.signature)
240
+ similar_funcs.each do |pair_func|
241
+ unless pair_func == func
242
+ C(:C0001, pair_func.location, pair_func.signature)
243
+ end
244
+ end
224
245
  end
225
246
  end
226
247
 
227
- def check_variable(variable)
228
- return unless variable.extern?
248
+ def check_variable(var)
249
+ return unless var.extern?
250
+
229
251
  mapping = @context[:ld_variable_mapping]
230
- variables = mapping.lookup_variables(variable.name)
231
- if variables.size > 1
232
- variables.each { |var| W(:W0791, var.location, var.name) }
252
+ similar_vars = mapping.lookup_variables(var.name)
253
+
254
+ if similar_vars.size > 1
255
+ W(:W0791, var.location, var.name)
256
+ similar_vars.each do |pair_var|
257
+ unless pair_var == var
258
+ C(:C0001, pair_var.location, pair_var.name)
259
+ end
260
+ end
233
261
  end
234
262
  end
235
263
  end
@@ -243,34 +271,48 @@ module CBuiltin #:nodoc:
243
271
 
244
272
  def initialize(context)
245
273
  super
246
- function_traversal = context[:ld_function_traversal]
247
- function_traversal.on_declaration += method(:check_function)
248
- function_traversal.on_definition += method(:check_function)
249
- variable_traversal = context[:ld_variable_traversal]
250
- variable_traversal.on_declaration += method(:check_variable)
251
- variable_traversal.on_definition += method(:check_variable)
274
+ func_traversal = context[:ld_function_traversal]
275
+ func_traversal.on_declaration += method(:check_function)
276
+ func_traversal.on_definition += method(:check_function)
277
+ var_traversal = context[:ld_variable_traversal]
278
+ var_traversal.on_declaration += method(:check_variable)
279
+ var_traversal.on_definition += method(:check_variable)
252
280
  end
253
281
 
254
282
  private
255
- def check_function(function)
256
- return unless function.extern?
283
+ def check_function(func)
284
+ return unless func.extern?
285
+
257
286
  mapping = @context[:ld_function_mapping]
258
- defs_and_decls =
259
- (mapping.lookup_function_declarations(function.name) +
260
- mapping.lookup_functions(function.name)).select { |f| f.extern? }
261
- if defs_and_decls.any? { |f| f.signature != function.signature }
262
- defs_and_decls.each { |f| W(:W1037, f.location, f.name) }
287
+ similar_dcls_or_funcs =
288
+ (mapping.lookup_function_declarations(func.name) +
289
+ mapping.lookup_functions(func.name)).select { |dcl_or_func|
290
+ dcl_or_func.extern? && dcl_or_func.signature != func.signature
291
+ }
292
+
293
+ unless similar_dcls_or_funcs.empty?
294
+ W(:W1037, func.location, func.signature)
295
+ similar_dcls_or_funcs.each do |pair_dcl_or_func|
296
+ C(:C0001, pair_dcl_or_func.location, pair_dcl_or_func.signature)
297
+ end
263
298
  end
264
299
  end
265
300
 
266
- def check_variable(variable)
267
- return unless variable.extern?
301
+ def check_variable(var)
302
+ return unless var.extern?
303
+
268
304
  mapping = @context[:ld_variable_mapping]
269
- defs_and_decls =
270
- (mapping.lookup_variable_declarations(variable.name) +
271
- mapping.lookup_variables(variable.name)).select { |var| var.extern? }
272
- if defs_and_decls.any? { |var| var.type != variable.type }
273
- defs_and_decls.each { |var| W(:W1037, var.location, var.name) }
305
+ similar_dcls_or_vars =
306
+ (mapping.lookup_variable_declarations(var.name) +
307
+ mapping.lookup_variables(var.name)).select { |dcl_or_var|
308
+ dcl_or_var.extern? && dcl_or_var.type != var.type
309
+ }
310
+
311
+ unless similar_dcls_or_vars.empty?
312
+ W(:W1037, var.location, var.name)
313
+ similar_dcls_or_vars.each do |pair_dcl_or_var|
314
+ C(:C0001, pair_dcl_or_var.location, pair_dcl_or_var.name)
315
+ end
274
316
  end
275
317
  end
276
318
  end
@@ -372,7 +372,7 @@ module AdLint #:nodoc:
372
372
 
373
373
  private
374
374
  def base_dpath
375
- Pathname.new("mesg.d/core").expand_path($etcdir)
375
+ Pathname.new("mesg.d/core").expand_path(Config[:etcdir])
376
376
  end
377
377
  end
378
378
 
data/lib/adlint/util.rb CHANGED
@@ -445,7 +445,7 @@ module AdLint #:nodoc:
445
445
  if key_indices.empty?
446
446
  if instance_method("#{name}").arity == 0
447
447
  define_cache_manipulator(name)
448
- class_eval(<<-EOS, "util.rb", 71)
448
+ class_eval <<-EOS
449
449
  define_method("#{name}") do |*args|
450
450
  @_#{name}_cache ||= nil
451
451
  @_#{name}_cache_forbidden ||= false
@@ -464,7 +464,7 @@ module AdLint #:nodoc:
464
464
  EOS
465
465
  else
466
466
  define_cache_manipulator(name, key_indices)
467
- class_eval(<<-EOS, "util.rb", 90)
467
+ class_eval <<-EOS
468
468
  define_method("#{name}") do |*args|
469
469
  @_#{name}_cache ||= {}
470
470
  @_#{name}_cache_forbidden ||= false
@@ -484,7 +484,7 @@ module AdLint #:nodoc:
484
484
  end
485
485
  else
486
486
  define_cache_manipulator(name, key_indices)
487
- class_eval(<<-EOS, "util.rb", 110)
487
+ class_eval <<-EOS
488
488
  define_method("#{name}") do |*args|
489
489
  @_#{name}_cache ||= {}
490
490
  @_#{name}_cache_forbidden ||= false
@@ -507,14 +507,14 @@ module AdLint #:nodoc:
507
507
 
508
508
  private
509
509
  def define_cache_manipulator(name, key_indices = nil)
510
- class_eval(<<-EOS, "util.rb", 133)
510
+ class_eval <<-EOS
511
511
  define_method("forbid_#{name}_memoizing_once") do |*args|
512
512
  @_#{name}_cache_forbidden = true
513
513
  end
514
514
  EOS
515
515
  case
516
516
  when key_indices && key_indices.empty?
517
- class_eval(<<-EOS, "util.rb", 140)
517
+ class_eval <<-EOS
518
518
  define_method("forget_#{name}_memo") do |*args|
519
519
  @_#{name}_cache.delete(args) if defined?(@_#{name}_cache)
520
520
  end
@@ -523,7 +523,7 @@ module AdLint #:nodoc:
523
523
  end
524
524
  EOS
525
525
  when key_indices
526
- class_eval(<<-EOS, "util.rb", 149)
526
+ class_eval <<-EOS
527
527
  define_method("forget_#{name}_memo") do |*args|
528
528
  if defined?(@_#{name}_cache)
529
529
  @_#{name}_cache.delete(args.values_at(#{key_indices.join(',')}))
@@ -534,7 +534,7 @@ module AdLint #:nodoc:
534
534
  end
535
535
  EOS
536
536
  else
537
- class_eval(<<-EOS, "util.rb", 160)
537
+ class_eval <<-EOS
538
538
  define_method("forget_#{name}_memo") do |*args|
539
539
  @_#{name}_cache = nil
540
540
  end
@@ -562,7 +562,7 @@ module AdLint #:nodoc:
562
562
 
563
563
  module Pluggable
564
564
  def def_plugin(event)
565
- class_eval(<<-EOS, "util.rb", 188)
565
+ class_eval <<-EOS
566
566
  define_method("#{event}") do |*args|
567
567
  @#{event}_plugin ||= Plugin.new
568
568
  end
@@ -33,8 +33,8 @@ module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 2
35
35
  MINOR_VERSION = 6
36
- PATCH_VERSION = 12
37
- RELEASE_DATE = "2012-11-29"
36
+ PATCH_VERSION = 14
37
+ RELEASE_DATE = "2012-12-17"
38
38
 
39
39
  TRAITS_SCHEMA_VERSION = "2.4.0"
40
40
 
data/lib/adlint.rb CHANGED
@@ -65,3 +65,11 @@ require "adlint/version"
65
65
  require "adlint/cpp"
66
66
  require "adlint/c"
67
67
  require "adlint/ld"
68
+
69
+ module AdLint #:nodoc:
70
+ Config = Hash.new
71
+ Config[:libdir] = Pathname.new(__FILE__).realpath.dirname
72
+ Config[:prefix] = Pathname.new("..").expand_path(Config[:libdir])
73
+ Config[:bindir] = Pathname.new("bin").expand_path(Config[:prefix])
74
+ Config[:etcdir] = Pathname.new("etc").expand_path(Config[:prefix])
75
+ end
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 2.6.12 開発者ガイド</title>
3
+ <title>AdLint 2.6.14 開発者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 2.6.12 開発者ガイド">
5
+ <meta name="description" content="AdLint 2.6.14 開発者ガイド">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 2.6.12 開発者ガイド</h1>
47
+ <h1 class="settitle">AdLint 2.6.14 開発者ガイド</h1>
48
48
  <div class="contents">
49
49
  <h2>Table of Contents</h2>
50
50
  <ul>
@@ -2,7 +2,7 @@
2
2
  @setfilename developers_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 2.6.12 開発者ガイド
5
+ @settitle AdLint 2.6.14 開発者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.