Use the real keyword location when rebuilding an elaborated type instead of

making something up.  Fixes PR8129.

llvm-svn: 118258
This commit is contained in:
John McCall 2010-11-04 19:04:38 +00:00
parent ed8b7bf9ed
commit 954b5de0d8
2 changed files with 11 additions and 7 deletions

View File

@ -618,7 +618,8 @@ namespace {
/// \brief Check for tag mismatches when instantiating an
/// elaborated type.
QualType RebuildElaboratedType(ElaboratedTypeKeyword Keyword,
QualType RebuildElaboratedType(SourceLocation KeywordLoc,
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS, QualType T);
ExprResult TransformPredefinedExpr(PredefinedExpr *E);
@ -743,14 +744,14 @@ VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
}
QualType
TemplateInstantiator::RebuildElaboratedType(ElaboratedTypeKeyword Keyword,
TemplateInstantiator::RebuildElaboratedType(SourceLocation KeywordLoc,
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS,
QualType T) {
if (const TagType *TT = T->getAs<TagType>()) {
TagDecl* TD = TT->getDecl();
// FIXME: this location is very wrong; we really need typelocs.
SourceLocation TagLocation = TD->getTagKeywordLoc();
SourceLocation TagLocation = KeywordLoc;
// FIXME: type might be anonymous.
IdentifierInfo *Id = TD->getIdentifier();
@ -769,7 +770,8 @@ TemplateInstantiator::RebuildElaboratedType(ElaboratedTypeKeyword Keyword,
}
}
return TreeTransform<TemplateInstantiator>::RebuildElaboratedType(Keyword,
return TreeTransform<TemplateInstantiator>::RebuildElaboratedType(KeywordLoc,
Keyword,
NNS, T);
}

View File

@ -522,7 +522,8 @@ public:
/// By default, builds a new ElaboratedType type from the keyword,
/// the nested-name-specifier and the named type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildElaboratedType(ElaboratedTypeKeyword Keyword,
QualType RebuildElaboratedType(SourceLocation KeywordLoc,
ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS, QualType Named) {
return SemaRef.Context.getElaboratedType(Keyword, NNS, Named);
}
@ -3340,7 +3341,8 @@ TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
if (getDerived().AlwaysRebuild() ||
NNS != T->getQualifier() ||
NamedT != T->getNamedType()) {
Result = getDerived().RebuildElaboratedType(T->getKeyword(), NNS, NamedT);
Result = getDerived().RebuildElaboratedType(TL.getKeywordLoc(),
T->getKeyword(), NNS, NamedT);
if (Result.isNull())
return QualType();
}