[cfe-commits] r39394 - in /cfe/cfe/trunk: AST/ASTContext.cpp AST/Expr.cpp AST/SemaDecl.cpp AST/SemaExpr.cpp AST/SemaType.cpp AST/Type.cpp Sema/SemaDecl.cpp Sema/SemaExpr.cpp Sema/SemaType.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Decl.h include/clang/AST/Expr.h include/clang/AST/Type.h

Steve Naroff snaroff at apple.com
Wed Jul 11 09:43:54 PDT 2007


Author: snaroff
Date: Wed Jul 11 11:43:54 2007
New Revision: 39394

URL: http://llvm.org/viewvc/llvm-project?rev=39394&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Fix "FIXME: does this lose qualifiers from the typedef??" in ASTContext::getTypedefType().

This change was fairly pervasive...nevertheless, here are the highlights:
- Change the type of Type::CanonicalType to TypeRef (was "Type *").
- Change the implementation of TypeRef::getCanonicalType() to work for typedefs.
- Make the implementation of Type::getCanonicalType private (only TypeRef should access). This
will force clients to use TypeRef::getCanonicalType (the correct version of the function). Since
TypeRef overloads "->", it was very easy to fall into this bug...
- Changed many references of "Type *" to "TypeRef"...when the raw type pointer is required, use t.getTypePtr().
- Changed all the *Type classes to take a TypeRef.
- Made the Type constructor protected (cleanup).
- Removed function Expr::getType().
- Convert functions in SemaExpr to use the above support. This fixed the "const" bug I was originally investigating.

I will follow this check-in up with a rename of TypeRef->QualType. I will also make sure the constructor does not default to 0 (which can lead to broken code...).

Modified:
    cfe/cfe/trunk/AST/ASTContext.cpp
    cfe/cfe/trunk/AST/Expr.cpp
    cfe/cfe/trunk/AST/SemaDecl.cpp
    cfe/cfe/trunk/AST/SemaExpr.cpp
    cfe/cfe/trunk/AST/SemaType.cpp
    cfe/cfe/trunk/AST/Type.cpp
    cfe/cfe/trunk/Sema/SemaDecl.cpp
    cfe/cfe/trunk/Sema/SemaExpr.cpp
    cfe/cfe/trunk/Sema/SemaType.cpp
    cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/cfe/trunk/include/clang/AST/Decl.h
    cfe/cfe/trunk/include/clang/AST/Expr.h
    cfe/cfe/trunk/include/clang/AST/Type.h

Modified: cfe/cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/ASTContext.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/cfe/trunk/AST/ASTContext.cpp Wed Jul 11 11:43:54 2007
@@ -137,15 +137,14 @@
   
   // If the pointee type isn't canonical, this won't be a canonical type either,
   // so fill in the canonical type field.
-  Type *Canonical = 0;
+  TypeRef Canonical = 0;
   if (!T->isCanonical()) {
-    Canonical = getPointerType(T.getCanonicalType()).getTypePtr();
+    Canonical = getPointerType(T.getCanonicalType());
    
     // Get the new insert position for the node we care about.
     PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(NewIP == 0 && "Shouldn't be in the map!");
   }
-  
   PointerType *New = new PointerType(T, Canonical);
   Types.push_back(New);
   PointerTypes.InsertNode(New, InsertPos);
@@ -167,10 +166,10 @@
   
   // If the element type isn't canonical, this won't be a canonical type either,
   // so fill in the canonical type field.
-  Type *Canonical = 0;
+  TypeRef Canonical = 0;
   if (!EltTy->isCanonical()) {
     Canonical = getArrayType(EltTy.getCanonicalType(), ASM, EltTypeQuals,
-                             NumElts).getTypePtr();
+                             NumElts);
     
     // Get the new insert position for the node we care about.
     ArrayType *NewIP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -196,7 +195,7 @@
         FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos))
     return FT;
   
