diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-03 21:38:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-03 21:38:09 +0000 |
commit | 2b6ca46c6b66096bc5dfc6f82c46cfb1761f4f53 (patch) | |
tree | 7881f432fe5f94b677450a7615703ef1e31e3782 /clang/lib/Sema/SemaExpr.cpp | |
parent | 59a1cd4a063a65983551a73dd858116fe2a01bbc (diff) | |
download | bcm5719-llvm-2b6ca46c6b66096bc5dfc6f82c46cfb1761f4f53.tar.gz bcm5719-llvm-2b6ca46c6b66096bc5dfc6f82c46cfb1761f4f53.zip |
Improve template instantiation for member access expressions that
involve qualified names, e.g., x->Base::f. We now maintain enough
information in the AST to compare the results of the name lookup of
"Base" in the scope of the postfix-expression (determined at template
definition time) and in the type of the object expression.
llvm-svn: 80953
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 394bc979277..720217a9103 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1989,7 +1989,8 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, const TemplateArgument *ExplicitTemplateArgs, unsigned NumExplicitTemplateArgs, SourceLocation RAngleLoc, - DeclPtrTy ObjCImpDecl, const CXXScopeSpec *SS) { + DeclPtrTy ObjCImpDecl, const CXXScopeSpec *SS, + NamedDecl *FirstQualifierInScope) { if (SS && SS->isInvalid()) return ExprError(); @@ -2022,14 +2023,23 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // Get the type being accessed in BaseType. If this is an arrow, the BaseExpr // must have pointer type, and the accessed type is the pointee. if (OpKind == tok::arrow) { - if (BaseType->isDependentType()) + if (BaseType->isDependentType()) { + NestedNameSpecifier *Qualifier = 0; + if (SS) { + Qualifier = static_cast<NestedNameSpecifier *>(SS->getScopeRep()); + if (!FirstQualifierInScope) + FirstQualifierInScope = FindFirstQualifierInScope(S, Qualifier); + } + return Owned(new (Context) CXXUnresolvedMemberExpr(Context, BaseExpr, true, OpLoc, - (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0), + Qualifier, SS? SS->getRange() : SourceRange(), + FirstQualifierInScope, MemberName, MemberLoc)); + } else if (const PointerType *PT = BaseType->getAs<PointerType>()) BaseType = PT->getPointeeType(); else if (BaseType->isObjCObjectPointerType()) @@ -2051,14 +2061,23 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, const PointerType *PT = BaseType->getAs<PointerType>(); if (!PT || (getLangOptions().ObjC1 && - !PT->getPointeeType()->isRecordType())) + !PT->getPointeeType()->isRecordType())) { + NestedNameSpecifier *Qualifier = 0; + if (SS) { + Qualifier = static_cast<NestedNameSpecifier *>(SS->getScopeRep()); + if (!FirstQualifierInScope) + FirstQualifierInScope = FindFirstQualifierInScope(S, Qualifier); + } + return Owned(new (Context) CXXUnresolvedMemberExpr(Context, BaseExpr, false, OpLoc, - (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0), + Qualifier, SS? SS->getRange() : SourceRange(), + FirstQualifierInScope, MemberName, MemberLoc)); + } } } |