Author: rsmith Date: Tue May 23 17:02:49 2017 New Revision: 303699 URL: http://llvm.org/viewvc/llvm-project?rev=303699&view=rev Log: [modules] When reparenting a local declaration, don't mark the declaration as being visible with its owning module if we're not tracking owning modules for local declarations.
This avoids the possibility of a declaration being (meaninglessly) marked as hidden with no owning module, which would otherwise lead to violated AST invariants (checked by the added assertion). Modified: cfe/trunk/lib/AST/DeclBase.cpp Modified: cfe/trunk/lib/AST/DeclBase.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=303699&r1=303698&r2=303699&view=diff ============================================================================== --- cfe/trunk/lib/AST/DeclBase.cpp (original) +++ cfe/trunk/lib/AST/DeclBase.cpp Tue May 23 17:02:49 2017 @@ -274,9 +274,17 @@ void Decl::setLexicalDeclContext(DeclCon } else { getMultipleDC()->LexicalDC = DC; } - Hidden = cast<Decl>(DC)->Hidden; - if (Hidden && !isFromASTFile() && hasLocalOwningModuleStorage()) - setLocalOwningModule(cast<Decl>(DC)->getOwningModule()); + + // FIXME: We shouldn't be changing the lexical context of declarations + // imported from AST files. + if (!isFromASTFile()) { + Hidden = cast<Decl>(DC)->Hidden && hasLocalOwningModuleStorage(); + if (Hidden) + setLocalOwningModule(cast<Decl>(DC)->getOwningModule()); + } + + assert((!Hidden || getOwningModule()) && + "hidden declaration has no owning module"); } void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits