adlint 3.2.10 → 3.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7800591707d3378396282fc1b60d34a9f075f546
4
- data.tar.gz: ab3169c01ba31248a5e3f7f7ac64d07b4bd95574
3
+ metadata.gz: fa76355096835da637b733c8206bf5d759f01147
4
+ data.tar.gz: 8fa414fe9df4b715c950d45c07ace9d5a1356ac4
5
5
  SHA512:
6
- metadata.gz: 386e78ec4f9a39f660c4146010eb6ee7cbf8b92ce4916815f19f6b5965512daf7f8a7793bb5448385845185d0827cb5b6a0f88a073572daf144e3eb82fd36ca8
7
- data.tar.gz: bac0402535c63311bc98aa3b570b348b73e5b9350322b68ce7deae2557a70bb10191fffe34e9067de06127e6c217d3b8f14795e38b376bec03bb2c7df9a82cd0
6
+ metadata.gz: eb322d1d2e7d67215b23706ba00f3509386f2ba06f661816001867fa7513d63e34498afbb4cb1824591871b91a3ae3d4119ed6dd3127491719030c98e33c291c
7
+ data.tar.gz: 19c980d7ef83983142b54430609941a6fefec254cbb674f3dac9041db64bcd093b60081ca555b4d887cd4e55ff87b395c0155b684a8fb6de75f13f65f8846db3
data/ChangeLog CHANGED
@@ -1,3 +1,62 @@
1
+ Sat Apr 12 09:08:17 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
+
3
+ * release.ga : 3.2.12
4
+ - Fix the type and object model in order to correctly manage unnamed
5
+ struct or union members.
6
+ - Add examination package initializer.
7
+ - Revise behavior of the CMA code structure collection so that an
8
+ optional examination package can output its own special
9
+ met-records.
10
+
11
+ Thu Apr 10 18:48:43 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
12
+
13
+ * release.rc : 3.2.11
14
+ - Fix the type and object model in order to correctly manage unnamed
15
+ struct or union members.
16
+ - Add examination package initializer.
17
+ - Revise behavior of the CMA code structure collection so that an
18
+ optional examination package can output its own special
19
+ met-records.
20
+
21
+ Thu Apr 10 15:11:38 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
22
+
23
+ * lib/adlint/metric.rb : Revise behavior of the CMA code structure
24
+ collection so that an optional examination package can output its own
25
+ special met-records.
26
+ * lib/adlint/ld/object.rb : Ditto.
27
+ * lib/adlint/ld/typedef.rb : Ditto.
28
+
29
+ Thu Apr 10 13:34:44 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
30
+
31
+ * lib/adlint/exam.rb : Add examination package initializer.
32
+
33
+ Thu Apr 10 10:57:34 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
34
+
35
+ * lib/adlint/cc1/type.rb : Fix the type and object model in order to
36
+ correctly manage unnamed struct or union members.
37
+ * lib/adlint/cc1/syntax.rb : Ditto.
38
+ * lib/adlint/cc1/resolver.rb : Ditto.
39
+ * lib/adlint/cc1/object.rb : Ditto.
40
+
41
+ * lib/adlint/exam/c_builtin/cc1_check.rb : Correct W0067 and W0492 code
42
+ check according to changes of the type and object model.
43
+ * features/code_check/W0801.feature : Ditto.
44
+
45
+ * features/code_check/W0067.feature : Add scenario to reproduce
46
+ false-positive of W0067 code check.
47
+ * MANIFEST : Ditto.
48
+
49
+ Fri Mar 7 12:57:41 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
50
+
51
+ * lib/adlint/cc1/lexer.rb : Refactor a bit in order to clarify
52
+ intention to take tail part of an array.
53
+ * lib/adlint/cc1/value.rb : Ditto.
54
+ * lib/adlint/cpp/eval.rb : Ditto.
55
+ * lib/adlint/cpp/macro.rb : Ditto.
56
+ * lib/adlint/cpp/subst.rb : Ditto.
57
+ * lib/adlint/exam/c_builtin/cc1_check.rb : Ditto.
58
+ * spec/adlint/cc1/syntax_spec.rb : Ditto.
59
+
1
60
  Mon Feb 17 12:56:05 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
61
 
3
62
  * release.ga : 3.2.10
data/MANIFEST CHANGED
@@ -55,6 +55,7 @@ features/code_check/W0023.feature
55
55
  features/code_check/W0024.feature
56
56
  features/code_check/W0025.feature
57
57
  features/code_check/W0026.feature
58
+ features/code_check/W0067.feature
58
59
  features/code_check/W0070.feature
59
60
  features/code_check/W0071.feature
60
61
  features/code_check/W0088.feature
data/NEWS CHANGED
@@ -21,6 +21,19 @@
21
21
 
22
22
  ++
23
23
 
