adlint 1.6.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -41,7 +41,7 @@ require "adlint/cpp/util"
41
41
  module AdLint #:nodoc:
42
42
  module Cpp #:nodoc:
43
43
 
44
- class PreparePhase < Phase
44
+ class Prepare1Phase < Phase
45
45
  private
46
46
  def do_execute(context)
47
47
  monitored_region("pr1") do
@@ -50,7 +50,14 @@ module Cpp #:nodoc:
50
50
  context[:cpp_macro_table] = MacroTable.new
51
51
  context[:cpp_interpreter] = Preprocessor.new
52
52
  context[:cpp_visitor] = SyntaxTreeMulticastVisitor.new
53
+ end
54
+ end
55
+ end
53
56
 
57
+ class Prepare2Phase < Phase
58
+ private
59
+ def do_execute(context)
60
+ monitored_region("pr2") do
54
61
  context[:cpp_commands] =
55
62
  setup_code_extractions(context) + setup_message_detections(context)
56
63
  end
@@ -101,6 +108,9 @@ module Cpp #:nodoc:
101
108
  W0575.new(context),
102
109
  W0576.new(context),
103
110
  W0577.new(context),
111
+ W0632.new(context),
112
+ W0633.new(context),
113
+ W0634.new(context),
104
114
  W0687.new(context),
105
115
  W0688.new(context),
106
116
  W0689.new(context),
@@ -112,6 +122,7 @@ module Cpp #:nodoc:
112
122
  W0807.new(context),
113
123
  W0808.new(context),
114
124
  W0831.new(context),
125
+ W0832.new(context),
115
126
  W9002.new(context)
116
127
  ]
117
128
  end
@@ -94,8 +94,8 @@ module Cpp #:nodoc:
94
94
  private
95
95
  def create_extension_substitution(pattern, replacement)
96
96
  CodeSubstitution.new(pattern, replacement).tap do |subst|
