diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-23 22:02:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-23 22:02:49 +0000 |
commit | 9b792b1316cc1cd30915605974aa50e537b1f1d0 (patch) | |
tree | 95a74da3a4ba5b44770aebe492af8f49ab0da108 /lib/AST/DeclBase.cpp | |
parent | ed911ada8c59bf5af2d5a1476e8a5b48893ffc22 (diff) | |
download | clang-9b792b1316cc1cd30915605974aa50e537b1f1d0.tar.gz |
[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).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 81cd1cc426..085fb52293 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -274,9 +274,17 @@ void Decl::setLexicalDeclContext(DeclContext *DC) { } 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, |