adlint 1.6.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +389 -37
- data/INSTALL +3 -0
- data/MANIFEST +7 -0
- data/NEWS +50 -10
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/mesg.d/en_US/messages.yml +7 -7
- data/etc/mesg.d/ja_JP/messages.yml +4 -4
- data/lib/adlint/c/branch.rb +4 -4
- data/lib/adlint/c/code.rb +11 -13
- data/lib/adlint/c/enum.rb +0 -2
- data/lib/adlint/c/environ.rb +13 -7
- data/lib/adlint/c/expr.rb +5 -1
- data/lib/adlint/c/interp.rb +10 -6
- data/lib/adlint/c/mediator.rb +1 -0
- data/lib/adlint/c/message.rb +294 -111
- data/lib/adlint/c/message_shima.rb +63 -0
- data/lib/adlint/c/metric.rb +25 -13
- data/lib/adlint/c/object.rb +168 -31
- data/lib/adlint/c/parser.rb +3 -3
- data/lib/adlint/c/phase.rb +20 -3
- data/lib/adlint/c/syntax.rb +175 -17
- data/lib/adlint/c/value.rb +199 -126
- data/lib/adlint/cpp/asm.rb +4 -4
- data/lib/adlint/cpp/constexpr.rb +1 -1
- data/lib/adlint/cpp/eval.rb +6 -4
- data/lib/adlint/cpp/message.rb +100 -7
- data/lib/adlint/cpp/phase.rb +12 -1
- data/lib/adlint/cpp/source.rb +2 -2
- data/lib/adlint/cpp/subst.rb +2 -4
- data/lib/adlint/lang.rb +5 -3
- data/lib/adlint/ld/metric.rb +1 -1
- data/lib/adlint/version.rb +2 -2
- data/share/demo/Makefile +5 -0
- data/share/demo/bad_include/bad_include.c +13 -0
- data/share/demo/bad_include/test'1'.h +0 -0
- data/share/demo/bad_include/test'2'.h +0 -0
- data/share/demo/incomplete_ifelse/incomplete_ifelse.c +29 -0
- data/share/demo/inline_asm/inline_asm.c +25 -0
- data/share/demo/invalid_call/invalid_call.c +12 -4
- data/share/demo/logical_expr/logical_expr.c +73 -0
- data/share/demo/register_vars/register_vars.c +12 -0
- data/share/demo/typedef_each_src/typedef_each_src.c +9 -0
- data/share/demo/wrap_around/wrap_around.c +17 -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 +137 -102
- data/share/doc/users_guide_en.texi +121 -86
- data/share/doc/users_guide_ja.html +118 -91
- data/share/doc/users_guide_ja.texi +103 -76
- metadata +10 -3
data/lib/adlint/cpp/phase.rb
CHANGED
@@ -41,7 +41,7 @@ require "adlint/cpp/util"
|
|
41
41
|
module AdLint #:nodoc:
|
42
42
|
module Cpp #:nodoc:
|
43
43
|
|
44
|
-
class
|
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
|
data/lib/adlint/cpp/source.rb
CHANGED
@@ -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 { |
|
98
|
-
on_language_extension.invoke(
|
97
|
+
subst.on_substitution += lambda { |matched_tokens|
|
98
|
+
on_language_extension.invoke(matched_tokens)
|
99
99
|
}
|
100
100
|
end
|
101
101
|
end
|
data/lib/adlint/cpp/subst.rb
CHANGED
@@ -68,10 +68,8 @@ module Cpp #:nodoc:
|
|
68
68
|
|
69
69
|
private
|
70
70
|
def notify_substitution(tokens, index, length)
|
71
|
-
|
72
|
-
|
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::
|
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::
|
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::
|
89
|
+
AdLint::Cpp::Prepare1Phase,
|
88
90
|
AdLint::Cpp::EvalPhase,
|
89
91
|
AdLint::Cpp::SubstPhase,
|
90
92
|
AdLint::C::ParsePhase
|
data/lib/adlint/ld/metric.rb
CHANGED
@@ -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
|
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
|
data/lib/adlint/version.rb
CHANGED
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
|
+
}
|
@@ -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.
|
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.
|
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.
|
47
|
+
<h1 class="settitle">AdLint 1.8.0 開発者ガイド</h1>
|
48
48
|
<div class="contents">
|
49
49
|
<h2>Table of Contents</h2>
|
50
50
|
<ul>
|