From 42fd9efa38e6f6e04824ede2cbb8bb1f73d0e9ad Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 5 Oct 2015 20:05:21 +0000 Subject: Revert r107690 (for PR7417) and add a testcase that it breaks. The approach of that change turns out to not be reasonable: mutating the AST of a parsed template during instantiation is not a sound thing to do, does not work across chained PCH / modules builds, and is in any case a special-case workaround to a more general problem that should be solved centrally. llvm-svn: 249342 --- clang/lib/Sema/SemaExpr.cpp | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 88ed127f3b9..7bf1938b86a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1804,8 +1804,7 @@ Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, // unqualified lookup. This is useful when (for example) the // original lookup would not have found something because it was a // dependent name. - DeclContext *DC = (SS.isEmpty() && !CallsUndergoingInstantiation.empty()) - ? CurContext : nullptr; + DeclContext *DC = SS.isEmpty() ? CurContext : nullptr; while (DC) { if (isa(DC)) { LookupQualifiedName(R, DC); @@ -1833,47 +1832,7 @@ Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, if (isInstance) { Diag(R.getNameLoc(), diagnostic) << Name << FixItHint::CreateInsertion(R.getNameLoc(), "this->"); - UnresolvedLookupExpr *ULE = cast( - CallsUndergoingInstantiation.back()->getCallee()); - - CXXMethodDecl *DepMethod; - if (CurMethod->isDependentContext()) { - DepMethod = CurMethod; - } else if (FunctionTemplateDecl *FTD = - CurMethod->getPrimaryTemplate()) { - // We have a member function template. It may be contained in a - // class template. If so, get the original pattern for the member - // function template. Otherwise, 'this' isn't dependent and we can - // use CurMethod as is. - if (FunctionTemplateDecl *MemberFTD = - FTD->getInstantiatedFromMemberTemplate()) - DepMethod = cast(MemberFTD->getTemplatedDecl()); - else - DepMethod = CurMethod; - } else { - DepMethod = cast( - CurMethod->getInstantiatedFromMemberFunction()); - } - assert(DepMethod && "No template pattern found"); - - QualType DepThisType = DepMethod->getThisType(Context); CheckCXXThisCapture(R.getNameLoc()); - CXXThisExpr *DepThis = new (Context) CXXThisExpr( - R.getNameLoc(), DepThisType, false); - TemplateArgumentListInfo TList; - if (ULE->hasExplicitTemplateArgs()) - ULE->copyTemplateArgumentsInto(TList); - - CXXScopeSpec SS; - SS.Adopt(ULE->getQualifierLoc()); - CXXDependentScopeMemberExpr *DepExpr = - CXXDependentScopeMemberExpr::Create( - Context, DepThis, DepThisType, true, SourceLocation(), - SS.getWithLocInContext(Context), - ULE->getTemplateKeywordLoc(), nullptr, - R.getLookupNameInfo(), - ULE->hasExplicitTemplateArgs() ? &TList : nullptr); - CallsUndergoingInstantiation.back()->setCallee(DepExpr); } else { Diag(R.getNameLoc(), diagnostic) << Name; } -- cgit v1.2.3