[PATCH] D43012: [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 9 08:23:02 PST 2018


a.sidorin marked 2 inline comments as done.
a.sidorin added inline comments.


================
Comment at: lib/AST/ASTImporter.cpp:4296
   // Create the declaration that is being templated.
-  SourceLocation StartLoc = Importer.Import(DTemplated->getLocStart());
-  SourceLocation IdLoc = Importer.Import(DTemplated->getLocation());
-  TypeSourceInfo *TInfo = Importer.Import(DTemplated->getTypeSourceInfo());
-  VarDecl *D2Templated = VarDecl::Create(Importer.getToContext(), DC, StartLoc,
-                                         IdLoc, Name.getAsIdentifierInfo(), T,
-                                         TInfo, DTemplated->getStorageClass());
-  D2Templated->setAccess(DTemplated->getAccess());
-  D2Templated->setQualifierInfo(Importer.Import(DTemplated->getQualifierLoc()));
-  D2Templated->setLexicalDeclContext(LexicalDC);
-
-  // Importer.Imported(DTemplated, D2Templated);
-  // LexicalDC->addDeclInternal(D2Templated);
-
-  // Merge the initializer.
-  if (ImportDefinition(DTemplated, D2Templated))
+  VarDecl *ToTemplated = dyn_cast_or_null<VarDecl>(Importer.Import(DTemplated));
+  if (!ToTemplated)
----------------
xazax.hun wrote:
> `auto *` to not repeat type.
I usually prefer to keep the type if it doesn't give a large space win because it hurts readability a bit. From `VarDecl *`, we can instantly find the type; for `auto`, we have to look forward. (Yes, VarTemplatePartialSpecializationDecl has to be replaced immediately :) ).
Other issue is that QtCreator I use for development still doesn't have an autocompletion for auto types. However, LLVM says: "do use auto with initializers like cast<Foo>(...)", so I'll change this.



Repository:
  rC Clang

https://reviews.llvm.org/D43012





More information about the cfe-commits mailing list