vabridgers updated this revision to Diff 256234. vabridgers added a comment.
Address comment from @balazske Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77721/new/ https://reviews.llvm.org/D77721 Files: clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/AST/ASTImporter.cpp clang/lib/ASTMatchers/ASTMatchersInternal.cpp clang/unittests/AST/ASTImporterTest.cpp Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -255,6 +255,7 @@ struct ImportExpr : TestImportBase {}; struct ImportType : TestImportBase {}; struct ImportDecl : TestImportBase {}; +struct ImportFixedPointExpr : ImportExpr {}; struct CanonicalRedeclChain : ASTImporterOptionSpecificTestBase {}; @@ -527,6 +528,14 @@ floatLiteral(equals(1.0e-5f), hasType(asString("float")))))); } +TEST_P(ImportFixedPointExpr, ImportFixedPointerLiteralExpr) { + MatchVerifier<Decl> Verifier; + testImport("void declToImport() { (void)1.0k; }", Lang_C, "", Lang_C, + Verifier, functionDecl(hasDescendant(fixedPointLiteral()))); + testImport("void declToImport() { (void)0.75r; }", Lang_C, "", Lang_C, + Verifier, functionDecl(hasDescendant(fixedPointLiteral()))); +} + TEST_P(ImportExpr, ImportImaginaryLiteralExpr) { MatchVerifier<Decl> Verifier; testImport( @@ -5931,6 +5940,9 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportExpr, DefaultTestValuesForRunOptions, ); +INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFixedPointExpr, + ::testing::Values(ArgVector{"-ffixed-point"}), ); + INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportType, DefaultTestValuesForRunOptions, ); Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -804,6 +804,8 @@ integerLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, FloatingLiteral> floatLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, ImaginaryLiteral> imaginaryLiteral; +const internal::VariadicDynCastAllOfMatcher<Stmt, FixedPointLiteral> + fixedPointLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral> userDefinedLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr> Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -588,6 +588,7 @@ ExpectedStmt VisitIntegerLiteral(IntegerLiteral *E); ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E); ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E); + ExpectedStmt VisitFixedPointLiteral(FixedPointLiteral *E); ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E); ExpectedStmt VisitStringLiteral(StringLiteral *E); ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E); @@ -6503,6 +6504,20 @@ *ToSubExprOrErr, *ToTypeOrErr); } +ExpectedStmt ASTNodeImporter::VisitFixedPointLiteral(FixedPointLiteral *E) { + auto ToTypeOrErr = import(E->getType()); + if (!ToTypeOrErr) + return ToTypeOrErr.takeError(); + + ExpectedSLoc ToLocationOrErr = import(E->getLocation()); + if (!ToLocationOrErr) + return ToLocationOrErr.takeError(); + + return new (Importer.getToContext()) FixedPointLiteral( + Importer.getToContext(), E->getValue(), *ToTypeOrErr, *ToLocationOrErr, + Importer.getToContext().getFixedPointScale(*ToTypeOrErr)); +} + ExpectedStmt ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { ExpectedType ToTypeOrErr = import(E->getType()); if (!ToTypeOrErr) Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -2271,6 +2271,10 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, ImaginaryLiteral> imaginaryLiteral; +/// Matches fixed point literals +extern const internal::VariadicDynCastAllOfMatcher<Stmt, FixedPointLiteral> + fixedPointLiteral; + /// Matches user defined literal operator call. /// /// Example match: "foo"_suffix
Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -255,6 +255,7 @@ struct ImportExpr : TestImportBase {}; struct ImportType : TestImportBase {}; struct ImportDecl : TestImportBase {}; +struct ImportFixedPointExpr : ImportExpr {}; struct CanonicalRedeclChain : ASTImporterOptionSpecificTestBase {}; @@ -527,6 +528,14 @@ floatLiteral(equals(1.0e-5f), hasType(asString("float")))))); } +TEST_P(ImportFixedPointExpr, ImportFixedPointerLiteralExpr) { + MatchVerifier<Decl> Verifier; + testImport("void declToImport() { (void)1.0k; }", Lang_C, "", Lang_C, + Verifier, functionDecl(hasDescendant(fixedPointLiteral()))); + testImport("void declToImport() { (void)0.75r; }", Lang_C, "", Lang_C, + Verifier, functionDecl(hasDescendant(fixedPointLiteral()))); +} + TEST_P(ImportExpr, ImportImaginaryLiteralExpr) { MatchVerifier<Decl> Verifier; testImport( @@ -5931,6 +5940,9 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportExpr, DefaultTestValuesForRunOptions, ); +INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFixedPointExpr, + ::testing::Values(ArgVector{"-ffixed-point"}), ); + INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportType, DefaultTestValuesForRunOptions, ); Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -804,6 +804,8 @@ integerLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, FloatingLiteral> floatLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, ImaginaryLiteral> imaginaryLiteral; +const internal::VariadicDynCastAllOfMatcher<Stmt, FixedPointLiteral> + fixedPointLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, UserDefinedLiteral> userDefinedLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr> Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -588,6 +588,7 @@ ExpectedStmt VisitIntegerLiteral(IntegerLiteral *E); ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E); ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E); + ExpectedStmt VisitFixedPointLiteral(FixedPointLiteral *E); ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E); ExpectedStmt VisitStringLiteral(StringLiteral *E); ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E); @@ -6503,6 +6504,20 @@ *ToSubExprOrErr, *ToTypeOrErr); } +ExpectedStmt ASTNodeImporter::VisitFixedPointLiteral(FixedPointLiteral *E) { + auto ToTypeOrErr = import(E->getType()); + if (!ToTypeOrErr) + return ToTypeOrErr.takeError(); + + ExpectedSLoc ToLocationOrErr = import(E->getLocation()); + if (!ToLocationOrErr) + return ToLocationOrErr.takeError(); + + return new (Importer.getToContext()) FixedPointLiteral( + Importer.getToContext(), E->getValue(), *ToTypeOrErr, *ToLocationOrErr, + Importer.getToContext().getFixedPointScale(*ToTypeOrErr)); +} + ExpectedStmt ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { ExpectedType ToTypeOrErr = import(E->getType()); if (!ToTypeOrErr) Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -2271,6 +2271,10 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, ImaginaryLiteral> imaginaryLiteral; +/// Matches fixed point literals +extern const internal::VariadicDynCastAllOfMatcher<Stmt, FixedPointLiteral> + fixedPointLiteral; + /// Matches user defined literal operator call. /// /// Example match: "foo"_suffix
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits