diff options
| author | John McCall <rjmccall@apple.com> | 2010-04-06 21:38:20 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-04-06 21:38:20 +0000 |
| commit | a8ae222d0e8ba667c3aadbd1a146b7de1afd3513 (patch) | |
| tree | f5aca4ad37193044a41d8ab53fae11c6954d5fa8 /clang/lib/AST/Decl.cpp | |
| parent | 4dac890600ea2265bd87ba4c903281ae5d08269e (diff) | |
| download | bcm5719-llvm-a8ae222d0e8ba667c3aadbd1a146b7de1afd3513.tar.gz bcm5719-llvm-a8ae222d0e8ba667c3aadbd1a146b7de1afd3513.zip | |
Implement the protected access restriction ([class.protected]), which requires
that protected members be used on objects of types which derive from the
naming class of the lookup. My first N attempts at this were poorly-founded,
largely because the standard is very badly worded here.
llvm-svn: 100562
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index dc9fb59e309..3f2baf7c9c5 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -494,6 +494,24 @@ NamedDecl *NamedDecl::getUnderlyingDecl() { } } +bool NamedDecl::isCXXInstanceMember() const { + assert(isCXXClassMember() && + "checking whether non-member is instance member"); + + const NamedDecl *D = this; + if (isa<UsingShadowDecl>(D)) + D = cast<UsingShadowDecl>(D)->getTargetDecl(); + + if (isa<FieldDecl>(D)) + return true; + if (isa<CXXMethodDecl>(D)) + return cast<CXXMethodDecl>(D)->isInstance(); + if (isa<FunctionTemplateDecl>(D)) + return cast<CXXMethodDecl>(cast<FunctionTemplateDecl>(D) + ->getTemplatedDecl())->isInstance(); + return false; +} + //===----------------------------------------------------------------------===// // DeclaratorDecl Implementation //===----------------------------------------------------------------------===// |

