[cfe-commits] r72220 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-expr-4.cpp
Douglas Gregor
dgregor at apple.com
Thu May 21 11:55:57 PDT 2009
Author: dgregor
Date: Thu May 21 13:55:48 2009
New Revision: 72220
URL: http://llvm.org/viewvc/llvm-project?rev=72220&view=rev
Log:
Template instantiation for unary type traits, e.g., __is_pod
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72220&r1=72219&r2=72220&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Thu May 21 13:55:48 2009
@@ -90,7 +90,7 @@
OwningExprResult VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
OwningExprResult VisitCXXNewExpr(CXXNewExpr *E);
OwningExprResult VisitCXXDeleteExpr(CXXDeleteExpr *E);
- // FIXME: UnaryTypeTraitExpr
+ OwningExprResult VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
// FIXME: QualifiedDeclRefExpr
OwningExprResult VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
OwningExprResult VisitCXXUnresolvedConstructExpr(
@@ -992,6 +992,23 @@
}
Sema::OwningExprResult
+TemplateExprInstantiator::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
+ QualType T = SemaRef.InstantiateType(E->getQueriedType(), TemplateArgs,
+ /*FIXME*/E->getSourceRange().getBegin(),
+ DeclarationName());
+ if (T.isNull())
+ return SemaRef.ExprError();
+
+ SourceLocation FakeLParenLoc
+ = SemaRef.PP.getLocForEndOfToken(E->getSourceRange().getBegin());
+ return SemaRef.ActOnUnaryTypeTrait(E->getTrait(),
+ E->getSourceRange().getBegin(),
+ /*FIXME*/FakeLParenLoc,
+ T.getAsOpaquePtr(),
+ E->getSourceRange().getEnd());
+}
+
+Sema::OwningExprResult
TemplateExprInstantiator::VisitCXXExprWithTemporaries(
CXXExprWithTemporaries *E) {
OwningExprResult SubExpr = Visit(E->getSubExpr());
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp?rev=72220&r1=72219&r2=72220&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Thu May 21 13:55:48 2009
@@ -139,3 +139,14 @@
template struct TypeId0<int>;
template struct TypeId0<Incomplete>;
template struct TypeId0<Abstract>;
+
+// ---------------------------------------------------------------------
+// type traits
+// ---------------------------------------------------------------------
+template<typename T>
+struct is_pod {
+ static const bool value = __is_pod(T);
+};
+
+static const int is_pod0[is_pod<X>::value? -1 : 1];
+static const int is_pod1[is_pod<Y>::value? 1 : -1];
More information about the cfe-commits
mailing list