summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaAccess.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-08-24 22:54:02 +0000
committerJohn McCall <rjmccall@apple.com>2012-08-24 22:54:02 +0000
commite91aec7a57e345a9bd044b33629c5a5ab725f3dc (patch)
tree4e564198890fbaf9cfe3ba5f9237c6de6b30aab7 /clang/lib/Sema/SemaAccess.cpp
parent74352494a6cad86f432036142fb9bf5323147b85 (diff)
downloadbcm5719-llvm-e91aec7a57e345a9bd044b33629c5a5ab725f3dc.tar.gz
bcm5719-llvm-e91aec7a57e345a9bd044b33629c5a5ab725f3dc.zip
When computing the effective context for access control,
make sure we walk up the DC chain for the current context, rather than allowing ourselves to get switched over to the canonical DC chain. Fixes PR13642. llvm-svn: 162616
Diffstat (limited to 'clang/lib/Sema/SemaAccess.cpp')
-rw-r--r--clang/lib/Sema/SemaAccess.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index ed72a5600b7..58b1a51ae57 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/lib/Sema/SemaAccess.cpp
@@ -97,14 +97,19 @@ struct EffectiveContext {
// functions (which can gain privileges through friendship), but we
// take that as an oversight.
while (true) {
+ // We want to add canonical declarations to the EC lists for
+ // simplicity of checking, but we need to walk up through the
+ // actual current DC chain. Otherwise, something like a local
+ // extern or friend which happens to be the canonical
+ // declaration will really mess us up.
+
if (isa<CXXRecordDecl>(DC)) {
- CXXRecordDecl *Record = cast<CXXRecordDecl>(DC)->getCanonicalDecl();
- Records.push_back(Record);
+ CXXRecordDecl *Record = cast<CXXRecordDecl>(DC);
+ Records.push_back(Record->getCanonicalDecl());
DC = Record->getDeclContext();
} else if (isa<FunctionDecl>(DC)) {
- FunctionDecl *Function = cast<FunctionDecl>(DC)->getCanonicalDecl();
- Functions.push_back(Function);
-
+ FunctionDecl *Function = cast<FunctionDecl>(DC);
+ Functions.push_back(Function->getCanonicalDecl());
if (Function->getFriendObjectKind())
DC = Function->getLexicalDeclContext();
else
OpenPOWER on IntegriCloud