summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-03-01 16:31:39 +0000
committerDouglas Gregor <dgregor@apple.com>2011-03-01 16:31:39 +0000
commitbf5fe47b128f16ad601204763442af72fe0c39c0 (patch)
treebe1e393de32d26d02764708e980a2ec68c3bcc07 /clang/lib/Sema/SemaTemplate.cpp
parent62a60c50f4fb78f731d4b9d02ad9905afe588671 (diff)
downloadbcm5719-llvm-bf5fe47b128f16ad601204763442af72fe0c39c0.tar.gz
bcm5719-llvm-bf5fe47b128f16ad601204763442af72fe0c39c0.zip
Reinstate r126737, extending the generation of type-source location
information for qualifier type names throughout the parser to address several problems. The commit message from r126737: Push nested-name-specifier source location information into elaborated name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind". Aside from the normal changes, this also required some tweaks to the parser. Essentially, when we're looking at a type name (via getTypeName()) specifically for the purpose of creating an annotation token, we pass down the flag that asks for full type-source location information to be stored within the returned type. That way, we retain source-location information involving nested-name-specifiers rather than trying to reconstruct that information later, long after it's been lost in the parser. With this change, test/Index/recursive-cxx-member-calls.cpp is showing much improved results again, since that code has lots of nested-name-specifiers. llvm-svn: 126748
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index cdb35a20c09..fbb72465335 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1821,12 +1821,12 @@ TypeResult Sema::ActOnTagTemplateIdType(CXXScopeSpec &SS,
ElaboratedTypeKeyword Keyword
= TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
- QualType ElabType = Context.getElaboratedType(Keyword, /*NNS=*/0, Type);
+ QualType ElabType = Context.getElaboratedType(Keyword, SS.getScopeRep(), Type);
TypeSourceInfo *ElabDI = Context.CreateTypeSourceInfo(ElabType);
ElaboratedTypeLoc TL = cast<ElaboratedTypeLoc>(ElabDI->getTypeLoc());
TL.setKeywordLoc(TagLoc);
- TL.setQualifierRange(SS.getRange());
+ TL.setQualifierLoc(SS.getWithLocInContext(Context));
TL.getNamedTypeLoc().initializeFullCopy(DI->getTypeLoc());
return CreateParsedType(ElabType, ElabDI);
}
@@ -5910,8 +5910,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
<< FixItHint::CreateRemoval(TypenameLoc);
NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
- QualType T = CheckTypenameType(ETK_Typename, TypenameLoc, QualifierLoc,
- II, IdLoc);
+ QualType T = CheckTypenameType(TypenameLoc.isValid()? ETK_Typename : ETK_None,
+ TypenameLoc, QualifierLoc, II, IdLoc);
if (T.isNull())
return true;
@@ -5924,7 +5924,7 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
} else {
ElaboratedTypeLoc TL = cast<ElaboratedTypeLoc>(TSI->getTypeLoc());
TL.setKeywordLoc(TypenameLoc);
- TL.setQualifierRange(SS.getRange());
+ TL.setQualifierLoc(QualifierLoc);
cast<TypeSpecTypeLoc>(TL.getNamedTypeLoc()).setNameLoc(IdLoc);
}
@@ -5964,7 +5964,7 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
// type.
TypeLocBuilder Builder;
TemplateSpecializationTypeLoc SpecTL
- = Builder.push<TemplateSpecializationTypeLoc>(T);
+ = Builder.push<TemplateSpecializationTypeLoc>(T);
// FIXME: No place to set the location of the 'template' keyword!
SpecTL.setLAngleLoc(LAngleLoc);
@@ -5973,14 +5973,10 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
SpecTL.setArgLocInfo(I, TemplateArgs[I].getLocInfo());
- // FIXME: This is a hack. We really want to push the nested-name-specifier
- // into TemplateSpecializationType.
-
- /* Note: NNS already embedded in template specialization type T. */
- T = Context.getElaboratedType(ETK_Typename, /*NNS=*/0, T);
+ T = Context.getElaboratedType(ETK_Typename, SS.getScopeRep(), T);
ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T);
TL.setKeywordLoc(TypenameLoc);
- TL.setQualifierRange(SS.getRange());
+ TL.setQualifierLoc(SS.getWithLocInContext(Context));
TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T);
return CreateParsedType(T, TSI);
OpenPOWER on IntegriCloud