summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/DeclBase.cpp16
-rw-r--r--clang/lib/AST/DeclCXX.cpp9
2 files changed, 22 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 2d276614f22..0f7c4dcc0d6 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -198,6 +198,9 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
case ObjCProperty:
case ObjCCompatibleAlias:
return IDNS_Ordinary;
+
+ case FriendFunction:
+ return IDNS_Friend;
case ObjCProtocol:
return IDNS_ObjCProtocol;
@@ -583,7 +586,7 @@ bool DeclContext::decls_empty() const {
return !FirstDecl;
}
-void DeclContext::addDecl(Decl *D) {
+void DeclContext::addHiddenDecl(Decl *D) {
assert(D->getLexicalDeclContext() == this &&
"Decl inserted into wrong lexical context");
assert(!D->getNextDeclInContext() && D != LastDecl &&
@@ -595,6 +598,10 @@ void DeclContext::addDecl(Decl *D) {
} else {
FirstDecl = LastDecl = D;
}
+}
+
+void DeclContext::addDecl(Decl *D) {
+ addHiddenDecl(D);
if (NamedDecl *ND = dyn_cast<NamedDecl>(D))
ND->getDeclContext()->makeDeclVisibleInContext(ND);
@@ -608,9 +615,12 @@ void DeclContext::buildLookup(DeclContext *DCtx) {
for (decl_iterator D = DCtx->decls_begin(),
DEnd = DCtx->decls_end();
D != DEnd; ++D) {
- // Insert this declaration into the lookup structure
+ // Insert this declaration into the lookup structure, but only
+ // if it's semantically in its decl context. During non-lazy
+ // lookup building, this is implicitly enforced by addDecl.
if (NamedDecl *ND = dyn_cast<NamedDecl>(*D))
- makeDeclVisibleInContextImpl(ND);
+ if (D->getDeclContext() == DCtx)
+ makeDeclVisibleInContextImpl(ND);
// If this declaration is itself a transparent declaration context,
// add its members (recursively).
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index a302fd87f44..f85091e4f56 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -738,6 +738,15 @@ bool OverloadIterator::Equals(const OverloadIterator &Other) const {
return !isa<OverloadedFunctionDecl>(D) || Iter == Other.Iter;
}
+FriendFunctionDecl *FriendFunctionDecl::Create(ASTContext &C,DeclContext *DC,
+ SourceLocation L,
+ DeclarationName N, QualType T,
+ bool isInline,
+ SourceLocation FriendL) {
+ return new (C) FriendFunctionDecl(DC, L, N, T, isInline, FriendL);
+}
+
+
LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
DeclContext *DC,
SourceLocation L,
OpenPOWER on IntegriCloud