[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 27 06:41:50 PST 2018


martong marked 2 inline comments as done.
martong added inline comments.


================
Comment at: lib/AST/ExternalASTMerger.cpp:154
       ToContainer->setHasExternalLexicalStorage();
-      ToContainer->setMustBuildLookupTable();
+      ToContainer->getPrimaryContext()->setMustBuildLookupTable();
       assert(Parent.CanComplete(ToContainer));
----------------
a_sidorin wrote:
> Do we have to do the same for NamespaceDecls?
Yes, I think so.
The primary context of a `NamespaceDecl` can be other than itself:
```
DeclContext *DeclContext::getPrimaryContext() {
  switch (DeclKind) {
  case Decl::TranslationUnit:
  case Decl::ExternCContext:
  case Decl::LinkageSpec:
  case Decl::Export:
  case Decl::Block:
  case Decl::Captured:
  case Decl::OMPDeclareReduction:
    // There is only one DeclContext for these entities.
    return this;

  case Decl::Namespace:
    // The original namespace is our primary context.
    return static_cast<NamespaceDecl *>(this)->getOriginalNamespace();
```
Consequently, we should call `setMustBuildLookupTable` only on a `NamespaceDecl` if we know for sure that is a primary context.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53755





More information about the cfe-commits mailing list