aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-12 06:55:29 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-12 06:55:29 +0000
commit6af9f3ca25157379efd5c1caad82e9d01c17b9ff (patch)
tree06956d2a1ab9189c4c42e149abb23ba2f904dbbd
parent3a2b657088de9413714a51bff153a59565adb3ef (diff)
Fix the desugaring of dependent decltype and typeof(expr) nodes. The
isSugared() and desugar() routines previously provided were never actually called, since the corresponding types (DependentTypeOfExprType, DependentDecltypeType) don't have corresponding type classes. Outside of the current (incomplete) patch I'm working on, I haven't found a way to trigger this problem. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134973 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Type.h12
-rw-r--r--lib/AST/Type.cpp18
2 files changed, 20 insertions, 10 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index f1710f0e97..d8a92272c8 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -2952,7 +2952,7 @@ public:
QualType desugar() const;
/// \brief Returns whether this type directly provides sugar.
- bool isSugared() const { return true; }
+ bool isSugared() const;
static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExpr; }
static bool classof(const TypeOfExprType *) { return true; }
@@ -2972,9 +2972,6 @@ public:
DependentTypeOfExprType(const ASTContext &Context, Expr *E)
: TypeOfExprType(E), Context(Context) { }
- bool isSugared() const { return false; }
- QualType desugar() const { return QualType(this, 0); }
-
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Context, getUnderlyingExpr());
}
@@ -3025,10 +3022,10 @@ public:
QualType getUnderlyingType() const { return UnderlyingType; }
/// \brief Remove a single level of sugar.
- QualType desugar() const { return getUnderlyingType(); }
+ QualType desugar() const;
/// \brief Returns whether this type directly provides sugar.
- bool isSugared() const { return !isDependentType(); }
+ bool isSugared() const;
static bool classof(const Type *T) { return T->getTypeClass() == Decltype; }
static bool classof(const DecltypeType *) { return true; }
@@ -3046,9 +3043,6 @@ class DependentDecltypeType : public DecltypeType, public llvm::FoldingSetNode {
public:
DependentDecltypeType(const ASTContext &Context, Expr *E);
- bool isSugared() const { return false; }
- QualType desugar() const { return QualType(this, 0); }
-
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Context, getUnderlyingExpr());
}
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 20a0d595e4..89c00eb850 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1645,8 +1645,15 @@ TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
TOExpr(E) {
}
+bool TypeOfExprType::isSugared() const {
+ return !TOExpr->isTypeDependent();
+}
+
QualType TypeOfExprType::desugar() const {
- return getUnderlyingExpr()->getType();
+ if (isSugared())
+ return getUnderlyingExpr()->getType();
+
+ return QualType(this, 0);
}
void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
@@ -1663,6 +1670,15 @@ DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
UnderlyingType(underlyingType) {
}
+bool DecltypeType::isSugared() const { return !E->isInstantiationDependent(); }
+
+QualType DecltypeType::desugar() const {
+ if (isSugared())
+ return getUnderlyingType();
+
+ return QualType(this, 0);
+}
+
DependentDecltypeType::DependentDecltypeType(const ASTContext &Context, Expr *E)
: DecltypeType(E, Context.DependentTy), Context(Context) { }