summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/TreeTransform.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-26 22:37:10 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-26 22:37:10 +0000
commit9da641912d4d36661d69aef225ffb6d770963479 (patch)
tree326e2fbf1d270d1245f45b078d1222195a03be89 /clang/lib/Sema/TreeTransform.h
parent678eaa90ab68d2cfff010a473eae4f26743c8cac (diff)
downloadbcm5719-llvm-9da641912d4d36661d69aef225ffb6d770963479.tar.gz
bcm5719-llvm-9da641912d4d36661d69aef225ffb6d770963479.zip
Improve source-location information in a C++ typeid (type) expression
by using TypeSourceInfo, cleaning up the representation somewhat. Teach getTypeOperand() to strip references and cv-qualifiers, providing the semantic view of the type without requiring any extra storage (the unmodified type remains within the TypeSourceInfo). This fixes a bug found by Boost's call_traits test. Finally, clean up semantic analysis, by splitting the ActOnCXXTypeid routine into ActOnCXXTypeId (the parser action) and two BuildCXXTypeId functions, which perform the semantic analysis for typeid(type) and typeid(expression), respectively. We now perform less work at template instantiation time (we don't look for std::type_info again) and can give better diagnostics. llvm-svn: 102393
Diffstat (limited to 'clang/lib/Sema/TreeTransform.h')
-rw-r--r--clang/lib/Sema/TreeTransform.h43
1 files changed, 18 insertions, 25 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index cded16cd60d..f80747b69f1 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -1499,30 +1499,24 @@ public:
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildCXXTypeidExpr(SourceLocation TypeidLoc,
- SourceLocation LParenLoc,
- QualType T,
+ OwningExprResult RebuildCXXTypeidExpr(QualType TypeInfoType,
+ SourceLocation TypeidLoc,
+ TypeSourceInfo *Operand,
SourceLocation RParenLoc) {
- return getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, true,
- T.getAsOpaquePtr(), RParenLoc);
+ return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
+ RParenLoc);
}
/// \brief Build a new C++ typeid(expr) expression.
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildCXXTypeidExpr(SourceLocation TypeidLoc,
- SourceLocation LParenLoc,
+ OwningExprResult RebuildCXXTypeidExpr(QualType TypeInfoType,
+ SourceLocation TypeidLoc,
ExprArg Operand,
SourceLocation RParenLoc) {
- OwningExprResult Result
- = getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, false, Operand.get(),
- RParenLoc);
- if (Result.isInvalid())
- return getSema().ExprError();
-
- Operand.release(); // FIXME: since ActOnCXXTypeid silently took ownership
- return move(Result);
+ return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, move(Operand),
+ RParenLoc);
}
/// \brief Build a new C++ "this" expression.
@@ -4943,19 +4937,18 @@ template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
if (E->isTypeOperand()) {
- TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
-
- QualType T = getDerived().TransformType(E->getTypeOperand());
- if (T.isNull())
+ TypeSourceInfo *TInfo
+ = getDerived().TransformType(E->getTypeOperandSourceInfo());
+ if (!TInfo)
return SemaRef.ExprError();
if (!getDerived().AlwaysRebuild() &&
- T == E->getTypeOperand())
+ TInfo == E->getTypeOperandSourceInfo())
return SemaRef.Owned(E->Retain());
- return getDerived().RebuildCXXTypeidExpr(E->getLocStart(),
- /*FIXME:*/E->getLocStart(),
- T,
+ return getDerived().RebuildCXXTypeidExpr(E->getType(),
+ E->getLocStart(),
+ TInfo,
E->getLocEnd());
}
@@ -4973,8 +4966,8 @@ TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
SubExpr.get() == E->getExprOperand())
return SemaRef.Owned(E->Retain());
- return getDerived().RebuildCXXTypeidExpr(E->getLocStart(),
- /*FIXME:*/E->getLocStart(),
+ return getDerived().RebuildCXXTypeidExpr(E->getType(),
+ E->getLocStart(),
move(SubExpr),
E->getLocEnd());
}
OpenPOWER on IntegriCloud