24
+ === \AdLint 3.2.12 is released (2014-04-12)
25
+
26
+ ==== Changes since the 3.2.10 release
27
+
28
+ * Fix the type and object model in order to correctly manage unnamed struct or
29
+ union members
30
+ * Add examination package initializer
31
+ * Revise behavior of the CMA code structure collection so that an optional
32
+ examination package can output its own special met-records
33
+
34
+ See the file {ChangeLog}[https://github.com/yanoh/adlint/blob/master/ChangeLog]
35
+ for more details.
36
+
24
37
  === \AdLint 3.2.10 is released (2014-02-17)
25
38
 
26
39
  ==== Changes since the 3.2.8 release
@@ -28,9 +41,6 @@
28
41
  * Add new templates for MSVC100 (Visual C++ 2010) as a C compiler on 32bit
29
42
  Windows
30
43
 
31
- See the file {ChangeLog}[https://github.com/yanoh/adlint/blob/master/ChangeLog]
32
- for more details.
33
-
34
44
  === \AdLint 3.2.8 is released (2014-02-07)
35
45
 
36
46
  ==== Changes since the 3.2.6 release
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.10"
52
+ version: "3.2.12"
53
53
 
54
54
  message_definition:
55
55
  W0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.10"
52
+ version: "3.2.12"
53
53
 
54
54
  message_definition:
55
55
  W0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.10"
52
+ version: "3.2.12"
53
53
 
54
54
  message_definition:
55
55
  X0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.10"
52
+ version: "3.2.12"
53
53
 
54
54
  message_definition:
55
55
  X0001:
@@ -0,0 +1,74 @@
1
+ Feature: W0067
2
+
3
+ W0067 detects that the nested member of a composite data type is accessed
4
+ directly without parent member names.
5
+
6
+ Scenario: no direct access
7
+ Given a target source named "fixture.c" with:
8
+ """
9
+ static int foo(void)
10
+ {
11
+ struct {
12
+ int i;
13
+ struct {
14
+ int j;
15
+ } baz;
16
+ } bar = { 0, { 0 } };
17
+
18
+ return bar.i + bar.baz.j; /* OK */
19
+ }
20
+ """
21
+ When I successfully run `adlint fixture.c` on noarch
22
+ Then the output should exactly match with:
23
+ | mesg | line | column |
24
+ | W1076 | 1 | 12 |
25
+ | W0100 | 8 | 7 |
26
+ | W0629 | 1 | 12 |
27
+ | W0628 | 1 | 12 |
28
+
29
+ Scenario: direct access to nested member included in a named member
30
+ Given a target source named "fixture.c" with:
31
+ """
32
+ static int foo(void)
33
+ {
34
+ struct {
35
+ int i;
36
+ struct {
37
+ int j;
38
+ } baz;
39
+ } bar = { 0, { 0 } };
40
+
41
+ return bar.i + bar.j; /* W0067 */
42
+ }
43
+ """
44
+ When I successfully run `adlint fixture.c` on noarch
45
+ Then the output should exactly match with:
46
+ | mesg | line | column |
47
+ | W1076 | 1 | 12 |
48
+ | W0067 | 10 | 23 |
49
+ | W0100 | 8 | 7 |
50
+ | W0629 | 1 | 12 |
51
+ | W0628 | 1 | 12 |
52
+
53
+ Scenario: direct access to nested member included in an unnamed member
54
+ Given a target source named "fixture.c" with:
55
+ """
56
+ static int foo(void)
57
+ {
58
+ struct {
59
+ int i;
60
+ struct {
61
+ int j;
62
+ };
63
+ } bar = { 0, { 0 } };
64
+
65
+ return bar.i + bar.j; /* OK */
66
+ }
67
+ """
68
+ When I successfully run `adlint fixture.c` on noarch
69
+ Then the output should exactly match with:
70
+ | mesg | line | column |
71
+ | W1076 | 1 | 12 |
72
+ | W0100 | 8 | 7 |
73
+ | W0629 | 1 | 12 |
74
+ | W0628 | 1 | 12 |
@@ -26,6 +26,7 @@ Feature: W0801
26
26
  When I successfully run `adlint fixture.c` on noarch
27
27
  Then the output should exactly match with:
28
28
  | mesg | line | column |
29
+ | W0040 | 1 | 8 |
29
30
  | W0801 | 1 | 8 |
30
31
 
31
32
  Scenario: named member exists in the struct
@@ -65,6 +66,7 @@ Feature: W0801
65
66
  When I successfully run `adlint fixture.c` on noarch
66
67
  Then the output should exactly match with:
67
68
  | mesg | line | column |
69
+ | W0040 | 1 | 7 |
68
70
  | W0551 | 1 | 7 |
69
71
  | W0801 | 1 | 7 |
70
72
 
@@ -170,7 +170,7 @@ module Cc1 #:nodoc:
170
170
  head_idx = @lst_toks.rindex { |tok| keys.include?(tok.type) }
171
171
 
172
172
  if head_idx
173
- toks = @lst_toks[(head_idx + 1)..-1]
173
+ toks = @lst_toks.drop(head_idx + 1)
174
174
  case toks.size
175
175
  when 1
176
176
  patch_identifier_translation_mode1(*toks)
@@ -447,10 +447,18 @@ module Cc1 #:nodoc:
447
447
  # TODO: If linear searching is too slow, use an index of inner
448
448
  # variables.
449
449
  target_name = CompositeMemberVariable.component_name_of(name)
450
- @inner_variables.find { |inner| inner.component_name == target_name }
451
- else
452
- nil
450
+ @inner_variables.each do |inner|
451
+ case
452
+ when inner.component_name.nil?
453
+ if var = inner.inner_variable_named(name)
454
+ return var
455
+ end
456
+ when inner.component_name == target_name
457
+ return inner
458
+ end
459
+ end
453
460
  end
461
+ nil
454
462
  end
455
463
 
456
464
  private
@@ -619,10 +627,11 @@ module Cc1 #:nodoc:
619
627
  private
620
628
  def create_qualified_name(outer_var, component_name)
621
629
  if outer_var.named?
622
- "#{outer_var.name}#{component_name}"
630
+ prefix = outer_var.name
623
631
  else
624
- "__adlint__tempvar#{component_name}"
632
+ prefix = "__adlint__tempvar"
625
633
  end
634
+ component_name ? "#{prefix}#{component_name}" : prefix
626
635
  end
627
636
  end
628
637
 
@@ -638,7 +647,7 @@ module Cc1 #:nodoc:
638
647
 
639
648
  class CompositeMemberVariable < InnerVariable
640
649
  def self.component_name_of(name)
641
- ".#{name}"
650
+ name ? ".#{name}" : nil
642
651
  end
643
652
 
644
653
  def initialize(mem, outer_var, type, name)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.10
3
+ # This file is automatically generated by Racc 1.4.11
4
4
  # from Racc grammer file "".
5
5
  #
6
6
 
@@ -69,16 +69,18 @@ module Cc1 #:nodoc:
69
69
  def visit_member_declaration(node)
70
70
  checkpoint(node.location)
71
71
  node.specifier_qualifier_list.accept(self)
72
- node.struct_declarator.accept(self)
72
+ node.struct_declarator.accept(self) if node.struct_declarator
73
73
 
74
74
  type_quals = node.specifier_qualifier_list.type_qualifiers
75
75
  type_specs = node.specifier_qualifier_list.type_specifiers
76
+ struct_dcr = node.struct_declarator
77
+
76
78
  type = lookup_variable_type(type_quals, type_specs,
77
- node.struct_declarator.declarator)
79
+ struct_dcr ? struct_dcr.declarator : nil)
78
80
  type = @type_table.pointer_type(type) if type.function?
79
81
 
80
- if node.struct_declarator.bitfield?
81
- if bit_width = compute_bitfield_width(node.struct_declarator)
82
+ if struct_dcr and struct_dcr.bitfield?
83
+ if bit_width = compute_bitfield_width(struct_dcr)
82
84
  type = @type_table.bitfield_type(type, bit_width)
83
85
  else
84
86
  type = fallback_type
@@ -2867,10 +2867,14 @@ module Cc1 #:nodoc:
2867
2867
 
2868
2868
  private
2869
2869
  def build_items(spec_qual_list, struct_dcrs)
2870
- struct_dcrs.each_with_object([]) do |struct_dcr, items|
2871
- # FIXME: Must support unnamed bit padding.
2872
- next unless struct_dcr.declarator
2873
- items.push(MemberDeclaration.new(spec_qual_list, struct_dcr))
2870
+ # FIXME: Must support unnamed bit padding.
2871
+
2872
+ if struct_dcrs.empty?
2873
+ [MemberDeclaration.new(spec_qual_list, nil)]
2874
+ else
2875
+ struct_dcrs.map do |struct_dcr|
2876
+ MemberDeclaration.new(spec_qual_list, struct_dcr)
2877
+ end
2874
2878
  end
2875
2879
  end
2876
2880
  end
@@ -2888,20 +2892,35 @@ module Cc1 #:nodoc:
2888
2892
  attr_accessor :type
2889
2893
 
2890
2894
  def identifier
2891
- @struct_declarator.declarator.identifier
2895
+ if @struct_declarator && @struct_declarator.declarator
2896
+ @struct_declarator.declarator.identifier
2897
+ else
2898
+ nil
2899
+ end
2892
2900
  end
2893
2901
 
2894
2902
  def location
2895
- identifier.location
2903
+ case
2904
+ when @struct_declarator && @struct_declarator.declarator
2905
+ @struct_declarator.declarator.identifier.location
2906
+ when @struct_declarator
2907
+ @struct_declarator.head_location
2908
+ else
2909
+ @specifier_qualifier_list.head_location
2910
+ end
2896
2911
  end
2897
2912
 
2898
2913
  def to_s
2899
- "#{type.brief_image} #{identifier.value}"
2914
+ if id = identifier
2915
+ "#{type.brief_image} #{id.value}"
2916
+ else
2917
+ type.brief_image
2918
+ end
2900
2919
  end
2901
2920
 
2902
2921
  def inspect(indent = 0)
2903
2922
  " " * indent + "#{short_class_name} (#{location.inspect}) " +
2904
- identifier.value
2923
+ ((id = identifier) ? id.value : "")
2905
2924
  end
2906
2925
  end
2907
2926
 
@@ -6306,7 +6306,17 @@ module Cc1 #:nodoc:
6306
6306
 
6307
6307
  def member_named(name)
6308
6308
  # FIXME: Should use the member name index.
6309
- @members.find { |memb| memb.name == name }
6309
+ @members.each do |memb|
6310
+ case
6311
+ when memb.name.nil? && memb.type.composite?
6312
+ if inner_memb = memb.type.member_named(name)
6313
+ return inner_memb
6314
+ end
6315
+ when memb.name == name
6316
+ return memb
6317
+ end
6318
+ end
6319
+ nil
6310
6320
  end
6311
6321
 
6312
6322
  def min
@@ -6691,6 +6701,10 @@ module Cc1 #:nodoc:
6691
6701
  attr_reader :name
6692
6702
  attr_reader :type
6693
6703
 
6704
+ def named?
6705
+ !@name.nil?
6706
+ end
6707
+
6694
6708
  def dup
6695
6709
  Member.new(@name, @type.dup)
6696
6710
  end
@@ -7584,16 +7598,6 @@ module Cc1 #:nodoc:
7584
7598
  end
7585
7599
  end
7586
7600
 
7587
- def create_members(struct_dcls)
7588
- membs = []
7589
- struct_dcls.each do |struct_dcl|
7590
- struct_dcl.items.each do |item|
7591
- membs.push(Member.new(item.identifier.value, item.type))
7592
- end
7593
- end
7594
- membs
7595
- end
7596
-
7597
7601
  def rewrite_struct_type(struct_type, type_dcl)
7598
7602
  struct_type.declarations.push(type_dcl)
7599
7603
  struct_type.image = type_dcl.struct_specifier.to_s
@@ -7608,6 +7612,14 @@ module Cc1 #:nodoc:
7608
7612
  union_type.members.replace(create_members(type_dcl.struct_declarations))
7609
7613
  end
7610
7614
 
7615
+ def create_members(struct_dcls)
7616
+ struct_dcls.map { |struct_dcl|
7617
+ struct_dcl.items.map do |item|
7618
+ Member.new(item.identifier ? item.identifier.value : nil, item.type)
7619
+ end
7620
+ }.flatten
7621
+ end
7622
+
7611
7623
  def rewrite_enum_type(enum_type, type_dcl)
7612
7624
  enum_type.declarations.push(type_dcl)
7613
7625
  enum_type.image = type_dcl.enum_specifier.to_s
@@ -2756,7 +2756,7 @@ module Cc1 #:nodoc:
2756
2756
  end
2757
2757
 
2758
2758
  def active_versioning_groups
2759
- @versioning_group_stack[1..-1]
2759
+ @versioning_group_stack.drop(1)
2760
2760
  end
2761
2761
 
2762
2762
  def current_versioning_group
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.10
3
+ # This file is automatically generated by Racc 1.4.11
4
4
  # from Racc grammer file "".
5
5
  #
6
6
 
@@ -994,7 +994,7 @@ module Cpp #:nodoc:
994
994
 
995
995
  # NOTE: It's not completed when a new-line appears after the macro
996
996
  # name.
997
- return false unless pp_toks[idx..-1].any? { |t| t.value == "(" }
997
+ return false unless pp_toks.drop(idx).any? { |t| t.value == "(" }
998
998
 
999
999
  paren_cnt = 0
1000
1000
  while tok = pp_toks[idx]
@@ -738,7 +738,7 @@ module Cpp #:nodoc:
738
738
  return nil unless tok = toks[idx] and macro = lookup(tok.value)
739
739
  return nil if repl_ctxt.hidden?(tok, macro.name.value)
740
740
 
741
- size = macro.replaceable_size(toks[idx..-1])
741
+ size = macro.replaceable_size(toks.drop(idx))
742
742
 
743
743
  if toks[idx, size].all? { |t| t.need_no_further_replacement? }
744
744
  return nil
@@ -81,7 +81,7 @@ module Cpp #:nodoc:
81
81
  end
82
82
 
83
83
  def rest_pattern_tokens
84
- @pattern_tokens[@pattern_index..-1]
84
+ @pattern_tokens.drop(@pattern_index)
85
85
  end
86
86
 
87
87
  def next_pattern_token
data/lib/adlint/exam.rb CHANGED
@@ -127,6 +127,7 @@ module AdLint #:nodoc:
127
127
  class ExaminationCatalog
128
128
  def initialize(loader_fpath)
129
129
  @loader_fpath = loader_fpath
130
+ @initializer = lambda {}
130
131
  yield(self) if block_given?
131
132
  end
132
133
 
@@ -136,6 +137,7 @@ module AdLint #:nodoc:
136
137
  attr_accessor :patch_version
137
138
  attr_accessor :release_date
138
139
  attr_accessor :examination_classes
140
+ attr_accessor :initializer
139
141
 
140
142
  def short_version
141
143
  "#{major_version}.#{minor_version}.#{patch_version}"
@@ -161,6 +163,7 @@ module AdLint #:nodoc:
161
163
 
162
164
  def load
163
165
  require "adlint/exam/#{@name}"
166
+ catalog.initializer.call
164
167
  true
165
168
  rescue LoadError
166
169
  false
@@ -269,7 +269,7 @@ module CBuiltin #:nodoc:
269
269
  if fmt_str_idx
270
270
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
271
271
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
272
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
272
+ args = arg_vars.drop(fmt_str_idx + 1) || []
273
273
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
274
274
  end
275
275
  end
@@ -315,7 +315,7 @@ module CBuiltin #:nodoc:
315
315
  if fmt_str_idx
316
316
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
317
317
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
318
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
318
+ args = arg_vars.drop(fmt_str_idx + 1) || []
319
319
  return Cc1::ScanfFormat.new($1, fmt_str.location, args, env)
320
320
  end
321
321
  end
@@ -361,7 +361,7 @@ module CBuiltin #:nodoc:
361
361
  if fmt_str_idx
362
362
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
363
363
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
364
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
364
+ args = arg_vars.drop(fmt_str_idx + 1) || []
365
365
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
366
366
  end
367
367
  end
@@ -1593,15 +1593,20 @@ module CBuiltin #:nodoc:
1593
1593
 
1594
1594
  private
1595
1595
  def check_member_access(expr, outer_var, inner_var)
1596
- type = outer_var.type
1597
- unqual_type = type.unqualify
1598
-
1599
- if type.pointer? && unqual_type.base_type.incomplete? or
1600
- type.composite? && type.incomplete?
1596
+ case expr
1597
+ when Cc1::MemberAccessByValueExpression
1598
+ outer_type = outer_var.type.unqualify
1599
+ when Cc1::MemberAccessByPointerExpression
1600
+ outer_type = outer_var.type.unqualify.base_type
1601
+ else
1601
1602
  return
1602
1603
  end
1603
1604
 
1604
- W(expr.location) unless inner_var
1605
+ if outer_type.composite? && !outer_type.incomplete?
1606
+ unless outer_type.member_named(expr.identifier.value)
1607
+ W(expr.location)
1608
+ end
1609
+ end
1605
1610
  end
1606
1611
  end
1607
1612
 
@@ -8216,7 +8221,7 @@ module CBuiltin #:nodoc:
8216
8221
  if enums = node.enum_specifier.enumerators
8217
8222
  exprs = enums.map { |enum| enum.expression }
8218
8223
  return if exprs.all? { |expr| expr.nil? }
8219
- return if exprs.first && exprs[1..-1].all? { |expr| expr.nil? }
8224
+ return if exprs.first && exprs.drop(1).all? { |expr| expr.nil? }
8220
8225
  return if exprs.all? { |expr| !expr.nil? }
8221
8226
  W(node.location)
8222
8227
  end
@@ -10484,7 +10489,7 @@ module CBuiltin #:nodoc:
10484
10489
  def declare_members(struct_or_union_dcl)
10485
10490
  memb_dcls = MemberExtractor.new.tap { |extr|
10486
10491
  struct_or_union_dcl.accept(extr)
10487
- }.result
10492
+ }.result.select { |memb| !memb.identifier.nil? }
10488
10493
 
