summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-10-05 20:05:21 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-10-05 20:05:21 +0000
commit42fd9efa38e6f6e04824ede2cbb8bb1f73d0e9ad (patch)
treee2729d331ebba930eeed3c798bac69830c95f687 /clang/lib/Sema/SemaExpr.cpp
parent478a8eb2b6da49b2f018c1ed925c9e4ee4213ae8 (diff)
downloadbcm5719-llvm-42fd9efa38e6f6e04824ede2cbb8bb1f73d0e9ad.tar.gz
bcm5719-llvm-42fd9efa38e6f6e04824ede2cbb8bb1f73d0e9ad.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp43
1 files changed, 1 insertions, 42 deletions
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<CXXRecordDecl>(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<UnresolvedLookupExpr>(
- 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<CXXMethodDecl>(MemberFTD->getTemplatedDecl());
- else
- DepMethod = CurMethod;
- } else {
- DepMethod = cast<CXXMethodDecl>(
- 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;
}
OpenPOWER on IntegriCloud