adlint 1.10.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +197 -4
- data/MANIFEST +17 -0
- data/NEWS +23 -4
- data/etc/mesg.d/en_US/messages.yml +14 -1
- data/etc/mesg.d/ja_JP/messages.yml +14 -1
- data/features/message_detection/W0093.feature +87 -0
- data/features/message_detection/W0687.feature +25 -0
- data/features/message_detection/W0688.feature +63 -0
- data/features/message_detection/W0689.feature +46 -0
- data/features/message_detection/W0690.feature +35 -0
- data/features/message_detection/W0698.feature +3 -2
- data/features/message_detection/W0703.feature +1 -0
- data/features/message_detection/W0723.feature +34 -0
- data/features/message_detection/W0732.feature +158 -0
- data/features/message_detection/W0733.feature +158 -0
- data/features/message_detection/W0734.feature +322 -0
- data/features/message_detection/W0735.feature +322 -0
- data/features/message_detection/W1052.feature +66 -0
- data/features/message_detection/W9001.feature +33 -0
- data/features/message_detection/W9003.feature +131 -0
- data/lib/adlint/c/ctrlexpr.rb +51 -50
- data/lib/adlint/c/domain.rb +237 -223
- data/lib/adlint/c/expr.rb +6 -8
- data/lib/adlint/c/interp.rb +8 -11
- data/lib/adlint/c/message.rb +20 -0
- data/lib/adlint/c/message_shima.rb +63 -0
- data/lib/adlint/c/object.rb +5 -4
- data/lib/adlint/c/operator.rb +99 -0
- data/lib/adlint/c/parser.rb +2 -2
- data/lib/adlint/c/parser.y +2 -2
- data/lib/adlint/c/phase.rb +6 -1
- data/lib/adlint/c/syntax.rb +442 -30
- data/lib/adlint/c/type.rb +449 -363
- data/lib/adlint/c/value.rb +96 -25
- data/lib/adlint/c.rb +1 -0
- data/lib/adlint/prelude.rb +16 -18
- data/lib/adlint/version.rb +2 -2
- data/share/doc/developers_guide_ja.html +11 -5
- data/share/doc/developers_guide_ja.texi +9 -3
- data/share/doc/users_guide_en.html +697 -131
- data/share/doc/users_guide_en.texi +491 -41
- data/share/doc/users_guide_ja.html +709 -139
- data/share/doc/users_guide_ja.texi +499 -45
- data/spec/adlint/c/ctrlexpr_spec.rb +168 -0
- data/spec/adlint/c/domain_spec.rb +835 -0
- data/spec/adlint/c/operator_spec.rb +406 -0
- data/spec/adlint/c/syntax_spec.rb +717 -0
- data/spec/adlint/c/type_spec.rb +55 -30
- metadata +19 -2
data/lib/adlint/c/ctrlexpr.rb
CHANGED
@@ -34,6 +34,7 @@ require "adlint/c/object"
|
|
34
34
|
require "adlint/c/mediator"
|
35
35
|
require "adlint/c/expr"
|
36
36
|
require "adlint/c/conv"
|
37
|
+
require "adlint/c/operator"
|
37
38
|
|
38
39
|
module AdLint #:nodoc:
|
39
40
|
module C #:nodoc:
|
@@ -569,7 +570,7 @@ module C #:nodoc:
|
|
569
570
|
private
|
570
571
|
def commit_changes(narrowing)
|
571
572
|
narrowing.narrowed_values.each do |variable, narrowed_value|
|
572
|
-
variable.narrow_value_domain!(
|
573
|
+
variable.narrow_value_domain!(Operator::EQ, narrowed_value)
|
573
574
|
end
|
574
575
|
end
|
575
576
|
end
|
@@ -578,7 +579,7 @@ module C #:nodoc:
|
|
578
579
|
private
|
579
580
|
def commit_changes(narrowing)
|
580
581
|
narrowing.narrowed_values.each do |variable, narrowed_value|
|
581
|
-
variable.widen_value_domain!(
|
582
|
+
variable.widen_value_domain!(Operator::EQ, narrowed_value)
|
582
583
|
end
|
583
584
|
end
|
584
585
|
end
|
@@ -596,7 +597,8 @@ module C #:nodoc:
|
|
596
597
|
private
|
597
598
|
def commit_changes(narrowing)
|
598
599
|
@branch_group.all_controlling_variables.each do |variable|
|
599
|
-
variable.narrow_value_domain!(
|
600
|
+
variable.narrow_value_domain!(Operator::EQ,
|
601
|
+
variable.type.arbitrary_value)
|
600
602
|
end
|
601
603
|
true
|
602
604
|
end
|
@@ -615,7 +617,8 @@ module C #:nodoc:
|
|
615
617
|
private
|
616
618
|
def commit_changes(narrowing)
|
617
619
|
@branch_group.all_controlling_variables.each do |variable|
|
618
|
-
variable.widen_value_domain!(
|
620
|
+
variable.widen_value_domain!(Operator::EQ,
|
621
|
+
variable.type.arbitrary_value)
|
619
622
|
end
|
620
623
|
true
|
621
624
|
end
|
@@ -658,7 +661,7 @@ module C #:nodoc:
|
|
658
661
|
def ensure_result_equal_to(value)
|
659
662
|
if @result.variable? && @result.designated_by_lvalue?
|
660
663
|
if @result.value.scalar? && value.scalar?
|
661
|
-
ensure_relation(@result,
|
664
|
+
ensure_relation(@result, Operator::EQ, value)
|
662
665
|
end
|
663
666
|
end
|
664
667
|
end
|
@@ -688,10 +691,14 @@ module C #:nodoc:
|
|
688
691
|
return lhs_result, rhs_result
|
689
692
|
end
|
690
693
|
|
691
|
-
def ensure_relation(variable,
|
692
|
-
|
693
|
-
|
694
|
-
|
694
|
+
def ensure_relation(variable, operator, value)
|
695
|
+
# NOTE: To avoid over-narrowing.
|
696
|
+
if value.definite? or
|
697
|
+
variable.value.contain?(value) && !value.contain?(variable.value)
|
698
|
+
target_value = save_original_value(variable).dup
|
699
|
+
target_value.narrow_domain!(operator, value)
|
700
|
+
update_narrowed_value(variable, target_value)
|
701
|
+
end
|
695
702
|
end
|
696
703
|
|
697
704
|
def save_original_value(variable)
|
@@ -712,7 +719,7 @@ module C #:nodoc:
|
|
712
719
|
|
713
720
|
@narrowed_values = lhs_values.merge(rhs_values) { |key, lhs_val, rhs_val|
|
714
721
|
result = lhs_val.dup
|
715
|
-
result.narrow_domain!(
|
722
|
+
result.narrow_domain!(Operator::EQ, rhs_val)
|
716
723
|
result
|
717
724
|
}
|
718
725
|
end
|
@@ -723,7 +730,7 @@ module C #:nodoc:
|
|
723
730
|
|
724
731
|
@narrowed_values = lhs_values.merge(rhs_values) { |key, lhs_val, rhs_val|
|
725
732
|
result = lhs_val.dup
|
726
|
-
result.widen_domain!(
|
733
|
+
result.widen_domain!(Operator::EQ, rhs_val)
|
727
734
|
result
|
728
735
|
}
|
729
736
|
end
|
@@ -739,7 +746,7 @@ module C #:nodoc:
|
|
739
746
|
class ValueComparison < ValueDomainNarrowing
|
740
747
|
def initialize(value_domain_manip, node, lhs_narrowing, rhs_narrowing)
|
741
748
|
super
|
742
|
-
@
|
749
|
+
@operator = ComparisonOperator.new(node.operator)
|
743
750
|
@lhs_narrowing = lhs_narrowing
|
744
751
|
@rhs_narrowing = rhs_narrowing
|
745
752
|
end
|
@@ -747,59 +754,53 @@ module C #:nodoc:
|
|
747
754
|
private
|
748
755
|
def do_narrowing
|
749
756
|
@lhs_narrowing.execute!
|
750
|
-
|
757
|
+
lhs_var = object_to_variable(@lhs_narrowing.result)
|
751
758
|
|
752
759
|
@rhs_narrowing.execute!
|
753
|
-
|
760
|
+
rhs_var = object_to_variable(@rhs_narrowing.result)
|
754
761
|
|
755
|
-
unless
|
762
|
+
unless lhs_var.type.scalar? && rhs_var.type.scalar?
|
756
763
|
return temporary_variable(int_type)
|
757
764
|
end
|
758
765
|
|
759
|
-
unless
|
766
|
+
unless lhs_var.value.scalar? && rhs_var.value.scalar?
|
760
767
|
return temporary_variable(int_type)
|
761
768
|
end
|
762
769
|
|
763
|
-
|
764
|
-
do_logical_arithmetic_conversion(@node,
|
765
|
-
|
766
|
-
case @
|
767
|
-
when
|
768
|
-
result = temporary_variable(int_type,
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
when
|
774
|
-
result = temporary_variable(int_type,
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
when :<=
|
780
|
-
result = temporary_variable(int_type,
|
781
|
-
lhs_converted.value <= rhs_converted.value)
|
782
|
-
when :>=
|
783
|
-
result = temporary_variable(int_type,
|
784
|
-
lhs_converted.value >= rhs_converted.value)
|
770
|
+
lhs_conv, rhs_conv =
|
771
|
+
do_logical_arithmetic_conversion(@node, lhs_var, rhs_var)
|
772
|
+
|
773
|
+
case @operator
|
774
|
+
when Operator::EQ
|
775
|
+
result = temporary_variable(int_type, lhs_conv.value == rhs_conv.value)
|
776
|
+
when Operator::NE
|
777
|
+
result = temporary_variable(int_type, lhs_conv.value != rhs_conv.value)
|
778
|
+
when Operator::LT
|
779
|
+
result = temporary_variable(int_type, lhs_conv.value < rhs_conv.value)
|
780
|
+
when Operator::GT
|
781
|
+
result = temporary_variable(int_type, lhs_conv.value > rhs_conv.value)
|
782
|
+
when Operator::LE
|
783
|
+
result = temporary_variable(int_type, lhs_conv.value <= rhs_conv.value)
|
784
|
+
when Operator::GE
|
785
|
+
result = temporary_variable(int_type, lhs_conv.value >= rhs_conv.value)
|
785
786
|
else
|
786
|
-
|
787
|
+
__NOTREACHED__
|
787
788
|
end
|
788
789
|
|
789
|
-
case @
|
790
|
-
when
|
791
|
-
notify_equality_expr_evaled(@node,
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
790
|
+
case @operator
|
791
|
+
when Operator::EQ, Operator::NE
|
792
|
+
notify_equality_expr_evaled(@node, lhs_conv, rhs_conv, result)
|
793
|
+
when Operator::LT, Operator::GT, Operator::LE, Operator::GE
|
794
|
+
notify_relational_expr_evaled(@node, lhs_conv, rhs_conv, result)
|
795
|
+
else
|
796
|
+
__NOTREACHED__
|
796
797
|
end
|
797
798
|
|
798
799
|
case
|
799
|
-
when
|
800
|
-
ensure_relation(
|
801
|
-
when
|
802
|
-
ensure_relation(
|
800
|
+
when lhs_conv.designated_by_lvalue?
|
801
|
+
ensure_relation(lhs_conv, @operator, rhs_conv.value)
|
802
|
+
when rhs_conv.designated_by_lvalue?
|
803
|
+
ensure_relation(rhs_conv, @operator.for_commutation, lhs_conv.value)
|
803
804
|
else
|
804
805
|
# NOTE: Domain of the rvalue should not be narrowed.
|
805
806
|
end
|