summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-12-02 20:26:00 +0000
committerJohn McCall <rjmccall@apple.com>2009-12-02 20:26:00 +0000
commit5af0450a67c7bfa6826ea47039da28c1b6a447f5 (patch)
tree3a5e0e603f5a5be23659618ced9d1a51f9c8bb2e /clang/lib/Sema/SemaExpr.cpp
parent8dc27496c0c6a909607741167943acc5a31a7055 (diff)
downloadbcm5719-llvm-5af0450a67c7bfa6826ea47039da28c1b6a447f5.tar.gz
bcm5719-llvm-5af0450a67c7bfa6826ea47039da28c1b6a447f5.zip
Use a more rigorous definition of 'class member'. I don't have any evidence
that this was causing a problem, but it could have. llvm-svn: 90343
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8e1e0afaa64..dc0b6db0503 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -732,11 +732,23 @@ static bool IsProvablyNotDerivedFrom(Sema &SemaRef,
return true;
}
-static bool IsInstanceMember(NamedDecl *D) {
- if (isa<EnumConstantDecl>(D))
- return false;
+/// Determines if this a C++ class member.
+static bool IsClassMember(NamedDecl *D) {
+ DeclContext *DC = D->getDeclContext();
+
+ // C++0x [class.mem]p1:
+ // The enumerators of an unscoped enumeration defined in
+ // the class are members of the class.
+ // FIXME: support C++0x scoped enumerations.
+ if (isa<EnumDecl>(DC))
+ DC = DC->getParent();
- assert(isa<CXXRecordDecl>(D->getDeclContext()) &&
+ return DC->isRecord();
+}
+
+/// Determines if this is an instance member of a class.
+static bool IsInstanceMember(NamedDecl *D) {
+ assert(IsClassMember(D) &&
"checking whether non-member is instance member");
if (isa<FieldDecl>(D)) return true;
@@ -798,7 +810,7 @@ enum IMAKind {
/// not be caught until template-instantiation.
static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
const LookupResult &R) {
- assert(!R.empty() && isa<CXXRecordDecl>((*R.begin())->getDeclContext()));
+ assert(!R.empty() && IsClassMember(*R.begin()));
bool isStaticContext =
(!isa<CXXMethodDecl>(SemaRef.CurContext) ||
@@ -1010,7 +1022,7 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,
// class member access expression.
// But note that &SomeClass::foo is grammatically distinct, even
// though we don't parse it that way.
- if (!R.empty() && (*R.begin())->getDeclContext()->isRecord()) {
+ if (!R.empty() && IsClassMember(*R.begin())) {
bool isAbstractMemberPointer = (isAddressOfOperand && !SS.isEmpty());
if (!isAbstractMemberPointer) {
@@ -1274,7 +1286,7 @@ bool Sema::UseArgumentDependentLookup(const CXXScopeSpec &SS,
// -- a declaration of a class member
// Since using decls preserve this property, we check this on the
// original decl.
- if (D->getDeclContext()->isRecord())
+ if (IsClassMember(D))
return false;
// C++0x [basic.lookup.argdep]p3:
OpenPOWER on IntegriCloud