Template instantiation for "typeof" for both types and expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72440 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2009-05-26 22:09:24 +00:00
Родитель 49d1cd5a09
Коммит 5f8bd59b44
3 изменённых файлов: 35 добавлений и 7 удалений

Просмотреть файл

@ -414,17 +414,22 @@ TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T,
QualType
TemplateTypeInstantiator::InstantiateTypeOfExprType(const TypeOfExprType *T,
unsigned Quals) const {
// FIXME: Implement this
assert(false && "Cannot instantiate TypeOfExprType yet");
return QualType();
Sema::OwningExprResult E
= SemaRef.InstantiateExpr(T->getUnderlyingExpr(), TemplateArgs);
if (E.isInvalid())
return QualType();
return SemaRef.Context.getTypeOfExprType(E.takeAs<Expr>());
}
QualType
TemplateTypeInstantiator::InstantiateTypeOfType(const TypeOfType *T,
unsigned Quals) const {
// FIXME: Implement this
assert(false && "Cannot instantiate TypeOfType yet");
return QualType();
QualType Underlying = Instantiate(T->getUnderlyingType());
if (Underlying.isNull())
return QualType();
return SemaRef.Context.getTypeOfType(Underlying);
}
QualType

Просмотреть файл

@ -138,9 +138,15 @@ TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) {
else
assert(false &&
"FIXME: instantiation of non-local variable declarations");
} else if (isa<FunctionDecl>(D) || isa<OverloadedFunctionDecl>(D)) {
} else if (isa<FunctionDecl>(D)) {
// FIXME: Instantiate decl!
NewD = cast<ValueDecl>(D);
} else if (isa<OverloadedFunctionDecl>(D)) {
// FIXME: instantiate decls?
return SemaRef.Owned(new (SemaRef.Context) DeclRefExpr(cast<NamedDecl>(D),
SemaRef.Context.OverloadTy,
E->getLocation(),
false, false));
} else
assert(false && "FIXME: unhandled declaration reference kind");

Просмотреть файл

@ -0,0 +1,17 @@
// RUN: clang-cc -fsyntax-only %s
int* f(int);
float *f(...);
template<typename T>
struct X {
typedef typeof(T*) typeof_type;
typedef typeof(f(T())) typeof_expr;
};
int *iptr0;
float *fptr0;
X<int>::typeof_type &iptr1 = iptr0;
X<int>::typeof_expr &iptr2 = iptr0;
X<float*>::typeof_expr &fptr1 = fptr0;