[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 8 02:34:21 PDT 2018


a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Looks good!



================
Comment at: lib/AST/ASTImporter.cpp:2650
+  for (const auto *A : D->attrs())
+    ToIndirectField->addAttr(Importer.Import(const_cast<Attr *>(A)));
 
----------------
r.stahl wrote:
> a.sidorin wrote:
> > Could we just remove 'const' qualifier from `A` to avoid `const_cast`? (Same below)
> I made the interface const instead.
Yes, that's even better!


================
Comment at: lib/AST/ASTImporter.cpp:4724
   SmallVector<const Attr *, 1> ToAttrs(FromAttrs.size());
-  ASTContext &_ToContext = Importer.getToContext();
   std::transform(FromAttrs.begin(), FromAttrs.end(), ToAttrs.begin(),
+    [this](const Attr *A) -> const Attr * {
----------------
a.sidorin wrote:
> Could we use ImportArrayChecked instead?
We can use just `ImportArrayChecked(FromAttrs, ToAttrs.begin())`. But this is more a hint than a requirement.


https://reviews.llvm.org/D46115





More information about the cfe-commits mailing list