From 8cc64716c297df8b4d95692391368fb6d325198e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 22 Oct 2014 19:54:16 +0000 Subject: [PATCH] Correct importing of the type of a TemplateArgument It's not clear how this would be tested - I imagine we should have an ASTImporter test that RAVs the new AST and checks that all the elements in it are from this ASTContext and not the foreign one... but I know little about the ASTImporter and how/where that testing might be done. (post-commit review feedback from Richard Smith on r219900) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220411 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTImporter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 02864a5d4d..07b2a73ee8 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2092,10 +2092,11 @@ ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) { } case TemplateArgument::Declaration: { - ValueDecl *FromD = From.getAsDecl(); - if (ValueDecl *To = cast_or_null(Importer.Import(FromD))) - return TemplateArgument(To, From.getParamTypeForDecl()); - return TemplateArgument(); + ValueDecl *To = cast_or_null(Importer.Import(From.getAsDecl())); + QualType ToType = Importer.Import(From.getParamTypeForDecl()); + if (!To || ToType.isNull()) + return TemplateArgument(); + return TemplateArgument(To, ToType); } case TemplateArgument::NullPtr: { -- 2.40.0