10489
10494
  memb_dcls.each do |memb_dcl|
10490
10495
  pair_names =
@@ -12139,8 +12144,11 @@ module CBuiltin #:nodoc:
12139
12144
  private
12140
12145
  def check(node)
12141
12146
  return unless node.type.scalar? && node.type.integer?
12142
- if node.type.bitfield? && node.type.signed? && node.type.bit_size == 1
12143
- W(node.location)
12147
+
12148
+ if node.identifier
12149
+ if node.type.bitfield? && node.type.signed? && node.type.bit_size == 1
12150
+ W(node.location)
12151
+ end
12144
12152
  end
12145
12153
  end
12146
12154
  end
@@ -12520,7 +12528,7 @@ module CBuiltin #:nodoc:
12520
12528
  }
12521
12529
 
12522
12530
  if params.size > 1
12523
- params.first.zip(*params[1..-1]) do |names|
12531
+ params.first.zip(*params.drop(1)) do |names|
12524
12532
  unless names.tap { |ary| ary.delete("") }.uniq.size == 1
12525
12533
  W(node.location)
12526
12534
  break
@@ -13378,7 +13386,7 @@ module CBuiltin #:nodoc:
13378
13386
  if fmt_str_idx
13379
13387
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
13380
13388
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
13381
- trailing_args = arg_vars[(fmt_str_idx + 1)..-1] || []
13389
+ trailing_args = arg_vars.drop(fmt_str_idx + 1) || []
13382
13390
  return Cc1::ScanfFormat.new($1, fmt_str.location, trailing_args, env)
