Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -1975,6 +1975,11 @@ extern const internal::VariadicDynCastAllOfMatcher floatLiteral; +/// Matches imaginary literals, which are based on integer and floating +/// point literals e.g.: 1i, 1.0i +extern const internal::VariadicDynCastAllOfMatcher + imaginaryLiteral; + /// Matches user defined literal operator call. /// /// Example match: "foo"_suffix Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -412,6 +412,7 @@ Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E); Expr *VisitIntegerLiteral(IntegerLiteral *E); Expr *VisitFloatingLiteral(FloatingLiteral *E); + Expr *VisitImaginaryLiteral(ImaginaryLiteral *E); Expr *VisitCharacterLiteral(CharacterLiteral *E); Expr *VisitStringLiteral(StringLiteral *E); Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E); @@ -5594,6 +5595,7 @@ Importer.Import(E->getLocation())); } + Expr *ASTNodeImporter::VisitFloatingLiteral(FloatingLiteral *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) @@ -5604,6 +5606,19 @@ Importer.Import(E->getLocation())); } +Expr *ASTNodeImporter::VisitImaginaryLiteral(ImaginaryLiteral *E) { + QualType T = Importer.Import(E->getType()); + if (T.isNull()) + return nullptr; + + Expr *SubE = Importer.Import(E->getSubExpr()); + if (!SubE) + return nullptr; + + return new (Importer.getToContext()) + ImaginaryLiteral(SubE, T); +} + Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) Index: lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- lib/ASTMatchers/ASTMatchersInternal.cpp +++ lib/ASTMatchers/ASTMatchersInternal.cpp @@ -710,6 +710,7 @@ const internal::VariadicDynCastAllOfMatcher integerLiteral; const internal::VariadicDynCastAllOfMatcher floatLiteral; +const internal::VariadicDynCastAllOfMatcher imaginaryLiteral; const internal::VariadicDynCastAllOfMatcher userDefinedLiteral; const internal::VariadicDynCastAllOfMatcher Index: unittests/AST/ASTImporterTest.cpp =================================================================== --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -553,6 +553,14 @@ floatLiteral(equals(1.0e-5f), hasType(asString("float")))))); } +TEST_P(ImportExpr, ImportImaginaryLiteralExpr) { + MatchVerifier Verifier; + testImport( + "void declToImport() { (void)1.0i; }", + Lang_CXX14, "", Lang_CXX14, Verifier, + functionDecl(hasDescendant(imaginaryLiteral()))); +} + TEST_P(ImportExpr, ImportCompoundLiteralExpr) { MatchVerifier Verifier; testImport(