From 89cc9d6e2aaf794fbd2c228a3755c19062ca0ba0 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 9 Feb 2010 22:48:33 +0000 Subject: [PATCH] Complain about types and declarations that we don't know how to import. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95706 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticASTKinds.td | 1 + lib/AST/ASTImporter.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/clang/Basic/DiagnosticASTKinds.td b/include/clang/Basic/DiagnosticASTKinds.td index d6921df0a3..935d15ac13 100644 --- a/include/clang/Basic/DiagnosticASTKinds.td +++ b/include/clang/Basic/DiagnosticASTKinds.td @@ -34,4 +34,5 @@ def err_odr_variable_multiple_def : Error< "external variable %0 defined in multiple translation units">; def note_odr_value_here : Note<"declared here with type %0">; def note_odr_defined_here : Note<"also defined here">; +def err_unsupported_ast_node: Error<"cannot import unsupported AST node %0">; } diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 0d1a0dca75..19ce889513 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -33,6 +33,7 @@ namespace { using DeclVisitor::Visit; // Importing types + QualType VisitType(Type *T); QualType VisitBuiltinType(BuiltinType *T); QualType VisitComplexType(ComplexType *T); QualType VisitPointerType(PointerType *T); @@ -68,6 +69,7 @@ namespace { QualType VisitObjCObjectPointerType(ObjCObjectPointerType *T); // Importing declarations + Decl *VisitDecl(Decl *D); Decl *VisitVarDecl(VarDecl *D); }; } @@ -76,6 +78,12 @@ namespace { // Import Types //---------------------------------------------------------------------------- +QualType ASTNodeImporter::VisitType(Type *T) { + Importer.FromDiag(SourceLocation(), diag::err_unsupported_ast_node) + << T->getTypeClassName(); + return QualType(); +} + QualType ASTNodeImporter::VisitBuiltinType(BuiltinType *T) { switch (T->getKind()) { case BuiltinType::Void: return Importer.getToContext().VoidTy; @@ -435,6 +443,12 @@ QualType ASTNodeImporter::VisitObjCObjectPointerType(ObjCObjectPointerType *T) { //---------------------------------------------------------------------------- // Import Declarations //---------------------------------------------------------------------------- +Decl *ASTNodeImporter::VisitDecl(Decl *D) { + Importer.FromDiag(SourceLocation(), diag::err_unsupported_ast_node) + << D->getDeclKindName(); + return 0; +} + Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) { // Import the context of this declaration. DeclContext *DC = Importer.ImportContext(D->getDeclContext());