-  Type *Canonical = 0;
+  TypeRef Canonical = 0;
   if (!ResultTy->isCanonical()) {
     Canonical =getFunctionTypeNoProto(ResultTy.getCanonicalType()).getTypePtr();
     
@@ -233,7 +232,7 @@
       isCanonical = false;
 
   // If this type isn't canonical, get the canonical version of it.
-  Type *Canonical = 0;
+  TypeRef Canonical = 0;
   if (!isCanonical) {
     SmallVector<TypeRef, 16> CanonicalArgs;
     CanonicalArgs.reserve(NumArgs);
@@ -242,7 +241,7 @@
     
     Canonical = getFunctionType(ResultTy.getCanonicalType(),
                                 &CanonicalArgs[0], NumArgs,
-                                isVariadic).getTypePtr();
+                                isVariadic);
     
     // Get the new insert position for the node we care about.
     FunctionTypeProto *NewIP =
@@ -268,8 +267,7 @@
 TypeRef ASTContext::getTypedefType(TypedefDecl *Decl) {
   if (Decl->TypeForDecl) return Decl->TypeForDecl;
   
-  // FIXME: does this lose qualifiers from the typedef??
-  Type *Canonical = Decl->getUnderlyingType().getCanonicalType().getTypePtr();
+  TypeRef Canonical = Decl->getUnderlyingType().getCanonicalType();
   Decl->TypeForDecl = new TypedefType(Decl, Canonical);
   Types.push_back(Decl->TypeForDecl);
   return Decl->TypeForDecl;

Modified: cfe/cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Expr.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Expr.cpp (original)
+++ cfe/cfe/trunk/AST/Expr.cpp Wed Jul 11 11:43:54 2007
@@ -74,7 +74,7 @@
 //===----------------------------------------------------------------------===//
 
 CallExpr::CallExpr(Expr *fn, Expr **args, unsigned numargs)
-  : Expr(CallExprClass, fn->getTypeRef()), Fn(fn), NumArgs(numargs) {
+  : Expr(CallExprClass, fn->getType()), Fn(fn), NumArgs(numargs) {
   Args = new Expr*[numargs];
   for (unsigned i = 0; i != numargs; ++i)
     Args[i] = args[i];

Modified: cfe/cfe/trunk/AST/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaDecl.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/AST/SemaDecl.cpp Wed Jul 11 11:43:54 2007
@@ -23,6 +23,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallSet.h"
+
 using namespace llvm;
 using namespace clang;
 
@@ -622,7 +623,7 @@
     if (!FD) continue;  // Already issued a diagnostic.
     
     // Get the type for the field.
-    Type *FDTy = FD->getType()->getCanonicalType();
+    Type *FDTy = FD->getType().getCanonicalType().getTypePtr();
     
     // C99 6.7.2.1p2 - A field may not be a function type.
     if (isa<FunctionType>(FDTy)) {

Modified: cfe/cfe/trunk/AST/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaExpr.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/AST/SemaExpr.cpp Wed Jul 11 11:43:54 2007
@@ -224,24 +224,27 @@
 Action::ExprResult Sema::
 ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
                         ExprTy *Idx, SourceLocation RLoc) {
-  TypeRef t1 = ((Expr *)Base)->getTypeRef();
-  TypeRef t2 = ((Expr *)Idx)->getTypeRef();
+  TypeRef t1 = ((Expr *)Base)->getType();
+  TypeRef t2 = ((Expr *)Idx)->getType();
 
   assert(!t1.isNull() && "no type for array base expression");
   assert(!t2.isNull() && "no type for array index expression");
 
+  TypeRef canonT1 = t1.getCanonicalType();
+  TypeRef canonT2 = t2.getCanonicalType();
+  
   // C99 6.5.2.1p2: the expression e1[e2] is by definition precisely equivalent
   // to the expression *((e1)+(e2)). This means the array "Base" may actually be 
   // in the subscript position. As a result, we need to derive the array base 
   // and index from the expression types.
   
   TypeRef baseType, indexType;
-  if (isa<ArrayType>(t1) || isa<PointerType>(t1)) {
-    baseType = t1;
-    indexType = t2;
-  } else if (isa<ArrayType>(t2) || isa<PointerType>(t2)) { // uncommon case
-    baseType = t2;
-    indexType = t1;
+  if (isa<ArrayType>(canonT1) || isa<PointerType>(canonT1)) {
+    baseType = canonT1;
+    indexType = canonT2;
+  } else if (isa<ArrayType>(canonT2) || isa<PointerType>(canonT2)) { // uncommon
+    baseType = canonT2;
+    indexType = canonT1;
   } else 
     return Diag(LLoc, diag::err_typecheck_subscript_value);
 
@@ -267,16 +270,16 @@
 ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
                          tok::TokenKind OpKind, SourceLocation MemberLoc,
                          IdentifierInfo &Member) {
-  TypeRef qualifiedType = ((Expr *)Base)->getTypeRef();
+  TypeRef qualifiedType = ((Expr *)Base)->getType();
   
   assert(!qualifiedType.isNull() && "no type for member expression");
   
-  Type *canonType = qualifiedType->getCanonicalType();
+  TypeRef canonType = qualifiedType.getCanonicalType();
 
   if (OpKind == tok::arrow) {
     if (PointerType *PT = dyn_cast<PointerType>(canonType)) {
       qualifiedType = PT->getPointeeType();
-      canonType = qualifiedType->getCanonicalType();
+      canonType = qualifiedType.getCanonicalType();
     } else
       return Diag(OpLoc, diag::err_typecheck_member_reference_arrow);
   }
@@ -387,7 +390,7 @@
 
 Expr *Sema::ImplicitConversion(Expr *E) {
 #if 0
-  TypeRef t = E->getTypeRef();
+  TypeRef t = E->getType();
   if (t != 0) t.dump();
   else printf("no type for expr %s\n", E->getStmtClassName());
 #endif
@@ -425,12 +428,12 @@
 Action::ExprResult
 Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
                                                unsigned OpCode) {
-  TypeRef qType = op->getTypeRef();
+  TypeRef qType = op->getType();
 
   assert(!qType.isNull() && "no type for increment/decrement expression");
 
-  Type *canonType = qType->getCanonicalType();
-  
+  TypeRef canonType = qType.getCanonicalType();
+
   // C99 6.5.2.4p1
   if (const PointerType *pt = dyn_cast<PointerType>(canonType)) {
     if (!pt->getPointeeType()->isObjectType()) // C99 6.5.2.4p2, 6.5.6p2
@@ -442,7 +445,7 @@
   // At this point, we know we have a real or pointer type. As a result, the
   // following predicate is overkill (i.e. it will check for types we know we
   // don't have in this context). Nevertheless, we model the C99 spec closely.
-  if (!qType.isModifiableLvalue())
+  if (!canonType.isModifiableLvalue())
     return Diag(OpLoc, diag::err_typecheck_not_modifiable, qType);
 
   return new UnaryOperator(op, (UnaryOperator::Opcode)OpCode, qType);

Modified: cfe/cfe/trunk/AST/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaType.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaType.cpp (original)
+++ cfe/cfe/trunk/AST/SemaType.cpp Wed Jul 11 11:43:54 2007
@@ -131,7 +131,7 @@
       else
         ASM = ArrayType::Normal;
       
-      Type *CanonicalT = T->getCanonicalType();
+      Type *CanonicalT = T.getCanonicalType().getTypePtr();
       
       // C99 6.7.5.2p1: If the element type is an incomplete or function type, 
       // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())

Modified: cfe/cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Type.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Type.cpp (original)
+++ cfe/cfe/trunk/AST/Type.cpp Wed Jul 11 11:43:54 2007
@@ -75,11 +75,11 @@
   switch (CanonicalType->getTypeClass()) {
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::ULongLong;
   case Tagged:
-    const TagType *TT = static_cast<TagType*>(CanonicalType);
+    const TagType *TT = static_cast<TagType*>(CanonicalType.getTypePtr());
     if (TT->getDecl()->getKind() == Decl::Enum)
       return true;
     return false;
@@ -90,7 +90,7 @@
   switch (CanonicalType->getTypeClass()) {
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::Float &&
            BT->getKind() <= BuiltinType::LongDoubleComplex;
   }
@@ -100,7 +100,7 @@
   switch (CanonicalType->getTypeClass()) {
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::Float &&
            BT->getKind() <= BuiltinType::LongDouble;
   }
@@ -111,11 +111,11 @@
   switch (CanonicalType->getTypeClass()) { // inlined for performance
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::LongDouble;
   case Tagged:
-    const TagType *TT = static_cast<TagType*>(CanonicalType);
+    const TagType *TT = static_cast<TagType*>(CanonicalType.getTypePtr());
     if (TT->getDecl()->getKind() == Decl::Enum)
       return true;
     return false;
@@ -126,7 +126,7 @@
   switch (CanonicalType->getTypeClass()) {
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::FloatComplex &&
            BT->getKind() <= BuiltinType::LongDoubleComplex;
   }
@@ -136,7 +136,7 @@
   switch (CanonicalType->getTypeClass()) {
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::LongDoubleComplex;
   }
@@ -146,7 +146,7 @@
   switch (CanonicalType->getTypeClass()) {
   default: return false;
   case Builtin:
-    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType);
+    const BuiltinType *BT = static_cast<BuiltinType*>(CanonicalType.getTypePtr());
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::LongDoubleComplex;
   case Pointer:
@@ -160,7 +160,7 @@
   case Array:
     return true;
   case Tagged:
-    const TagType *TT = static_cast<TagType*>(CanonicalType);
+    const TagType *TT = static_cast<TagType*>(CanonicalType.getTypePtr());
     if (TT->getDecl()->getKind() == Decl::Struct)
       return true;
     return true;

Modified: cfe/cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaDecl.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaDecl.cpp Wed Jul 11 11:43:54 2007
@@ -23,6 +23,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallSet.h"
+
 using namespace llvm;
 using namespace clang;
 
@@ -622,7 +623,7 @@
     if (!FD) continue;  // Already issued a diagnostic.
     
     // Get the type for the field.
-    Type *FDTy = FD->getType()->getCanonicalType();
+    Type *FDTy = FD->getType().getCanonicalType().getTypePtr();
     
     // C99 6.7.2.1p2 - A field may not be a function type.
     if (isa<FunctionType>(FDTy)) {

Modified: cfe/cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaExpr.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaExpr.cpp Wed Jul 11 11:43:54 2007
@@ -224,24 +224,27 @@
 Action::ExprResult Sema::
 ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
                         ExprTy *Idx, SourceLocation RLoc) {
-  TypeRef t1 = ((Expr *)Base)->getTypeRef();
-  TypeRef t2 = ((Expr *)Idx)->getTypeRef();
+  TypeRef t1 = ((Expr *)Base)->getType();
+  TypeRef t2 = ((Expr *)Idx)->getType();
 
   assert(!t1.isNull() && "no type for array base expression");
   assert(!t2.isNull() && "no type for array index expression");
 
+  TypeRef canonT1 = t1.getCanonicalType();
+  TypeRef canonT2 = t2.getCanonicalType();
+  
   // C99 6.5.2.1p2: the expression e1[e2] is by definition precisely equivalent
   // to the expression *((e1)+(e2)). This means the array "Base" may actually be 
   // in the subscript position. As a result, we need to derive the array base 
   // and index from the expression types.
   
   TypeRef baseType, indexType;
-  if (isa<ArrayType>(t1) || isa<PointerType>(t1)) {
-    baseType = t1;
-    indexType = t2;
-  } else if (isa<ArrayType>(t2) || isa<PointerType>(t2)) { // uncommon case
-    baseType = t2;
-    indexType = t1;
+  if (isa<ArrayType>(canonT1) || isa<PointerType>(canonT1)) {
+    baseType = canonT1;
+    indexType = canonT2;
+  } else if (isa<ArrayType>(canonT2) || isa<PointerType>(canonT2)) { // uncommon
+    baseType = canonT2;
+    indexType = canonT1;
   } else 
     return Diag(LLoc, diag::err_typecheck_subscript_value);
 
@@ -267,16 +270,16 @@
 ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
                          tok::TokenKind OpKind, SourceLocation MemberLoc,
                          IdentifierInfo &Member) {
-  TypeRef qualifiedType = ((Expr *)Base)->getTypeRef();
+  TypeRef qualifiedType = ((Expr *)Base)->getType();
   
   assert(!qualifiedType.isNull() && "no type for member expression");
   
-  Type *canonType = qualifiedType->getCanonicalType();
+  TypeRef canonType = qualifiedType.getCanonicalType();
 
   if (OpKind == tok::arrow) {
     if (PointerType *PT = dyn_cast<PointerType>(canonType)) {
       qualifiedType = PT->getPointeeType();
-      canonType = qualifiedType->getCanonicalType();
+      canonType = qualifiedType.getCanonicalType();
     } else
       return Diag(OpLoc, diag::err_typecheck_member_reference_arrow);
   }
@@ -387,7 +390,7 @@
 
 Expr *Sema::ImplicitConversion(Expr *E) {
 #if 0
-  TypeRef t = E->getTypeRef();
+  TypeRef t = E->getType();
   if (t != 0) t.dump();
   else printf("no type for expr %s\n", E->getStmtClassName());
 #endif
@@ -425,12 +428,12 @@
 Action::ExprResult
 Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
                                                unsigned OpCode) {
-  TypeRef qType = op->getTypeRef();
+  TypeRef qType = op->getType();
 
   assert(!qType.isNull() && "no type for increment/decrement expression");
 
-  Type *canonType = qType->getCanonicalType();
-  
+  TypeRef canonType = qType.getCanonicalType();
+
   // C99 6.5.2.4p1
   if (const PointerType *pt = dyn_cast<PointerType>(canonType)) {
     if (!pt->getPointeeType()->isObjectType()) // C99 6.5.2.4p2, 6.5.6p2
@@ -442,7 +445,7 @@
   // At this point, we know we have a real or pointer type. As a result, the
   // following predicate is overkill (i.e. it will check for types we know we
   // don't have in this context). Nevertheless, we model the C99 spec closely.
-  if (!qType.isModifiableLvalue())
+  if (!canonType.isModifiableLvalue())
     return Diag(OpLoc, diag::err_typecheck_not_modifiable, qType);
 
   return new UnaryOperator(op, (UnaryOperator::Opcode)OpCode, qType);

Modified: cfe/cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaType.cpp?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaType.cpp Wed Jul 11 11:43:54 2007
@@ -131,7 +131,7 @@
       else
         ASM = ArrayType::Normal;
       
-      Type *CanonicalT = T->getCanonicalType();
+      Type *CanonicalT = T.getCanonicalType().getTypePtr();
       
       // C99 6.7.5.2p1: If the element type is an incomplete or function type, 
       // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())

Modified: cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/cfe/trunk/clang.xcodeproj/project.pbxproj Wed Jul 11 11:43:54 2007
@@ -483,10 +483,12 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";
 			projectRoot = "";
+			shouldCheckCompatibility = 1;
 			targets = (
 				8DD76F620486A84900D96B5E /* clang */,
 			);

Modified: cfe/cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Decl.h?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Decl.h Wed Jul 11 11:43:54 2007
@@ -109,8 +109,6 @@
   ValueDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, TypeRef T): 
              Decl(DK, L, Id), DeclType(T) {}
 public:
-  // FIXME: should rename to getTypeRef/getCanonicalTypeRef to distinguish
-  // TypeRef's from Type's...
   TypeRef getType() const { return DeclType; }
   TypeRef getCanonicalType() const { return DeclType.getCanonicalType(); }
   
@@ -288,8 +286,7 @@
   /// UnderlyingType - This is the type the typedef is set to.
   TypeRef UnderlyingType;
 public:
-    // FIXME: Remove Declarator argument.
-    TypedefDecl(SourceLocation L, IdentifierInfo *Id, TypeRef T)
+  TypedefDecl(SourceLocation L, IdentifierInfo *Id, TypeRef T)
     : TypeDecl(Typedef, L, Id), UnderlyingType(T) {}
   
   TypeRef getUnderlyingType() const { return UnderlyingType; }

Modified: cfe/cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Expr.h?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Expr.h Wed Jul 11 11:43:54 2007
@@ -33,10 +33,7 @@
   Expr(StmtClass SC, TypeRef T=0) : Stmt(SC), TR(T) {}
   ~Expr() {}
 public:  
-  // FIXME: the return type of getType is inconsistent with Decls.
-  // this is confusing and needs to be reconciled (by making one conform).
-  Type *getType() const { return TR.getTypePtr(); }
-  TypeRef getTypeRef() const { return TR; }
+  TypeRef getType() const { return TR; }
   
   virtual void visit(StmtVisitor &Visitor);
   static bool classof(const Stmt *T) { 

Modified: cfe/cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Type.h?rev=39394&r1=39393&r2=39394&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Type.h Wed Jul 11 11:43:54 2007
@@ -112,11 +112,6 @@
   bool operator!=(const TypeRef &RHS) const {
     return ThePtr != RHS.ThePtr;
   }
-  
-  /// getCanonicalType - Return the canonical version of this type, with the
-  /// appropriate type qualifiers on it.
-  inline TypeRef getCanonicalType() const;
-
   /// isModifiableLvalue - C99 6.3.2.1p1: returns true if the type is an lvalue
   /// that does not have array type, does not have an incomplete type, does
   /// not have a const-qualified type, and if it is a struct/union, does not 
@@ -126,6 +121,10 @@
     
   void getAsString(std::string &S) const;
   void dump() const;
+
+  /// getCanonicalType - Return the canonical version of this type, with the
+  /// appropriate type qualifiers on it.
+  inline TypeRef getCanonicalType() const;
 };
 
 } // end clang.
@@ -174,21 +173,21 @@
     Builtin, Pointer, Array, FunctionNoProto, FunctionProto, TypeName, Tagged
   };
 private:
-  Type *CanonicalType;
+  TypeRef CanonicalType;
 
   /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
   /// Note that this should stay at the end of the ivars for Type so that
   /// subclasses can pack their bitfields into the same word.
   TypeClass TC : 3;
-public:
-  Type(TypeClass tc, Type *Canonical)
-    : CanonicalType(Canonical ? Canonical : this), TC(tc) {}
+protected:
+  Type(TypeClass tc, TypeRef Canonical)
+    : CanonicalType(Canonical.isNull() ? TypeRef(this,0) : Canonical), TC(tc) {}
   virtual ~Type();
-  
+  friend class ASTContext;
+public:  
   TypeClass getTypeClass() const { return TC; }
   
-  bool isCanonical() const { return CanonicalType == this; }
-  Type *getCanonicalType() const { return CanonicalType; }
+  bool isCanonical() const { return CanonicalType.getTypePtr() == this; }
 
   /// Types are partitioned into 3 broad categories (C99 6.2.5p1): 
   /// object types, function types, and incomplete types.
@@ -231,6 +230,8 @@
   // this forces clients to use isModifiableLvalue on TypeRef, the class that 
   // knows if the type is const. This predicate is a helper to TypeRef. 
   bool isModifiableLvalue() const; // C99 6.3.2.1p1
+  
+  TypeRef getCanonicalType() const { return CanonicalType; }
   friend class TypeRef;
 public:
   virtual void getAsString(std::string &InnerString) const = 0;
@@ -267,7 +268,7 @@
 ///
 class PointerType : public Type, public FoldingSetNode {
   TypeRef PointeeType;
-  PointerType(TypeRef Pointee, Type *CanonicalPtr) :
+  PointerType(TypeRef Pointee, TypeRef CanonicalPtr) :
     Type(Pointer, CanonicalPtr), PointeeType(Pointee) {
   }
   friend class ASTContext;  // ASTContext creates these.
@@ -314,7 +315,7 @@
   /// Variable Length Arrays). VLA's are only permitted within a function block. 
   Expr *SizeExpr;
   
-  ArrayType(TypeRef et, ArraySizeModifier sm, unsigned tq, Type *can, Expr *e)
+  ArrayType(TypeRef et, ArraySizeModifier sm, unsigned tq, TypeRef can, Expr *e)
     : Type(Array, can), SizeModifier(sm), IndexTypeQuals(tq), ElementType(et),
       SizeExpr(e) {}
   friend class ASTContext;  // ASTContext creates these.
@@ -355,7 +356,7 @@
   // The type returned by the function.
   TypeRef ResultType;
 protected:
-  FunctionType(TypeClass tc, TypeRef res, bool SubclassInfo, Type *Canonical)
+  FunctionType(TypeClass tc, TypeRef res, bool SubclassInfo, TypeRef Canonical)
     : Type(tc, Canonical), SubClassData(SubclassInfo), ResultType(res) {}
   bool getSubClassData() const { return SubClassData; }
 public:
@@ -373,7 +374,7 @@
 /// FunctionTypeNoProto - Represents a K&R-style 'int foo()' function, which has
 /// no information available about its arguments.
 class FunctionTypeNoProto : public FunctionType, public FoldingSetNode {
-  FunctionTypeNoProto(TypeRef Result, Type *Canonical)
+  FunctionTypeNoProto(TypeRef Result, TypeRef Canonical)
     : FunctionType(FunctionNoProto, Result, false, Canonical) {}
   friend class ASTContext;  // ASTContext creates these.
 public:
@@ -399,7 +400,7 @@
 /// arguments, not as having a single void argument.
 class FunctionTypeProto : public FunctionType, public FoldingSetNode {
   FunctionTypeProto(TypeRef Result, TypeRef *ArgArray, unsigned numArgs,
-                    bool isVariadic, Type *Canonical)
+                    bool isVariadic, TypeRef Canonical)
     : FunctionType(FunctionProto, Result, isVariadic, Canonical),
       NumArgs(numArgs) {
     for (unsigned i = 0; i != numArgs; ++i)
@@ -438,7 +439,7 @@
 
 class TypedefType : public Type {
   TypedefDecl *Decl;
-  TypedefType(TypedefDecl *D, Type *can) : Type(TypeName, can), Decl(D) {
+  TypedefType(TypedefDecl *D, TypeRef can) : Type(TypeName, can), Decl(D) {
     assert(!isa<TypedefType>(can) && "Invalid canonical type");
   }
   friend class ASTContext;  // ASTContext creates these.
@@ -455,7 +456,7 @@
 
 class TagType : public Type {
   TagDecl *Decl;
-  TagType(TagDecl *D, Type *can) : Type(Tagged, can), Decl(D) {}
+  TagType(TagDecl *D, TypeRef can) : Type(Tagged, can), Decl(D) {}
   friend class ASTContext;  // ASTContext creates these.
 public:
     
@@ -494,13 +495,13 @@
 // specify the same type, we want to print the default argument only if
 // specified in the source code.
 
-
 /// getCanonicalType - Return the canonical version of this type, with the
 /// appropriate type qualifiers on it.
 inline TypeRef TypeRef::getCanonicalType() const {
-  return TypeRef(getTypePtr()->getCanonicalType(), getQualifiers());
+  return TypeRef(getTypePtr()->getCanonicalType().getTypePtr(),
+                 getQualifiers() |
+                 getTypePtr()->getCanonicalType().getQualifiers());
 }
-
   
 }  // end namespace clang
 }  // end namespace llvm





More information about the cfe-commits mailing list