13383
13391
  end
13384
13392
  end
@@ -14863,7 +14871,7 @@ module CBuiltin #:nodoc:
14863
14871
  if fmt_str_idx
14864
14872
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
14865
14873
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
14866
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
14874
+ args = arg_vars.drop(fmt_str_idx + 1) || []
14867
14875
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
14868
14876
  end
14869
14877
  end
@@ -14912,7 +14920,7 @@ module CBuiltin #:nodoc:
14912
14920
  if fmt_str_idx
14913
14921
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
14914
14922
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
14915
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
14923
+ args = arg_vars.drop(fmt_str_idx + 1) || []
14916
14924
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
14917
14925
  end
14918
14926
  end
@@ -14961,7 +14969,7 @@ module CBuiltin #:nodoc:
14961
14969
  if fmt_str_idx
14962
14970
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
14963
14971
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
14964
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
14972
+ args = arg_vars.drop(fmt_str_idx + 1) || []
14965
14973
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
14966
14974
  end
14967
14975
  end
@@ -15037,7 +15045,7 @@ module CBuiltin #:nodoc:
15037
15045
  if fmt_str_idx
15038
15046
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15039
15047
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15040
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15048
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15041
15049
  return Cc1::ScanfFormat.new($1, fmt_str.location, args, env)
