[PATCH] D123685: [clang][ASTImporter] Add isNewDecl

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 6 08:40:46 PDT 2022


xazax.hun added inline comments.


================
Comment at: clang/include/clang/AST/ASTImporterSharedState.h:43
+  /// Set of the newly created declarations.
+  llvm::DenseSet<Decl *> NewDecls;
+
----------------
ASTImporter already has something like `ImportedFromDecls`. Is that not sufficient to check if a declaration is new?

Is it possible that we may want the "degree" of the imported definition? I.e., how many hops did we do to import it (is it imported as a result of evaluating an imported call?).


================
Comment at: clang/include/clang/AST/ASTImporterSharedState.h:81
+
+  bool isNewDecl(const Decl *ToD) const { return NewDecls.count(ToD); }
+
----------------
I assume this would only be applicable for definitions, so I wonder whether `IsNewDefinition()` would be more descriptive. Or maybe `IsImportedDefinition`? 


================
Comment at: clang/lib/AST/ASTImporter.cpp:248
       Importer.RegisterImportedDecl(FromD, ToD);
+      Importer.SharedState->setNewDecl(ToD);
       InitializeImportedDecl(FromD, ToD);
----------------
Should this be part of `Importer.RegisterImportedDecl`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123685/new/

https://reviews.llvm.org/D123685



More information about the cfe-commits mailing list