From: John McCall Date: Thu, 4 Nov 2010 19:04:38 +0000 (+0000) Subject: Use the real keyword location when rebuilding an elaborated type instead of X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21e413fe6305a198564d436ac515497716c47844;p=clang Use the real keyword location when rebuilding an elaborated type instead of making something up. Fixes PR8129. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118258 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index f78fe81aa8..af9af0ab83 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -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()) { 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::RebuildElaboratedType(Keyword, + return TreeTransform::RebuildElaboratedType(KeywordLoc, + Keyword, NNS, T); } diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index d318bc6e5c..41d8f2a711 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -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::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(); }