aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-20 15:39:42 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-20 15:39:42 +0000
commit81d3466d037dc5844234c7a93dab21a6ad986e7d (patch)
tree96500ef0d904af631151e38ae92ce41b8e498a7d /lib
parenta4f0a80e7367bad218ffe1f8ab1b380f690276ce (diff)
Keep proper source location information for the type in an Objective-C
@encode expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Frontend/PCHReaderStmt.cpp2
-rw-r--r--lib/Frontend/PCHWriterStmt.cpp2
-rw-r--r--lib/Sema/Sema.h2
-rw-r--r--lib/Sema/SemaExprObjC.cpp13
-rw-r--r--lib/Sema/TreeTransform.h15
5 files changed, 19 insertions, 15 deletions
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index 2c954a68ac..60318dee77 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -725,7 +725,7 @@ unsigned PCHStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
unsigned PCHStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
VisitExpr(E);
- E->setEncodedType(Reader.GetType(Record[Idx++]));
+ E->setEncodedTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
E->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 0;
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index 9a5417ca61..9c9f891115 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -655,7 +655,7 @@ void PCHStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
void PCHStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
VisitExpr(E);
- Writer.AddTypeRef(E->getEncodedType(), Record);
+ Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record);
Writer.AddSourceLocation(E->getAtLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_OBJC_ENCODE;
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 0535923d6b..2578332743 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -2411,7 +2411,7 @@ public:
unsigned NumStrings);
Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
- QualType EncodedType,
+ TypeSourceInfo *EncodedTypeInfo,
SourceLocation RParenLoc);
CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp,
NamedDecl *FoundDecl,
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index ad95f00d24..ce06abec4d 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -95,8 +95,9 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
}
Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
- QualType EncodedType,
+ TypeSourceInfo *EncodedTypeInfo,
SourceLocation RParenLoc) {
+ QualType EncodedType = EncodedTypeInfo->getType();
QualType StrTy;
if (EncodedType->isDependentType())
StrTy = Context.DependentTy;
@@ -114,7 +115,7 @@ Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
ArrayType::Normal, 0);
}
- return new (Context) ObjCEncodeExpr(StrTy, EncodedType, AtLoc, RParenLoc);
+ return new (Context) ObjCEncodeExpr(StrTy, EncodedTypeInfo, AtLoc, RParenLoc);
}
Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
@@ -123,9 +124,13 @@ Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
TypeTy *ty,
SourceLocation RParenLoc) {
// FIXME: Preserve type source info ?
- QualType EncodedType = GetTypeFromParser(ty);
+ TypeSourceInfo *TInfo;
+ QualType EncodedType = GetTypeFromParser(ty, &TInfo);
+ if (!TInfo)
+ TInfo = Context.getTrivialTypeSourceInfo(EncodedType,
+ PP.getLocForEndOfToken(LParenLoc));
- return BuildObjCEncodeExpression(AtLoc, EncodedType, RParenLoc);
+ return BuildObjCEncodeExpression(AtLoc, TInfo, RParenLoc);
}
Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index e2fdf66442..ba714e8867 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -1688,9 +1688,9 @@ public:
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc,
- QualType T,
+ TypeSourceInfo *EncodeTypeInfo,
SourceLocation RParenLoc) {
- return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, T,
+ return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
RParenLoc));
}
@@ -5464,18 +5464,17 @@ TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
- // FIXME: poor source location
- TemporaryBase Rebase(*this, E->getAtLoc(), DeclarationName());
- QualType EncodedType = getDerived().TransformType(E->getEncodedType());
- if (EncodedType.isNull())
+ TypeSourceInfo *EncodedTypeInfo
+ = getDerived().TransformType(E->getEncodedTypeSourceInfo());
+ if (!EncodedTypeInfo)
return SemaRef.ExprError();
if (!getDerived().AlwaysRebuild() &&
- EncodedType == E->getEncodedType())
+ EncodedTypeInfo == E->getEncodedTypeSourceInfo())
return SemaRef.Owned(E->Retain());
return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
- EncodedType,
+ EncodedTypeInfo,
E->getRParenLoc());
}