15042
15050
  end
15043
15051
  end
@@ -15090,7 +15098,7 @@ module CBuiltin #:nodoc:
15090
15098
  if fmt_str_idx
15091
15099
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15092
15100
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15093
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15101
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15094
15102
  return Cc1::ScanfFormat.new($1, fmt_str.location, args, env)
15095
15103
  end
15096
15104
  end
@@ -15404,7 +15412,7 @@ module CBuiltin #:nodoc:
15404
15412
  if fmt_str_idx
15405
15413
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15406
15414
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15407
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15415
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15408
15416
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
15409
15417
  end
15410
15418
  end
@@ -15457,7 +15465,7 @@ module CBuiltin #:nodoc:
15457
15465
  if fmt_str_idx
15458
15466
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15459
15467
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15460
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15468
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15461
15469
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
15462
15470
  end
15463
15471
  end
@@ -15688,7 +15696,7 @@ module CBuiltin #:nodoc:
15688
15696
  if fmt_str_idx
15689
15697
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15690
15698
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15691
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15699
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15692
15700
  return Cc1::PrintfFormat.new($1, fmt_str.location, args, env)
15693
15701
  end
15694
15702
  end
@@ -15735,7 +15743,7 @@ module CBuiltin #:nodoc:
15735
15743
  if fmt_str_idx
