]> granicus.if.org Git - clang/commitdiff
Fix a problem that Eli noticed, and that Doug helped me fix.
authorAnders Carlsson <andersca@mac.com>
Fri, 10 Jul 2009 19:20:26 +0000 (19:20 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 10 Jul 2009 19:20:26 +0000 (19:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75265 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/AST/ASTContext.cpp
lib/AST/Type.cpp
lib/CodeGen/CGDebugInfo.cpp

index 2beaba637c63e59f740de483e771becdcbcb2216..39eb1842b33b42c018561c0a63ac93c1ed3ab7a0 100644 (file)
@@ -1463,11 +1463,18 @@ public:
 /// DecltypeType (C++0x)
 class DecltypeType : public Type {
   Expr *E;
-  DecltypeType(Expr *E, QualType can = QualType());
+  
+  // FIXME: We could get rid of UnderlyingType if we wanted to: We would have to
+  // Move getDesugaredType to ASTContext so that it can call getDecltypeForExpr
+  // from it.
+  QualType UnderlyingType;
+  
+  DecltypeType(Expr *E, QualType underlyingType, QualType can = QualType());
   friend class ASTContext;  // ASTContext creates these.
 public:
   Expr *getUnderlyingExpr() const { return E; }
-  
+  QualType getUnderlyingType() const { return UnderlyingType; }
+
   virtual void getAsStringInternal(std::string &InnerString, 
                                    const PrintingPolicy &Policy) const;
   
index de4816c503be4f6bad529ef56aa0b2b1de13ed93..2bd1482adc2b3a39a6fa4e8522f24bc96189d70d 100644 (file)
@@ -1964,10 +1964,10 @@ static QualType getDecltypeForExpr(const Expr *e, ASTContext &Context) {
 QualType ASTContext::getDecltypeType(Expr *e) {
   DecltypeType *dt;
   if (e->isTypeDependent()) // FIXME: canonicalize the expression
-    dt = new (*this, 8) DecltypeType(e);
+    dt = new (*this, 8) DecltypeType(e, DependentTy);
   else {
     QualType T = getDecltypeForExpr(e, *this);
-    dt = new (*this, 8) DecltypeType(e, getCanonicalType(T));    
+    dt = new (*this, 8) DecltypeType(e, T, getCanonicalType(T));    
   }
   Types.push_back(dt);
   return QualType(dt, 0);
index d5dd776b7df6f13055ea536dc8787617111c98ca..78c3b78977de9aa8e433b6ae08d6b96337c4be3a 100644 (file)
@@ -124,8 +124,10 @@ QualType Type::getDesugaredType(bool ForDisplay) const {
     return TOE->getUnderlyingExpr()->getType().getDesugaredType();
   if (const TypeOfType *TOT = dyn_cast<TypeOfType>(this))
     return TOT->getUnderlyingType().getDesugaredType();
-  if (const DecltypeType *DTT = dyn_cast<DecltypeType>(this))
-    return DTT->getCanonicalTypeInternal();
+  if (const DecltypeType *DTT = dyn_cast<DecltypeType>(this)) {
+    if (!DTT->getUnderlyingType()->isDependentType())
+      return DTT->getUnderlyingType().getDesugaredType();
+  }
   if (const TemplateSpecializationType *Spec 
         = dyn_cast<TemplateSpecializationType>(this)) {
     if (ForDisplay)
@@ -1074,8 +1076,9 @@ TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
   : Type(TypeOfExpr, can, E->isTypeDependent()), TOExpr(E) {
 }
 
-DecltypeType::DecltypeType(Expr *E, QualType can)
-  : Type(Decltype, can, E->isTypeDependent()), E(E) {
+DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
+  : Type(Decltype, can, E->isTypeDependent()), E(E), 
+  UnderlyingType(underlyingType) {
 }
 
 TagType::TagType(TypeClass TC, TagDecl *D, QualType can) 
index cf8e19af3231906a45f1019d870d5a39f1a4e445..8fa1e9c920fd65750152d14598bbbd3d3ea92625 100644 (file)
@@ -792,8 +792,8 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
     return Slot = getOrCreateType(cast<TypeOfType>(Ty)->getUnderlyingType(),
                                   Unit);
   case Type::Decltype:
-    return Slot = getOrCreateType(cast<DecltypeType>(Ty)->getUnderlyingExpr()
-                                  ->getType(), Unit);
+    return Slot = getOrCreateType(cast<DecltypeType>(Ty)->getUnderlyingType(),
+                                  Unit);
   }
   
   return Slot;