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 | ae50c56d651d5b8dccf59a4c6a2ff2a30973a62f (patch) | |
tree | 12b8b7e2a74ee1b5185db8df5ffdc3fbf625944c /clang/lib/AST/DeclBase.cpp | |
parent | 9017ca290aba42802a42b5d5eb4e04b754518df9 (diff) | |
download | bcm5719-llvm-ae50c56d651d5b8dccf59a4c6a2ff2a30973a62f.tar.gz bcm5719-llvm-ae50c56d651d5b8dccf59a4c6a2ff2a30973a62f.zip |
[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).
llvm-svn: 303699
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 81cd1cc4265..085fb522932 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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, |