15736
15744
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15737
15745
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15738
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15746
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15739
15747
  return Cc1::ScanfFormat.new($1, fmt_str.location, args, env)
15740
15748
  end
15741
15749
  end
@@ -15788,7 +15796,7 @@ module CBuiltin #:nodoc:
15788
15796
  if fmt_str_idx
15789
15797
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15790
15798
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15791
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15799
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15792
15800
  return Cc1::ScanfFormat.new($1, fmt_str.location, args, env)
15793
15801
  end
15794
15802
  end
@@ -15954,7 +15962,7 @@ module CBuiltin #:nodoc:
15954
15962
  if fmt_str_idx
15955
15963
  fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
15956
15964
  if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
15957
- args = arg_vars[(fmt_str_idx + 1)..-1] || []
15965
+ args = arg_vars.drop(fmt_str_idx + 1) || []
15958
15966
  return Cc1::ScanfFormat.new($1, fmt_str.location, args, env)
15959
15967
  end
15960
15968
  end
@@ -19969,7 +19977,7 @@ module CBuiltin #:nodoc:
19969
19977
 
19970
19978
  private
19971
19979
  def check(node)
19972
- W(node.location) if node.type.members.empty?
19980
+ W(node.location) if node.type.members.none? { |memb| memb.named? }
19973
19981
  end
19974
19982
  end
19975
19983
 
@@ -20800,7 +20808,7 @@ module CBuiltin #:nodoc:
20800
20808
  fmt_arg = expr.argument_expressions[fmt_idx]
20801
20809
  if fmt_arg && fmt_arg.literal.value =~ /\AL?"(.*)"\z/i
20802
20810
  loc = fmt_arg.location
20803
- args = arg_vars[(fmt_idx + 1)..-1] || []
20811
+ args = arg_vars.drop(fmt_idx + 1) || []
20804
20812
  return Cc1::PrintfFormat.new($1, loc, args, @environ)
20805
20813
  end
20806
20814
  end
@@ -20812,7 +20820,7 @@ module CBuiltin #:nodoc:
20812
20820
  fmt_arg = expr.argument_expressions[fmt_idx]
20813
20821
  if fmt_arg && fmt_arg.literal.value =~ /\AL?"(.*)"\z/i
20814
20822
  loc = fmt_arg.location
20815
- args = arg_vars[(fmt_idx + 1)..-1] || []
20823
+ args = arg_vars.drop(fmt_idx + 1) || []
20816
20824
  return Cc1::ScanfFormat.new($1, loc, args, @environ)
20817
20825
  end
20818
20826
  end
@@ -150,16 +150,17 @@ module Ld #:nodoc:
150
150
  def execute(met_fpath)
151
151
  sma_wd = Pathname.pwd
152
152
  CSV.foreach(met_fpath) do |csv_row|
153
- rec = MetricRecord.of(csv_row, sma_wd)
154
- case
155
- when rec.version?
156
- sma_wd = Pathname.new(rec.exec_working_directory)
157
- when rec.variable_definition?
158
- if rec.variable_linkage_type == "X"
159
- @map.add_variable(Variable.new(rec))
153
+ if rec = MetricRecord.of(csv_row, sma_wd)
154
+ case
155
+ when rec.version?
156
+ sma_wd = Pathname.new(rec.exec_working_directory)
157
+ when rec.variable_definition?
158
+ if rec.variable_linkage_type == "X"
159
+ @map.add_variable(Variable.new(rec))
160
+ end
161
+ when rec.global_variable_declaration?
162
+ @map.add_variable_declaration(VariableDeclaration.new(rec))
160
163
  end
