From b2e400aae8c62c4e1616016f40618baace0da065 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 18 Feb 2010 02:21:22 +0000 Subject: [PATCH] AST import for character literals git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96557 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTImporter.cpp | 11 +++++++++++ test/ASTMerge/Inputs/exprs1.c | 5 +++++ test/ASTMerge/Inputs/exprs2.c | 5 +++++ test/ASTMerge/exprs.c | 4 ++++ 4 files changed, 25 insertions(+) create mode 100644 test/ASTMerge/Inputs/exprs1.c create mode 100644 test/ASTMerge/Inputs/exprs2.c create mode 100644 test/ASTMerge/exprs.c diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index e064e78c1c..b57ef52f94 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -108,6 +108,7 @@ namespace { // Importing expressions Expr *VisitExpr(Expr *E); Expr *VisitIntegerLiteral(IntegerLiteral *E); + Expr *VisitCharacterLiteral(CharacterLiteral *E); Expr *VisitImplicitCastExpr(ImplicitCastExpr *E); }; } @@ -2598,6 +2599,16 @@ Expr *ASTNodeImporter::VisitIntegerLiteral(IntegerLiteral *E) { IntegerLiteral(E->getValue(), T, Importer.Import(E->getLocation())); } +Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { + QualType T = Importer.Import(E->getType()); + if (T.isNull()) + return 0; + + return new (Importer.getToContext()) CharacterLiteral(E->getValue(), + E->isWide(), T, + Importer.Import(E->getLocation())); +} + Expr *ASTNodeImporter::VisitImplicitCastExpr(ImplicitCastExpr *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) diff --git a/test/ASTMerge/Inputs/exprs1.c b/test/ASTMerge/Inputs/exprs1.c new file mode 100644 index 0000000000..f9de8df7fd --- /dev/null +++ b/test/ASTMerge/Inputs/exprs1.c @@ -0,0 +1,5 @@ +// Matching +enum E0 { + E0_Val0 = 'a' +}; + diff --git a/test/ASTMerge/Inputs/exprs2.c b/test/ASTMerge/Inputs/exprs2.c new file mode 100644 index 0000000000..f9de8df7fd --- /dev/null +++ b/test/ASTMerge/Inputs/exprs2.c @@ -0,0 +1,5 @@ +// Matching +enum E0 { + E0_Val0 = 'a' +}; + diff --git a/test/ASTMerge/exprs.c b/test/ASTMerge/exprs.c new file mode 100644 index 0000000000..0a4e1e51e2 --- /dev/null +++ b/test/ASTMerge/exprs.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/exprs1.c +// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/exprs2.c +// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s + -- 2.40.0