[cfe-commits] r119697 - in /cfe/trunk: include/clang/AST/TypeLoc.h include/clang/Sema/Sema.h lib/AST/TypeLoc.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/SemaTemplate.cpp
Craig Silverstein
csilvers2000 at yahoo.com
Thu Nov 18 00:32:02 PST 2010
Author: csilvers
Date: Thu Nov 18 02:32:02 2010
New Revision: 119697
URL: http://llvm.org/viewvc/llvm-project?rev=119697&view=rev
Log:
In some situations, TemplateArgumentLoc wasn't setting TypeSourceLoc (see
http://llvm.org/bugs/show_bug.cgi?id=8558). This patch fixes it. Thanks to
rjmccall for all the coaching!
Approved by rjmccall
Modified:
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=119697&r1=119696&r2=119697&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Thu Nov 18 02:32:02 2010
@@ -124,6 +124,12 @@
initializeImpl(*this, Loc);
}
+ /// \brief Initializes this by copying its information from another
+ /// TypeLoc of the same type.
+ void initializeFullCopy(TypeLoc Other) const {
+ initializeFullCopyImpl(*this, Other);
+ }
+
friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
}
@@ -136,6 +142,7 @@
private:
static void initializeImpl(TypeLoc TL, SourceLocation Loc);
+ static void initializeFullCopyImpl(TypeLoc TL, TypeLoc Other);
static TypeLoc getNextTypeLocImpl(TypeLoc TL);
static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
};
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=119697&r1=119696&r2=119697&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Nov 18 02:32:02 2010
@@ -2869,10 +2869,11 @@
ASTTemplateArgsPtr TemplateArgs,
SourceLocation RAngleLoc);
- TypeResult ActOnTagTemplateIdType(TypeResult Type,
- TagUseKind TUK,
- TypeSpecifierType TagSpec,
- SourceLocation TagLoc);
+ TypeResult ActOnTagTemplateIdType(CXXScopeSpec &SS,
+ TypeResult Type,
+ TagUseKind TUK,
+ TypeSpecifierType TagSpec,
+ SourceLocation TagLoc);
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
LookupResult &R,
Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=119697&r1=119696&r2=119697&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Thu Nov 18 02:32:02 2010
@@ -94,6 +94,13 @@
}
}
+/// \brief Initializes a type location by copying all its data from
+/// another type location of the same type.
+void TypeLoc::initializeFullCopyImpl(TypeLoc TL, TypeLoc Other) {
+ assert(TL.getType() == Other.getType() && "Must copy from same type");
+ memcpy(TL.getOpaqueData(), Other.getOpaqueData(), TL.getFullDataSize());
+}
+
SourceLocation TypeLoc::getBeginLoc() const {
TypeLoc Cur = *this;
while (true) {
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=119697&r1=119696&r2=119697&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Nov 18 02:32:02 2010
@@ -908,7 +908,7 @@
TemplateArgsPtr,
TemplateId->RAngleLoc);
- TypeResult = Actions.ActOnTagTemplateIdType(TypeResult, TUK,
+ TypeResult = Actions.ActOnTagTemplateIdType(SS, TypeResult, TUK,
TagType, StartLoc);
} else {
// This is an explicit specialization or a class template
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=119697&r1=119696&r2=119697&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Nov 18 02:32:02 2010
@@ -1646,14 +1646,14 @@
return CreateParsedType(Result, DI);
}
-TypeResult Sema::ActOnTagTemplateIdType(TypeResult TypeResult,
+TypeResult Sema::ActOnTagTemplateIdType(CXXScopeSpec &SS,
+ TypeResult TypeResult,
TagUseKind TUK,
TypeSpecifierType TagSpec,
SourceLocation TagLoc) {
if (TypeResult.isInvalid())
return ::TypeResult();
- // FIXME: preserve source info, ideally without copying the DI.
TypeSourceInfo *DI;
QualType Type = GetTypeFromParser(TypeResult.get(), &DI);
@@ -1678,7 +1678,12 @@
= TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
QualType ElabType = Context.getElaboratedType(Keyword, /*NNS=*/0, Type);
- return ParsedType::make(ElabType);
+ TypeSourceInfo *ElabDI = Context.CreateTypeSourceInfo(ElabType);
+ ElaboratedTypeLoc TL = cast<ElaboratedTypeLoc>(ElabDI->getTypeLoc());
+ TL.setKeywordLoc(TagLoc);
+ TL.setQualifierRange(SS.getRange());
+ TL.getNamedTypeLoc().initializeFullCopy(DI->getTypeLoc());
+ return CreateParsedType(ElabType, ElabDI);
}
ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
More information about the cfe-commits
mailing list