diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-07 02:33:37 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-07 02:33:37 +0000 |
commit | c3d2ebb60f6048cf99a5c30ce77b9ec9118b635b (patch) | |
tree | 097f01e3d2d992fa92d4396cd9c85b84ae9227ea /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | a1acb49188281013ca1eea3ab1b758f1adef0377 (diff) | |
download | bcm5719-llvm-c3d2ebb60f6048cf99a5c30ce77b9ec9118b635b.tar.gz bcm5719-llvm-c3d2ebb60f6048cf99a5c30ce77b9ec9118b635b.zip |
PR16243: Use CXXThisOverride during template instantiation, and fix up the
places which weren't setting it up properly. This allows us to get the right
cv-qualifiers for 'this' when it appears outside a method body in a class
template.
llvm-svn: 183483
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 09ddd9db658..9d1757d878d 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -142,6 +142,13 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, Saved = CurrentInstantiationScope->cloneScopes(OuterMostScope); LateAttrs->push_back(LateInstantiatedAttribute(TmplAttr, Saved, New)); } else { + // Allow 'this' within late-parsed attributes. + NamedDecl *ND = dyn_cast<NamedDecl>(New); + CXXRecordDecl *ThisContext = + dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()); + CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/0, + ND && ND->isCXXInstanceMember()); + Attr *NewAttr = sema::instantiateTemplateAttribute(TmplAttr, Context, *this, TemplateArgs); if (NewAttr) @@ -2449,7 +2456,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, CXXRecordDecl *ThisContext = 0; unsigned ThisTypeQuals = 0; if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) { - ThisContext = Method->getParent(); + ThisContext = cast<CXXRecordDecl>(Owner); ThisTypeQuals = Method->getTypeQualifiers(); } @@ -2585,8 +2592,7 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, bool Expand = false; bool RetainExpansion = false; - Optional<unsigned> NumExpansions - = PackExpansion->getNumExpansions(); + Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions(); if (SemaRef.CheckParameterPacksForExpansion(New->getLocation(), SourceRange(), Unexpanded, |