@@ -1017,6 +1017,67 @@ TEST_P(ASTMatchersTest, FloatLiteral) {
10171017 notMatches (" double i = 5.0;" , floatLiteral (equals (llvm::APFloat (6.0 )))));
10181018}
10191019
1020+ TEST_P (ASTMatchersTest, FixedPointLiterals) {
1021+ StatementMatcher HasFixedPointLiteral = fixedPointLiteral ();
1022+ EXPECT_TRUE (matchesWithFixedpoint (" _Fract i = 0.25r;" , HasFixedPointLiteral));
1023+ EXPECT_TRUE (
1024+ matchesWithFixedpoint (" _Fract i = 0.25hr;" , HasFixedPointLiteral));
1025+ EXPECT_TRUE (
1026+ matchesWithFixedpoint (" _Fract i = 0.25uhr;" , HasFixedPointLiteral));
1027+ EXPECT_TRUE (
1028+ matchesWithFixedpoint (" _Fract i = 0.25ur;" , HasFixedPointLiteral));
1029+ EXPECT_TRUE (
1030+ matchesWithFixedpoint (" _Fract i = 0.25lr;" , HasFixedPointLiteral));
1031+ EXPECT_TRUE (
1032+ matchesWithFixedpoint (" _Fract i = 0.25ulr;" , HasFixedPointLiteral));
1033+ EXPECT_TRUE (matchesWithFixedpoint (" _Accum i = 1.25k;" , HasFixedPointLiteral));
1034+ EXPECT_TRUE (
1035+ matchesWithFixedpoint (" _Accum i = 1.25hk;" , HasFixedPointLiteral));
1036+ EXPECT_TRUE (
1037+ matchesWithFixedpoint (" _Accum i = 1.25uhk;" , HasFixedPointLiteral));
1038+ EXPECT_TRUE (
1039+ matchesWithFixedpoint (" _Accum i = 1.25uk;" , HasFixedPointLiteral));
1040+ EXPECT_TRUE (
1041+ matchesWithFixedpoint (" _Accum i = 1.25lk;" , HasFixedPointLiteral));
1042+ EXPECT_TRUE (
1043+ matchesWithFixedpoint (" _Accum i = 1.25ulk;" , HasFixedPointLiteral));
1044+ EXPECT_TRUE (matchesWithFixedpoint (" _Accum decexp1 = 1.575e1k;" ,
1045+ HasFixedPointLiteral));
1046+ EXPECT_TRUE (
1047+ matchesWithFixedpoint (" _Accum hex = 0x1.25fp2k;" , HasFixedPointLiteral));
1048+ EXPECT_TRUE (matchesWithFixedpoint (" _Sat long _Fract i = 0.25r;" ,
1049+ HasFixedPointLiteral));
1050+ EXPECT_TRUE (matchesWithFixedpoint (" _Sat short _Accum i = 256.0k;" ,
1051+ HasFixedPointLiteral));
1052+ EXPECT_TRUE (matchesWithFixedpoint (
1053+ " _Accum i = 256.0k;" ,
1054+ fixedPointLiteral (equals (llvm::APInt (32 , 0x800000 , true )))));
1055+ EXPECT_TRUE (matchesWithFixedpoint (
1056+ " _Fract i = 0.25ulr;" ,
1057+ fixedPointLiteral (equals (llvm::APInt (32 , 0x40000000 , false )))));
1058+ EXPECT_TRUE (matchesWithFixedpoint (
1059+ " _Fract i = 0.5hr;" ,
1060+ fixedPointLiteral (equals (llvm::APInt (8 , 0x40 , true )))));
1061+
1062+ EXPECT_TRUE (
1063+ notMatchesWithFixedpoint (" short _Accum i = 2u;" , HasFixedPointLiteral));
1064+ EXPECT_TRUE (
1065+ notMatchesWithFixedpoint (" short _Accum i = 2;" , HasFixedPointLiteral));
1066+ EXPECT_TRUE (
1067+ notMatchesWithFixedpoint (" _Accum i = 1.25;" , HasFixedPointLiteral));
1068+ EXPECT_TRUE (notMatchesWithFixedpoint (" _Accum i = (double)(1.25 * 4.5i);" ,
1069+ HasFixedPointLiteral));
1070+ EXPECT_TRUE (notMatchesWithFixedpoint (
1071+ " _Accum i = 256.0k;" ,
1072+ fixedPointLiteral (equals (llvm::APInt (32 , 0x800001 , true )))));
1073+ EXPECT_TRUE (notMatchesWithFixedpoint (
1074+ " _Fract i = 0.25ulr;" ,
1075+ fixedPointLiteral (equals (llvm::APInt (32 , 0x40000001 , false )))));
1076+ EXPECT_TRUE (notMatchesWithFixedpoint (
1077+ " _Fract i = 0.5hr;" ,
1078+ fixedPointLiteral (equals (llvm::APInt (8 , 0x41 , true )))));
1079+ }
1080+
10201081TEST_P (ASTMatchersTest, CXXNullPtrLiteralExpr) {
10211082 if (!GetParam ().isCXX11OrLater ()) {
10221083 return ;
0 commit comments