Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | List of all members
AETest Class Reference

Public Member Functions

 AETest ()=default
 
 ~AETest ()=default
 
void testBinaryOpStmt ()
 
void testAbsState ()
 

Detailed Description

Definition at line 625 of file ae.cpp.

Constructor & Destructor Documentation

◆ AETest()

AETest::AETest ( )
default

◆ ~AETest()

AETest::~AETest ( )
default

Member Function Documentation

◆ testAbsState()

void AETest::testAbsState ( )
inline

Definition at line 828 of file ae.cpp.

829 {
831 as[1] = IntervalValue(1, 3);
832 as[2] = IntervalValue(2, 7);
833 as[3] = AddressValue(0x7f000007);
834 as[4] = AddressValue(0x7f000008);
835 as.storeValue(3, as[1]);
836 as.storeValue(4, as[2]);
837 as.printAbstractState();
838 assert(as.loadValue(3).equals(as[1]) && as.loadValue(4).equals(as[2]));
839 }
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ testBinaryOpStmt()

void AETest::testBinaryOpStmt ( )
inline

Definition at line 632 of file ae.cpp.

633 {
634 // test division /
638 assert((IntervalValue(4) / IntervalValue(2)).equals(IntervalValue(2)));
639 assert((IntervalValue(3) / IntervalValue(2)).equals(IntervalValue(1))); //
640 assert((IntervalValue(-3) / IntervalValue(2)).equals(IntervalValue(-1))); //
641 assert((IntervalValue(1, 3) / IntervalValue(2)).equals(IntervalValue(0, 1))); //
642 assert((IntervalValue(2, 7) / IntervalValue(2)).equals(IntervalValue(1, 3))); //
643 assert((IntervalValue(-3, 3) / IntervalValue(2)).equals(IntervalValue(-1, 1)));
646 assert((IntervalValue(1, 3) / IntervalValue(1, 2)).equals(IntervalValue(0, 3)));//
647 assert((IntervalValue(-3, 3) / IntervalValue(1, 2)).equals(IntervalValue(-3, 3)));
648 assert((IntervalValue(2, 7) / IntervalValue(-2, 3)).equals(IntervalValue(-7, 7))); //
649 assert((IntervalValue(-2, 7) / IntervalValue(-2, 3)).equals(IntervalValue(-7, 7))); //
652
655 assert((IntervalValue(-6, -3) / IntervalValue(3, 9)).equals(IntervalValue(-2, 0)));
656 assert((IntervalValue(-6, 6) / IntervalValue(3, 9)).equals(IntervalValue(-2, 2)));
657
658 // test remainder %
662 assert((IntervalValue(4) % IntervalValue(2)).equals(IntervalValue(0)));
663 assert((IntervalValue(3) % IntervalValue(2)).equals(IntervalValue(1)));
664 assert((IntervalValue(-3) % IntervalValue(2)).equals(IntervalValue(-1)));
665 assert((IntervalValue(1, 3) % IntervalValue(2)).equals(IntervalValue(0, 1)));
666 assert((IntervalValue(2, 7) % IntervalValue(2)).equals(IntervalValue(0, 1)));
667 assert((IntervalValue(-3, 3) % IntervalValue(2)).equals(IntervalValue(-1, 1)));
670 assert((IntervalValue(1, 3) % IntervalValue(1, 2)).equals(IntervalValue(0, 1)));
671 assert((IntervalValue(-3, 3) % IntervalValue(1, 2)).equals(IntervalValue(-1, 1)));
672 assert((IntervalValue(2, 7) % IntervalValue(-2, 3)).equals(IntervalValue::top())); //
673 assert((IntervalValue(-2, 7) % IntervalValue(-2, 3)).equals(IntervalValue::top())); //
678 assert((IntervalValue(-6, -3) % IntervalValue(3, 9)).equals(IntervalValue(-6, 0)));
679 assert((IntervalValue(-6, 6) % IntervalValue(3, 9)).equals(IntervalValue(-6, 6)));
680
681 // shl <<
689 assert((IntervalValue(0, 0) << IntervalValue(2, 2)).equals(IntervalValue(0, 0)));
690 assert((IntervalValue(2, 2) << IntervalValue(3, 3)).equals(IntervalValue(16, 16)));
691 assert((IntervalValue(-2, -2) << IntervalValue(3, 3)).equals(IntervalValue(-16, -16)));
692
696 assert((IntervalValue(4) << IntervalValue(2)).equals(IntervalValue(16)));
697 assert((IntervalValue(3) << IntervalValue(2)).equals(IntervalValue(12)));
698 assert((IntervalValue(-3) << IntervalValue(2)).equals(IntervalValue(-12)));
700 assert((IntervalValue(1, 3) << IntervalValue(2)).equals(IntervalValue(4, 12)));
701 assert((IntervalValue(2, 7) << IntervalValue(2)).equals(IntervalValue(8, 28)));
702 assert((IntervalValue(-3, 3) << IntervalValue(2)).equals(IntervalValue(-12, 12)));
705 assert((IntervalValue(1, 3) << IntervalValue(1, 2)).equals(IntervalValue(2, 12)));
706 assert((IntervalValue(-3, 3) << IntervalValue(1, 2)).equals(IntervalValue(-12, 12)));
707 assert((IntervalValue(2, 7) << IntervalValue(-2, 3)).equals(IntervalValue(2, 56)));
708 assert((IntervalValue(-2, 7) << IntervalValue(-2, 3)).equals(IntervalValue(-16, 56)));
713 assert((IntervalValue(-6, -3) << IntervalValue(3, 9)).equals(IntervalValue(-3072, -24)));
714 assert((IntervalValue(-6, 6) << IntervalValue(3, 9)).equals(IntervalValue(-3072, 3072)));
717
718
719 // shr >>
727 assert((IntervalValue(0) >> IntervalValue(2)).equals(IntervalValue(0)));
728 assert((IntervalValue(15) >> IntervalValue(2)).equals(IntervalValue(3)));
729 assert((IntervalValue(-15) >> IntervalValue(2)).equals(IntervalValue(-4)));
730
734 assert((IntervalValue(15) >> IntervalValue(2)).equals(IntervalValue(3)));
735 assert((IntervalValue(1) >> IntervalValue(2)).equals(IntervalValue(0)));
736 assert((IntervalValue(-15) >> IntervalValue(2)).equals(IntervalValue(-4)));
738 assert((IntervalValue(1, 3) >> IntervalValue(2)).equals(IntervalValue(0)));
739 assert((IntervalValue(2, 7) >> IntervalValue(2)).equals(IntervalValue(0, 1)));
740 assert((IntervalValue(-15, 15) >> IntervalValue(2)).equals(IntervalValue(-4, 3)));
743 assert((IntervalValue(0, 15) >> IntervalValue(1, 2)).equals(IntervalValue(0, 7)));
744 assert((IntervalValue(-17, 15) >> IntervalValue(1, 2)).equals(IntervalValue(-9, 7)));
745 assert((IntervalValue(2, 7) >> IntervalValue(-2, 3)).equals(IntervalValue(0, 7)));
746 assert((IntervalValue(-2, 7) >> IntervalValue(-2, 3)).equals(IntervalValue(-2, 7)));
751 assert((IntervalValue(-6, -3) >> IntervalValue(2, 3)).equals(IntervalValue(-2, -1)));
752 assert((IntervalValue(-6, 6) >> IntervalValue(2, 3)).equals(IntervalValue(-2, 1)));
755
756 // and &
760 assert((IntervalValue(4) & IntervalValue(2)).equals(IntervalValue(0)));
761 assert((IntervalValue(3) & IntervalValue(2)).equals(IntervalValue(2)));
762 assert((IntervalValue(-3) & IntervalValue(2)).equals(IntervalValue(0)));
763 assert((IntervalValue(1, 3) & IntervalValue(2)).equals(IntervalValue(0, 2)));
764 assert((IntervalValue(2, 7) & IntervalValue(2)).equals(IntervalValue(0, 2)));
765 assert((IntervalValue(-3, 3) & IntervalValue(2)).equals(IntervalValue(0, 2)));
768 assert((IntervalValue(1, 3) & IntervalValue(1, 2)).equals(IntervalValue(0, 2)));
769 assert((IntervalValue(-3, 3) & IntervalValue(1, 2)).equals(IntervalValue(0, 2)));
770 assert((IntervalValue(2, 7) & IntervalValue(-2, 3)).equals(IntervalValue(0, 7)));
771 assert((IntervalValue(-2, 7) & IntervalValue(-2, 3)).equals(IntervalValue::top()));
776 assert((IntervalValue(-6, -3) & IntervalValue(3, 9)).equals(IntervalValue(0, 9)));
777 assert((IntervalValue(-6, 6) & IntervalValue(3, 9)).equals(IntervalValue(0, 9)));
778
779 // Or |
784 assert((IntervalValue(4) | IntervalValue(2)).equals(IntervalValue(6)));
785 assert((IntervalValue(3) | IntervalValue(2)).equals(IntervalValue(3)));
786 assert((IntervalValue(-3) | IntervalValue(2)).equals(IntervalValue(-1)));
787 assert((IntervalValue(1, 3) | IntervalValue(2)).equals(IntervalValue(0, 3)));
788 assert((IntervalValue(2, 7) | IntervalValue(2)).equals(IntervalValue(0, 7)));
789 assert((IntervalValue(-3, 3) | IntervalValue(2)).equals(IntervalValue::top()));
792 assert((IntervalValue(1, 3) | IntervalValue(1, 2)).equals(IntervalValue(0, 3)));
793 assert((IntervalValue(-3, 3) | IntervalValue(1, 2)).equals(IntervalValue::top()));
794 assert((IntervalValue(2, 7) | IntervalValue(-2, 3)).equals(IntervalValue::top()));
795 assert((IntervalValue(-2, 7) | IntervalValue(-2, 3)).equals(IntervalValue::top()));
800 assert((IntervalValue(-6, -3) | IntervalValue(3, 9)).equals(IntervalValue::top()));
801 assert((IntervalValue(-6, 6) | IntervalValue(3, 9)).equals(IntervalValue::top()));
802
803 // Xor ^
808 assert((IntervalValue(4) ^ IntervalValue(2)).equals(IntervalValue(6)));
809 assert((IntervalValue(3) ^ IntervalValue(2)).equals(IntervalValue(1)));
810 assert((IntervalValue(-3) ^ IntervalValue(2)).equals(IntervalValue(-1)));
811 assert((IntervalValue(1, 3) ^ IntervalValue(2)).equals(IntervalValue(0, 3)));
812 assert((IntervalValue(2, 7) ^ IntervalValue(2)).equals(IntervalValue(0, 7)));
813 assert((IntervalValue(-3, 3) ^ IntervalValue(2)).equals(IntervalValue::top()));
816 assert((IntervalValue(1, 3) ^ IntervalValue(1, 2)).equals(IntervalValue(0, 3)));
817 assert((IntervalValue(-3, 3) ^ IntervalValue(1, 2)).equals(IntervalValue::top()));
818 assert((IntervalValue(2, 7) ^ IntervalValue(-2, 3)).equals(IntervalValue::top()));
819 assert((IntervalValue(-2, 7) ^ IntervalValue(-2, 3)).equals(IntervalValue::top()));
824 assert((IntervalValue(-6, -3) ^ IntervalValue(3, 9)).equals(IntervalValue::top()));
825 assert((IntervalValue(-6, 6) ^ IntervalValue(3, 9)).equals(IntervalValue::top()));
826 }
static BoundedInt minus_infinity()
Get minus infinity -inf.
static IntervalValue bottom()
Create the bottom IntervalValue [+inf, -inf].
static BoundedInt plus_infinity()
Get plus infinity +inf.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].

The documentation for this class was generated from the following file: