[PATCH] D47632: [ASTImporter] Refactor Decl creation

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 26 02:48:56 PDT 2018


a.sidorin added a comment.

Hi Gabor!

I like the change but there are also some questions.



================
Comment at: lib/AST/ASTImporter.cpp:1659
+  AccessSpecDecl *ToD;
+  std::tie(ToD, AlreadyImported) = CreateDecl<AccessSpecDecl>(
+      D, Importer.getToContext(), D->getAccess(), DC, Loc, ColonLoc);
----------------
As I see, all usage samples require having a variable AlreadyImported used only once. How about changing the signature a bit:
```bool getOrCreateDecl(ToDeclTy *&ToD, FromDeclT *FromD, Args &&... args)```
with optional `LLVM_NODISCARD`? (Naming is a subject for discussion).
This signature also allows us to omit template arguments because we pass an argument of a templated type. So, the call will look like this:
```AccessSpecDecl *ToD;
if (getOrCreateDecl(ToD, D, Importer.getToContext(), D->getAccess(), DC, Loc, ColonLoc))
  return ToD;```


================
Comment at: lib/AST/ASTImporter.cpp:1922
       if (auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl))
-          return Importer.Imported(D, FoundAlias);
+          return Importer.MapImported(D, FoundAlias);
       ConflictingDecls.push_back(FoundDecl);
----------------
Could you also fix indentation here?


Repository:
  rC Clang

https://reviews.llvm.org/D47632





More information about the cfe-commits mailing list