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.
- data/ChangeLog +77 -0
- data/NEWS +17 -4
- data/bin/adlint +24 -30
- data/bin/adlint_chk +22 -28
- data/bin/adlint_cma +20 -26
- data/bin/adlint_sma +22 -28
- data/bin/adlintize +60 -58
- data/etc/mesg.d/c_builtin/en_US/messages.yml +168 -168
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +168 -168
- data/etc/mesg.d/core/en_US/messages.yml +1 -1
- data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
- data/features/code_check/W0119.feature +0 -5
- data/features/code_check/W0120.feature +1 -0
- data/features/code_check/W0121.feature +0 -5
- data/features/code_check/W0123.feature +0 -5
- data/features/code_check/W0125.feature +0 -5
- data/features/code_check/W0127.feature +0 -5
- data/features/code_check/W0128.feature +0 -5
- data/features/code_check/W0129.feature +0 -5
- data/features/code_check/W0130.feature +0 -5
- data/features/code_check/W0132.feature +1 -0
- data/features/code_check/W0133.feature +0 -5
- data/features/code_check/W0134.feature +0 -5
- data/features/code_check/W0135.feature +0 -5
- data/features/code_check/W0136.feature +0 -5
- data/features/code_check/W0137.feature +0 -5
- data/features/code_check/W0138.feature +0 -5
- data/features/code_check/W0139.feature +0 -5
- data/features/code_check/W0140.feature +0 -5
- data/features/code_check/W0141.feature +0 -5
- data/features/code_check/W0142.feature +0 -5
- data/features/code_check/W0157.feature +0 -5
- data/features/code_check/W0161.feature +0 -5
- data/features/code_check/W0165.feature +0 -5
- data/features/code_check/W0169.feature +0 -5
- data/features/code_check/W0177.feature +0 -5
- data/features/code_check/W0182.feature +0 -5
- data/features/code_check/W0183.feature +0 -5
- data/features/code_check/W0184.feature +0 -5
- data/features/code_check/W0212.feature +0 -5
- data/features/code_check/W0214.feature +0 -5
- data/features/code_check/W0221.feature +0 -5
- data/features/code_check/W0223.feature +0 -5
- data/features/code_check/W0230.feature +0 -5
- data/features/code_check/W0232.feature +0 -5
- data/features/code_check/W0245.feature +0 -5
- data/features/code_check/W0246.feature +0 -5
- data/features/code_check/W0247.feature +0 -5
- data/features/code_check/W0251.feature +0 -5
- data/features/code_check/W0650.feature +0 -4
- data/features/code_check/W0703.feature +5 -1
- data/features/code_check/W0719.feature +0 -10
- data/features/code_check/W0748.feature +0 -5
- data/features/code_check/W0751.feature +0 -5
- data/features/code_check/W0756.feature +0 -5
- data/features/code_check/W0763.feature +0 -5
- data/features/code_check/W0787.feature +7 -0
- data/features/code_check/W0794.feature +0 -1
- data/features/code_check/W1052.feature +0 -2
- data/features/support/env.rb +2 -7
- data/lib/adlint/c/syntax.rb +10 -16
- data/lib/adlint/cpp/macro.rb +96 -0
- data/lib/adlint/exam/c_builtin/c_check.rb +954 -817
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +17 -19
- data/lib/adlint/exam/c_builtin/ld_check.rb +86 -44
- data/lib/adlint/message.rb +1 -1
- data/lib/adlint/util.rb +8 -8
- data/lib/adlint/version.rb +2 -2
- data/lib/adlint.rb +8 -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 +5055 -5053
- data/share/doc/users_guide_en.texi +3817 -3818
- data/share/doc/users_guide_ja.html +3787 -3786
- data/share/doc/users_guide_ja.texi +3784 -3783
- data/spec/spec_helper.rb +3 -11
- metadata +2 -2
@@ -818,36 +818,34 @@ module CBuiltin #:nodoc:
|
|
818
818
|
end
|
819
819
|
|
820
820
|
private
|
821
|
-
def check(
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
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(
|
833
|
+
def clear_rvalues(*)
|
835
834
|
@rvalues = {}
|
836
835
|
end
|
837
836
|
|
838
|
-
def handle_additive(
|
839
|
-
|
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(
|
844
|
-
|
845
|
-
|
846
|
-
|
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,
|
850
|
-
@rvalues[rvalue_holder] =
|
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]
|
177
|
-
|
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(
|
182
|
-
return unless
|
185
|
+
def check_function(func)
|
186
|
+
return unless func.extern?
|
187
|
+
|
183
188
|
mapping = @context[:ld_function_mapping]
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
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(
|
193
|
-
return unless
|
201
|
+
def check_variable(var)
|
202
|
+
return unless var.extern?
|
203
|
+
|
194
204
|
mapping = @context[:ld_variable_mapping]
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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(
|
219
|
-
return unless
|
232
|
+
def check_function(func)
|
233
|
+
return unless func.extern?
|
234
|
+
|
220
235
|
mapping = @context[:ld_function_mapping]
|
221
|
-
|
222
|
-
|
223
|
-
|
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(
|
228
|
-
return unless
|
248
|
+
def check_variable(var)
|
249
|
+
return unless var.extern?
|
250
|
+
|
229
251
|
mapping = @context[:ld_variable_mapping]
|
230
|
-
|
231
|
-
|
232
|
-
|
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
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
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(
|
256
|
-
return unless
|
283
|
+
def check_function(func)
|
284
|
+
return unless func.extern?
|
285
|
+
|
257
286
|
mapping = @context[:ld_function_mapping]
|
258
|
-
|
259
|
-
(mapping.lookup_function_declarations(
|
260
|
-
mapping.lookup_functions(
|
261
|
-
|
262
|
-
|
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(
|
267
|
-
return unless
|
301
|
+
def check_variable(var)
|
302
|
+
return unless var.extern?
|
303
|
+
|
268
304
|
mapping = @context[:ld_variable_mapping]
|
269
|
-
|
270
|
-
(mapping.lookup_variable_declarations(
|
271
|
-
mapping.lookup_variables(
|
272
|
-
|
273
|
-
|
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
|
data/lib/adlint/message.rb
CHANGED
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
565
|
+
class_eval <<-EOS
|
566
566
|
define_method("#{event}") do |*args|
|
567
567
|
@#{event}_plugin ||= Plugin.new
|
568
568
|
end
|
data/lib/adlint/version.rb
CHANGED
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.
|
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.
|
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.
|
47
|
+
<h1 class="settitle">AdLint 2.6.14 開発者ガイド</h1>
|
48
48
|
<div class="contents">
|
49
49
|
<h2>Table of Contents</h2>
|
50
50
|
<ul>
|