97
- subst.on_substitution += lambda { |location, matched|
98
- on_language_extension.invoke(location, matched)
97
+ subst.on_substitution += lambda { |matched_tokens|
98
+ on_language_extension.invoke(matched_tokens)
99
99
  }
100
100
  end
101
101
  end
@@ -68,10 +68,8 @@ module Cpp #:nodoc:
68
68
 
69
69
  private
70
70
  def notify_substitution(tokens, index, length)
71
- matched = tokens[index, length].map { |token|
72
- token.type == :NEW_LINE ? nil : token.value
73
- }.compact.join(" ")
74
- on_substitution.invoke(tokens[index].location, matched)
71
+ matched_tokens = tokens[index, length]
72
+ on_substitution.invoke(matched_tokens) unless matched_tokens.empty?
75
73
  end
76
74
  end
77
75
 
data/lib/adlint/lang.rb CHANGED
@@ -68,12 +68,14 @@ module AdLint #:nodoc:
68
68
  class << self
69
69
  def single_module_phases
70
70
  [
71
- AdLint::Cpp::PreparePhase,
71
+ AdLint::Cpp::Prepare1Phase,
72
+ AdLint::C::Prepare1Phase,
73
+ AdLint::Cpp::Prepare2Phase,
72
74
  AdLint::Cpp::EvalPhase,
73
75
  AdLint::Cpp::SubstPhase,
74
76
  AdLint::C::ParsePhase,
75
77
  AdLint::C::ResolvePhase,
76
- AdLint::C::PreparePhase,
78
+ AdLint::C::Prepare2Phase,
77
79
  AdLint::C::InterpPhase,
78
80
  AdLint::Cpp::ReviewPhase,
79
81
  AdLint::C::ReviewPhase,
@@ -84,7 +86,7 @@ module AdLint #:nodoc:
84
86
 
85
87
  def check_phases
86
88
  [
87
- AdLint::Cpp::PreparePhase,
89
+ AdLint::Cpp::Prepare1Phase,
88
90
  AdLint::Cpp::EvalPhase,
89
91
  AdLint::Cpp::SubstPhase,
90
92
  AdLint::C::ParsePhase
@@ -48,7 +48,7 @@ module Ld #:nodoc:
48
48
 
49
49
  def measure(function)
50
50
  call_graph = @context[:ld_function_call_graph]
51
- FN_CALL(FunctionIdentifier.new(function.name, function.signature.to_s),
51
+ FN_CALL(FunctionIdentifier.new(function.name, function.signature),
52
52
  function.location, call_graph.all_callers_of(function).size)
53
53
  end
54
54
  end
@@ -32,9 +32,9 @@
32
32
  module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 1
35
- MINOR_VERSION = 6
35
+ MINOR_VERSION = 8
36
36
  PATCH_VERSION = 0
37
- RELEASE_DATE = "2012-04-06"
37
+ RELEASE_DATE = "2012-04-27"
38
38
 
39
39
  TRAITS_SCHEMA_VERSION = "1.0.0"
40
40
 
data/share/demo/Makefile CHANGED
@@ -9,6 +9,7 @@ bad_comment \
9
9
  bad_const \
10
10
  bad_conv \
11
11
  bad_enum \
12
+ bad_include \
12
13
  bad_indent \
13
14
  bad_init \
14
15
  bad_label \
@@ -31,6 +32,7 @@ id_hiding \
31
32
  ill_defined \
32
33
  implicit_conv \
33
34
  implicit_int \
35
+ incomplete_ifelse \
34
36
  incomplete_type \
35
37
  indirect_recur \
36
38
  inline_asm \
@@ -39,6 +41,7 @@ invalid_call \
39
41
  kandr_fundef \
40
42
  line_comment \
41
43
  local_decl \
44
+ logical_expr \
42
45
  logical_trick \
43
46
  long_sym \
44
47
  loop_var \
@@ -63,6 +66,7 @@ output_by_param \
63
66
  overflow \
64
67
  press_release \
65
68
  redundant_select \
69
+ register_vars \
66
70
  reserved_ident \
67
71
  retn_lvar_addr \
68
72
  sequence_point \
@@ -71,6 +75,7 @@ should_be_typedef \
71
75
  static_paths \
72
76
  static_vars \
73
77
  tag_hiding \
78
+ typedef_each_src \
74
79
  tricky_incdec \
75
80
  undefined_macro \
76
81
  uninit_vars \
@@ -0,0 +1,13 @@
1
+ #include <test'1'.h>
2
+ /*#include <test"1".h>*/
3
+
4
+ #include "test'2'.h"
5
+ #include ".\test'2'.h"
6
+ #include ".\\test'2'.h"
7
+
8
+ #include_next <test'1'.h>
9
+ /*#include_next <test"1".h>*/
10
+
11
+ #include_next "test'2'.h"
12
+ #include_next ".\test'2'.h"
13
+ #include_next ".\\test'2'.h"
File without changes
File without changes
@@ -0,0 +1,29 @@
1
+ int foo(const int i)
2
+ {
3
+ int j;
4
+
5
+ if (i == 0) {
6
+ j = 0;
7
+ }
8
+
9
+ if (i == 1) {
10
+ j = 1;
11
+ }
12
+ else if (i == 2) {
13
+ j = 2;
14
+ }
15
+
16
+ if (i > 2) {
17
+ if (i == 5) {
18
+ j = 5;
19
+ }
20
+ else if (i == 6) {
21
+ j = 6;
22
+ }
23
+ }
24
+ else if (i < 0) {
25
+ j = -1;
26
+ }
27
+
28
+ return j;
29
+ }
@@ -1,6 +1,7 @@
1
1
  void foo(int arg1, int *arg2, int arg3)
2
2
  {
3
3
  asm("movl %ecx, %eax");
4
+
4
5
  __asm__("movl %ecx, (%eax)");
5
6
 
6
7
  asm {
@@ -16,3 +17,27 @@ void foo(int arg1, int *arg2, int arg3)
16
17
  : "a" (128)
17
18
  : "memory", "cc");
18
19
  }
20
+
21
+ #define ASM1 asm("movl %ecx, %eax");
22
+
23
+ #define ASM2 __asm__("movl %ecx, (%eax)");
24
+
25
+ #define ASM3 asm { xorl eax, eax }
26
+
27
+ #define ASM4(arg1, arg2, arg3) \
28
+ __asm__ volatile ( \
29
+ "int $0x80" \
30
+ : "=a" (r) \
31
+ "+b" (arg1), \
32
+ "+c" (arg2), \
33
+ "+d" (arg3) \
34
+ : "a" (128) \
35
+ : "memory", "cc");
36
+
37
+ void bar(int arg1, int *arg2, int arg3)
38
+ {
39
+ ASM1;
40
+ ASM2;
41
+ ASM3;
42
+ ASM4(arg1, arg2, arg3);
43
+ }
@@ -1,5 +1,6 @@
1
- int baz(i)
1
+ int baz(i, a)
2
2
  const int i;
3
+ const char a[];
3
4
  {
4
5
  return i;
5
6
  }
@@ -8,6 +9,7 @@ int main(void)
8
9
  {
9
10
  const short s = 0;
10
11
  const int i = 0;
12
+ const char a[3];
11
13
 
12
14
  foo(s);
13
15
  foo(i);
@@ -17,9 +19,11 @@ int main(void)
17
19
  bar(i);
18
20
  bar(s, i);
19
21
 
20
- baz(s);
21
- baz(i);
22
- baz(s, i);
22
+ baz(s, a);
23
+ baz(i, a);
24
+ baz(s, a, i);
25
+
26
+ qux();
23
27
 
24
28
  return 0;
25
29
  }
@@ -35,3 +39,7 @@ static int bar(const int i)
35
39
 
36
40
  return i;
37
41
  }
42
+
43
+ static int qux(void)
44
+ {
45
+ }
@@ -0,0 +1,73 @@
1
+ int foo(const int i1, const int i2, const int i3, const int i4)
2
+ {
3
+ int r;
4
+
5
+ r = (i1 + i2) < (i3 == i4);
6
+ r = i1 - i2 > (i3 != i4);
7
+ r = (i1 * i2) <= (i3 < i4);
8
+ r = i1 / i2 >= (i3 > i4);
9
+ r = (i1 % i2) < (i3 <= i4);
10
+ r = i1 & i2 > (i3 >= i4);
11
+ r = (i1 | i2) <= !i3;
12
+ r = i1 ^ i2 >= !(i3 + i4);
13
+ r = (i1 << i2) > (!i3 < (i4 + i1));
14
+
15
+ r = (i3 == i4) < (i1 + i2);
16
+ r = (i3 != i4) > i1 - i2;
17
+ r = (i3 < i4) <= (i1 * i2);
18
+ r = (i3 > i4) >= i1 / i2;
19
+ r = (i3 <= i4) < (i1 % i2);
20
+ r = (i3 >= i4) > i1 & i2;
21
+ r = !i3 <= (i1 | i2);
22
+ r = !(i3 + i4) >= i1 ^ i2;
23
+ r = (!i3 < (i4 + i1)) > (i1 << i2);
24
+
25
+ r = (!i3 < (i4 + i1)) < (i3 == i4);
26
+ r = !(i3 + i4) > (i3 != i4);
27
+ r = !i3 <= (i3 < i4);
28
+ r = (i3 >= i4) >= (i3 > i4);
29
+ r = (i3 <= i4) < (i3 <= i4);
30
+ r = (i3 > i4) > (i3 >= i4);
31
+ r = (i3 < i4) <= !i3;
32
+ r = (i3 != i4) >= !(i3 + i4);
33
+ r = (i3 == i4) > (!i3 < (i4 + i1));
34
+
35
+ return r;
36
+ }
37
+
38
+ int bar(const int i1, const int i2, const int i3, const int i4)
39
+ {
40
+ int r;
41
+
42
+ r = (i1 + i2) & (i3 == i4);
43
+ r = i1 - i2 | (i3 != i4);
44
+ r = (i1 * i2) & (i3 < i4);
45
+ r = i1 / i2 | (i3 > i4);
46
+ r = (i1 % i2) & (i3 <= i4);
47
+ r = i1 & i2 | (i3 >= i4);
48
+ r = (i1 | i2) & !i3;
49
+ r = i1 ^ i2 | !(i3 + i4);
50
+ r = (i1 << i2) & (!i3 < (i4 + i1));
51
+
52
+ r = (i3 == i4) | (i1 + i2);
53
+ r = (i3 != i4) & i1 - i2;
54
+ r = (i3 < i4) | (i1 * i2);
55
+ r = (i3 > i4) & i1 / i2;
56
+ r = (i3 <= i4) | (i1 % i2);
57
+ r = (i3 >= i4) & i1 & i2;
58
+ r = !i3 | (i1 | i2);
59
+ r = !(i3 + i4) & i1 ^ i2;
60
+ r = (!i3 < (i4 + i1)) | (i1 << i2);
61
+
62
+ r = (!i3 < (i4 + i1)) & (i3 == i4);
63
+ r = !(i3 + i4) | (i3 != i4);
64
+ r = !i3 & (i3 < i4);
65
+ r = (i3 >= i4) | (i3 > i4);
66
+ r = (i3 <= i4) & (i3 <= i4);
67
+ r = (i3 > i4) | (i3 >= i4);
68
+ r = (i3 < i4) & !i3;
69
+ r = (i3 != i4) | !(i3 + i4);
70
+ r = (i3 == i4) & (!i3 < (i4 + i1));
71
+
72
+ return r;
73
+ }
@@ -0,0 +1,12 @@
1
+ extern int puts(const char *);
2
+
3
+ void foo(void)
4
+ {
5
+ register char a[3];
6
+ char *p = a;
7
+
8
+ p = &a[0];
9
+ p = &a[1];
10
+
11
+ puts(a);
12
+ }
@@ -0,0 +1,9 @@
1
+ typedef int integer;
2
+
3
+ integer ei1 = 0;
4
+ static integer si = 0;
5
+
6
+ void foo(void)
7
+ {
8
+ extern integer ei2;
9
+ }
@@ -110,3 +110,20 @@ static void qux(const unsigned int ui)
110
110
  ui3 = ui * 2U;
111
111
  }
112
112
  }
113
+
114
+ static void quux(const int i)
115
+ {
116
+ unsigned int ui;
117
+
118
+ if (i < 10) {
119
+ ui1 = (unsigned int) (i - 5);
120
+ ui1 = (unsigned int) (i - 9);
121
+ ui1 = (unsigned int) (i - 10);
122
+ }
123
+
124
+ if (i >= 0 && i < 10) {
125
+ ui1 = (unsigned int) (i - 5);
126
+ ui1 = (unsigned int) (i - 9);
127
+ ui1 = (unsigned int) (i - 10);
128
+ }
129
+ }
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 1.6.0 開発者ガイド</title>
3
+ <title>AdLint 1.8.0 開発者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 1.6.0 開発者ガイド">
5
+ <meta name="description" content="AdLint 1.8.0 開発者ガイド">
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 1.6.0 開発者ガイド</h1>
47
+ <h1 class="settitle">AdLint 1.8.0 開発者ガイド</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 1.6.0 開発者ガイド
5
+ @settitle AdLint 1.8.0 開発者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.