[PATCH] D54898: Set MustBuildLookupTable on PrimaryContext in ExternalASTMerger

Raphael Isemann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 26 07:28:33 PST 2018


teemperor created this revision.
teemperor added reviewers: martong, a.sidorin.
teemperor added a project: LLDB.
Herald added subscribers: cfe-commits, rnkovacs.

`MustBuildLookupTable` must always be called on a primary context as we otherwise
trigger an assert, but we don't ensure that this will always happen in our code right now.

This patch explicitly requests the primary context when doing this call as this shouldn't break
anything (as calling `getPrimaryContext` on a context which is its own primary context is a no-op) 
but will catch these rare cases where we somehow operate on a declaration context that is
not its own primary context.

See also D54863 <https://reviews.llvm.org/D54863>.


Repository:
  rC Clang

https://reviews.llvm.org/D54898

Files:
  lib/AST/ExternalASTMerger.cpp


Index: lib/AST/ExternalASTMerger.cpp
===================================================================
--- lib/AST/ExternalASTMerger.cpp
+++ lib/AST/ExternalASTMerger.cpp
@@ -144,14 +144,14 @@
     }
     if (auto *ToTag = dyn_cast<TagDecl>(To)) {
       ToTag->setHasExternalLexicalStorage();
-      ToTag->setMustBuildLookupTable();
+      ToTag->getPrimaryContext()->setMustBuildLookupTable();
       assert(Parent.CanComplete(ToTag));
     } else if (auto *ToNamespace = dyn_cast<NamespaceDecl>(To)) {
       ToNamespace->setHasExternalVisibleStorage();
       assert(Parent.CanComplete(ToNamespace));
     } else if (auto *ToContainer = dyn_cast<ObjCContainerDecl>(To)) {
       ToContainer->setHasExternalLexicalStorage();
-      ToContainer->setMustBuildLookupTable();
+      ToContainer->getPrimaryContext()->setMustBuildLookupTable();
       assert(Parent.CanComplete(ToContainer));
     }
     return To;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54898.175213.patch
Type: text/x-patch
Size: 917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181126/95d7c006/attachment.bin>


More information about the cfe-commits mailing list