[cfe-commits] r74975 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/AST/Type.cpp
Douglas Gregor
dgregor at apple.com
Tue Jul 7 17:03:07 PDT 2009
Author: dgregor
Date: Tue Jul 7 19:03:05 2009
New Revision: 74975
URL: http://llvm.org/viewvc/llvm-project?rev=74975&view=rev
Log:
The canonical type of typeof or decltype with a dependent type is itself,
not Context.DependentTy. I'll let Anders check in the test case for this one...
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=74975&r1=74974&r2=74975&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 7 19:03:05 2009
@@ -1432,7 +1432,7 @@
/// TypeOfExprType (GCC extension).
class TypeOfExprType : public Type {
Expr *TOExpr;
- TypeOfExprType(Expr *E, QualType can);
+ TypeOfExprType(Expr *E, QualType can = QualType());
friend class ASTContext; // ASTContext creates these.
public:
Expr *getUnderlyingExpr() const { return TOExpr; }
@@ -1463,7 +1463,7 @@
/// DecltypeType (C++0x)
class DecltypeType : public Type {
Expr *E;
- DecltypeType(Expr *E, QualType can);
+ DecltypeType(Expr *E, QualType can = QualType());
friend class ASTContext; // ASTContext creates these.
public:
Expr *getUnderlyingExpr() const { return E; }
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=74975&r1=74974&r2=74975&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 7 19:03:05 2009
@@ -1901,8 +1901,13 @@
/// DeclRefExpr's. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfExprType(Expr *tofExpr) {
- QualType Canonical = getCanonicalType(tofExpr->getType());
- TypeOfExprType *toe = new (*this,8) TypeOfExprType(tofExpr, Canonical);
+ TypeOfExprType *toe;
+ if (tofExpr->isTypeDependent())
+ toe = new (*this, 8) TypeOfExprType(tofExpr);
+ else {
+ QualType Canonical = getCanonicalType(tofExpr->getType());
+ toe = new (*this,8) TypeOfExprType(tofExpr, Canonical);
+ }
Types.push_back(toe);
return QualType(toe, 0);
}
@@ -1957,8 +1962,13 @@
/// an issue. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getDecltypeType(Expr *e) {
- QualType T = getDecltypeForExpr(e, *this);
- DecltypeType *dt = new (*this, 8) DecltypeType(e, getCanonicalType(T));
+ DecltypeType *dt;
+ if (e->isTypeDependent()) // FIXME: canonicalize the expression
+ dt = new (*this, 8) DecltypeType(e);
+ else {
+ QualType T = getDecltypeForExpr(e, *this);
+ dt = new (*this, 8) DecltypeType(e, getCanonicalType(T));
+ }
Types.push_back(dt);
return QualType(dt, 0);
}
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=74975&r1=74974&r2=74975&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Jul 7 19:03:05 2009
@@ -1072,14 +1072,10 @@
TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
: Type(TypeOfExpr, can, E->isTypeDependent()), TOExpr(E) {
- assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
DecltypeType::DecltypeType(Expr *E, QualType can)
: Type(Decltype, can, E->isTypeDependent()), E(E) {
- assert(can->isDependentType() == E->isTypeDependent() &&
- "type dependency mismatch!");
- assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
TagType::TagType(TypeClass TC, TagDecl *D, QualType can)
More information about the cfe-commits
mailing list