161
- when rec.global_variable_declaration?
162
- @map.add_variable_declaration(VariableDeclaration.new(rec))
163
164
  end
164
165
  end
165
166
  end
@@ -308,14 +309,15 @@ module Ld #:nodoc:
308
309
  def execute(met_fpath)
309
310
  sma_wd = Pathname.pwd
310
311
  CSV.foreach(met_fpath) do |csv_row|
311
- rec = MetricRecord.of(csv_row, sma_wd)
312
- case
313
- when rec.version?
314
- sma_wd = Pathname.new(rec.exec_working_directory)
315
- when rec.function_definition?
316
- @map.add_function(Function.new(rec))
317
- when rec.function_declaration?
318
- @map.add_function_declaration(FunctionDeclaration.new(rec))
312
+ if rec = MetricRecord.of(csv_row, sma_wd)
313
+ case
314
+ when rec.version?
315
+ sma_wd = Pathname.new(rec.exec_working_directory)
316
+ when rec.function_definition?
317
+ @map.add_function(Function.new(rec))
318
+ when rec.function_declaration?
319
+ @map.add_function_declaration(FunctionDeclaration.new(rec))
320
+ end
319
321
  end
320
322
  end
321
323
  end
@@ -490,23 +492,27 @@ module Ld #:nodoc:
490
492
  def execute(met_fpath)
491
493
  sma_wd = Pathname.pwd
492
494
  CSV.foreach(met_fpath) do |csv_row|
493
- rec = MetricRecord.of(csv_row, sma_wd)
494
- case
495
- when rec.version?
496
- sma_wd = Pathname.new(rec.exec_working_directory)
497
- when rec.variable_xref?
498
- var = @var_map.lookup_variables(rec.accessee_variable).first
499
- fun_id = rec.accessor_function
500
- if fun_id.named?
501
- fun = @fun_map.lookup_functions(fun_id.name).first
502
- ref = ObjectReferrer.of_function(fun)
503
- else
504
- ref = ObjectReferrer.of_ctors_section(rec.location)
495
+ if rec = MetricRecord.of(csv_row, sma_wd)
496
+ case
497
+ when rec.version?
498
+ sma_wd = Pathname.new(rec.exec_working_directory)
499
+ when rec.variable_xref?
500
+ if var = @var_map.lookup_variables(rec.accessee_variable).first
501
+ fun_id = rec.accessor_function
502
+ if fun_id.named?
503
+ fun = @fun_map.lookup_functions(fun_id.name).first
504
+ ref = ObjectReferrer.of_function(fun)
505
+ else
506
+ ref = ObjectReferrer.of_ctors_section(rec.location)
507
+ end
508
+ @graph.add(ObjectReference.new(ref, var, rec.location))
509
+ end
510
+ when rec.function_xref?
511
+ ref, fun = lookup_referrer_and_function_by_xref(rec)
512
+ if ref && fun
513
+ @graph.add(ObjectReference.new(ref, fun, rec.location))
514
+ end
505
515
  end
506
- @graph.add(ObjectReference.new(ref, var, rec.location)) if var
507
- when rec.function_xref?
508
- ref, fun = lookup_referrer_and_function_by_xref(rec)
509
- @graph.add(ObjectReference.new(ref, fun, rec.location)) if ref && fun
510
516
  end
511
517
  end
512
518
  end
@@ -614,14 +620,15 @@ module Ld #:nodoc:
614
620
  def execute(met_fpath)
615
621
  sma_wd = Pathname.pwd
616
622
  CSV.foreach(met_fpath) do |csv_row|
617
- rec = MetricRecord.of(csv_row, sma_wd)
618
- case
619
- when rec.version?
620
- sma_wd = Pathname.new(rec.exec_working_directory)
621
- when rec.function_call?
622
- caller_ref, callee_fun = lookup_functions_by_call(rec)
623
- if caller_ref && callee_fun
624
- @graph.add(FunctionCall.new(caller_ref, callee_fun))
623
+ if rec = MetricRecord.of(csv_row, sma_wd)
624
+ case
625
+ when rec.version?
626
+ sma_wd = Pathname.new(rec.exec_working_directory)
627
+ when rec.function_call?
628
+ caller_ref, callee_fun = lookup_functions_by_call(rec)
629
+ if caller_ref && callee_fun
630
+ @graph.add(FunctionCall.new(caller_ref, callee_fun))
631
+ end
625
632
  end
626
633
  end
627
634
  end
@@ -91,12 +91,13 @@ module Ld #:nodoc:
91
91
  def execute(met_fpath)
92
92
  sma_wd = Pathname.pwd
93
93
  CSV.foreach(met_fpath) do |csv_row|
94
- rec = MetricRecord.of(csv_row, sma_wd)
95
- case
96
- when rec.version?
97
- sma_wd = Pathname.new(rec.exec_working_directory)
98
- when rec.typedef_declaration?
99
- @map.add(Typedef.new(rec.type_name, rec.location))
94
+ if rec = MetricRecord.of(csv_row, sma_wd)
95
+ case
96
+ when rec.version?
97
+ sma_wd = Pathname.new(rec.exec_working_directory)
98
+ when rec.typedef_declaration?
99
+ @map.add(Typedef.new(rec.type_name, rec.location))
100
+ end
100
101
  end
