summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-09-20 01:15:31 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-09-20 01:15:31 +0000
commit541b38be7bf3afded3269a33586418254d82d7b3 (patch)
tree50251df12a54fbe196671445b8eee3d1a785b8cd /clang/lib/Serialization
parent508939428d005dff37df7f2131aeb06ed674b719 (diff)
downloadbcm5719-llvm-541b38be7bf3afded3269a33586418254d82d7b3.tar.gz
bcm5719-llvm-541b38be7bf3afded3269a33586418254d82d7b3.zip
Switch the semantic DeclContext for a block-scope declaration of a function or
variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index a9225fc81be..0d8e05711ee 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -946,7 +946,13 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
VD->VarDeclBits.ARCPseudoStrong = Record[Idx++];
VD->VarDeclBits.IsConstexpr = Record[Idx++];
VD->VarDeclBits.PreviousDeclInSameBlockScope = Record[Idx++];
- VD->setCachedLinkage(Linkage(Record[Idx++]));
+ Linkage VarLinkage = Linkage(Record[Idx++]);
+ VD->setCachedLinkage(VarLinkage);
+
+ // Reconstruct the one piece of the IdentifierNamespace that we need.
+ if (VarLinkage != NoLinkage &&
+ VD->getLexicalDeclContext()->isFunctionOrMethod())
+ VD->setLocalExternDecl();
// Only true variables (not parameters or implicit parameters) can be merged.
if (VD->getKind() != Decl::ParmVar && VD->getKind() != Decl::ImplicitParam)
@@ -2199,8 +2205,6 @@ void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) {
//
// FIXME: In this case, the declaration should only be visible if a module
// that makes it visible has been imported.
- // FIXME: This is not correct in the case where previous is a local extern
- // declaration and D is a friend declaraton.
D->IdentifierNamespace |=
previous->IdentifierNamespace &
(Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Type);
OpenPOWER on IntegriCloud