[PATCH] D27181: [ASTImporter] Support for importing UsingDecl and UsingShadowDecl

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 09:10:33 PST 2016


a.sidorin added a comment.

Thank you Kareem, It looks mostly good, but I'd like to have some functional tests in ASTMerge for this patch.



================
Comment at: lib/AST/ASTImporter.cpp:4299
+  if (ImportDeclParts(D, DC, LexicalDC, Name, AlreadyImported, Loc))
+    return NULL;
+  assert(DC && "Null DeclContext after importing decl parts");
----------------
nullptr


================
Comment at: lib/AST/ASTImporter.cpp:4323
+  for (UsingShadowDecl *I : D->shadows()) {
+    UsingShadowDecl *SD = cast<UsingShadowDecl>(Importer.Import(I));
+    ToD->addShadowDecl(SD);
----------------
This will assert if import fails. We need to use `cast_or_null` and check for null returns. (If this is the result of my misleading code, sorry for this.)


================
Comment at: lib/AST/ASTImporter.cpp:4335
+  if (ImportDeclParts(D, DC, LexicalDC, Name, AlreadyImported, Loc))
+    return NULL;
+  assert(DC && "Null DeclContext after importing decl parts");
----------------
nullptr


================
Comment at: lib/AST/ASTImporter.cpp:4342
+        Importer.getToContext(), DC, Loc,
+        cast<UsingDecl>(Importer.Import(D->getUsingDecl())),
+        cast_or_null<NamedDecl>(Importer.Import(D->getTargetDecl())));
----------------
This will assert if import fails. We need to use cast_or_null and check for null returns.


https://reviews.llvm.org/D27181





More information about the cfe-commits mailing list