101
102
  end
102
103
  end
data/lib/adlint/metric.rb CHANGED
@@ -190,7 +190,11 @@ module AdLint #:nodoc:
190
190
  when "MET"
191
191
  create_metric_record(csv_row, sma_wd)
192
192
  else
193
- raise "invalid metric record."
193
+ # NOTE: Silently ignore unknown records so that an optional examination
194
+ # package may output its own special ones.
195
+ #
196
+ #raise "invalid metric record."
197
+ nil
194
198
  end
195
199
  end
196
200
 
@@ -33,8 +33,8 @@ module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 3
35
35
  MINOR_VERSION = 2
36
- PATCH_VERSION = 10
37
- RELEASE_DATE = "2014-02-17"
36
+ PATCH_VERSION = 12
37
+ RELEASE_DATE = "2014-04-12"
38
38
 
39
39
  TRAITS_SCHEMA_VERSION = "3.0.0"
40
40
 
Binary file
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 3.2.10 開発者ガイド</title>
3
+ <title>AdLint 3.2.12 開発者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 3.2.10 開発者ガイド">
5
+ <meta name="description" content="AdLint 3.2.12 開発者ガイド">
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 3.2.10 開発者ガイド</h1>
47
+ <h1 class="settitle">AdLint 3.2.12 開発者ガイド</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 3.2.10 開発者ガイド
5
+ @settitle AdLint 3.2.12 開発者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2014, OGIS-RI Co.,Ltd.
@@ -1,8 +1,8 @@
1
1
  <html lang="en">
2
2
  <head>
3
- <title>AdLint 3.2.10 User's Guide</title>
3
+ <title>AdLint 3.2.12 User's Guide</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 3.2.10 User's Guide">
5
+ <meta name="description" content="AdLint 3.2.12 User's Guide">
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 3.2.10 User's Guide</h1>
47
+ <h1 class="settitle">AdLint 3.2.12 User's Guide</h1>
48
48
  <div class="node">
49
49
  <a name="Top"></a>
50
50
  <p><hr>
@@ -2,7 +2,7 @@
2
2
  @setfilename users_guide_en.info
3
3
  @documentlanguage en
4
4
  @documentencoding utf-8
5
- @settitle AdLint 3.2.10 User's Guide
5
+ @settitle AdLint 3.2.12 User's Guide
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2014, OGIS-RI Co.,Ltd.
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 3.2.10 利用者ガイド</title>
3
+ <title>AdLint 3.2.12 利用者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 3.2.10 利用者ガイド">
5
+ <meta name="description" content="AdLint 3.2.12 利用者ガイド">
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 3.2.10 利用者ガイド</h1>
47
+ <h1 class="settitle">AdLint 3.2.12 利用者ガイド</h1>
48
48
  <div class="node">
49
49
  <a name="Top"></a>
50
50
  <p><hr>
@@ -2,7 +2,7 @@
2
2
  @setfilename users_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 3.2.10 利用者ガイド
5
+ @settitle AdLint 3.2.12 利用者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2014, OGIS-RI Co.,Ltd.
@@ -591,7 +591,7 @@ module Cc1
591
591
  private
592
592
  def comma_separated_expression(*exprs)
593
593
  CommaSeparatedExpression.new(exprs.first).tap do |obj|
594
- exprs[1..-1].each { |expr| obj.push(expr) }
594
+ exprs.drop(1).each { |expr| obj.push(expr) }
595
595
  end
596
596
  end
597
597
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.10
4
+ version: 3.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka Yanoh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-17 00:00:00.000000000 Z
11
+ date: 2014-04-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  AdLint is a source code static analyzer.
@@ -82,6 +82,7 @@ files:
82
82
  - features/code_check/W0024.feature
83
83
  - features/code_check/W0025.feature
84
84
  - features/code_check/W0026.feature
85
+ - features/code_check/W0067.feature
85
86
  - features/code_check/W0070.feature
86
87
  - features/code_check/W0071.feature
87
88
  - features/code_check/W0088.feature
@@ -879,25 +880,25 @@ post_install_message: |
879
880
 
880
881
  -------------------------------------------------------------------------------
881
882
  rdoc_options:
882
- - --main
883
+ - "--main"
883
884
  - README
884
- - --charset
885
+ - "--charset"
885
886
  - utf-8
886
887
  require_paths:
887
888
  - lib
888
889
  required_ruby_version: !ruby/object:Gem::Requirement
889
890
  requirements:
890
- - - '>='
891
+ - - ">="
891
892
  - !ruby/object:Gem::Version
892
893
  version: 1.9.3
893
894
  required_rubygems_version: !ruby/object:Gem::Requirement
894
895
  requirements:
895
- - - '>='
896
+ - - ">="
896
897
  - !ruby/object:Gem::Version
897
898
  version: '0'
898
899
  requirements: []
899
900
  rubyforge_project:
900
- rubygems_version: 2.0.14
901
+ rubygems_version: 2.2.2
901
902
  signing_key:
902
903
  specification_version: 4
903
904
  summary: 'AdLint :: Advanced Lint - An open source and free source code static analyzer'