[cfe-commits] r54105 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/StmtPrinter.cpp lib/AST/Type.cpp lib/Analysis/BasicObjCFoundationChecks.cpp lib/CodeGen/CGExpr.cpp lib/Sema/Sema.cpp lib/Sema/SemaChecking.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprObjC.cpp

Chris Lattner sabre at nondot.org
Sat Jul 26 15:17:49 PDT 2008


Author: lattner
Date: Sat Jul 26 17:17:49 2008
New Revision: 54105

URL: http://llvm.org/viewvc/llvm-project?rev=54105&view=rev
Log:
change more instances of QualType::getCanonicalType to call
ASTContext::getCanonicalType instead (PR2189)


Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sat Jul 26 17:17:49 2008
@@ -53,6 +53,7 @@
   class TagType;
   class TypedefType;
   class FunctionType;
+  class FunctionTypeProto;
   class ExtVectorType;
   class BuiltinType;
   class ObjCInterfaceType;
@@ -342,6 +343,7 @@
   // the best type we can.
   const BuiltinType *getAsBuiltinType() const;   
   const FunctionType *getAsFunctionType() const;   
+  const FunctionTypeProto *getAsFunctionTypeProto() const;   
   const PointerLikeType *getAsPointerLikeType() const; // Pointer or Reference.
   const PointerType *getAsPointerType() const;
   const ReferenceType *getAsReferenceType() const;

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Sat Jul 26 17:17:49 2008
@@ -569,7 +569,7 @@
   OS << Node->getValue().toString(10, isSigned);
   
   // Emit suffixes.  Integer literals are always a builtin integer type.
-  switch (cast<BuiltinType>(Node->getType().getCanonicalType())->getKind()) {
+  switch (Node->getType()->getAsBuiltinType()->getKind()) {
   default: assert(0 && "Unexpected type for integer literal!");
   case BuiltinType::Int:       break; // no suffix.
   case BuiltinType::UInt:      OS << 'U'; break;

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

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Jul 26 17:17:49 2008
@@ -171,6 +171,11 @@
   return getDesugaredType()->getAsFunctionType();
 }
 
+const FunctionTypeProto *Type::getAsFunctionTypeProto() const {
+  return dyn_cast_or_null<FunctionTypeProto>(getAsFunctionType());
+}
+
+
 const PointerLikeType *Type::getAsPointerLikeType() const {
   // If this is directly a pointer-like type, return it.
   if (const PointerLikeType *PTy = dyn_cast<PointerLikeType>(this))

Modified: cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp Sat Jul 26 17:17:49 2008
@@ -28,7 +28,6 @@
 #include "clang/AST/ASTContext.h"
 #include "llvm/Support/Compiler.h"
 
-#include <vector>
 #include <sstream>
 
 using namespace clang;
@@ -496,7 +495,7 @@
   if (!LV)
     return false;
   
-  QualType T = LV->getDecl()->getType().getCanonicalType();
+  QualType T = Ctx.getCanonicalType(LV->getDecl()->getType());
   
   // FIXME: If the pointee isn't an integer type, should we flag a warning?
   //  People can do weird stuff with pointers.

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat Jul 26 17:17:49 2008
@@ -404,18 +404,20 @@
   if (E->getOpcode() == UnaryOperator::Extension)
     return EmitLValue(E->getSubExpr());
   
+  QualType ExprTy=CGM.getContext().getCanonicalType(E->getSubExpr()->getType());
   switch (E->getOpcode()) {
   default: assert(0 && "Unknown unary operator lvalue!");
   case UnaryOperator::Deref:
     return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
-      E->getSubExpr()->getType().getCanonicalType()->getAsPointerType()
-      ->getPointeeType().getCVRQualifiers());
+                            ExprTy->getAsPointerType()->getPointeeType()
+                                    .getCVRQualifiers());
   case UnaryOperator::Real:
   case UnaryOperator::Imag:
     LValue LV = EmitLValue(E->getSubExpr());
     unsigned Idx = E->getOpcode() == UnaryOperator::Imag;
     return LValue::MakeAddr(Builder.CreateStructGEP(LV.getAddress(),
-      Idx, "idx"),E->getSubExpr()->getType().getCVRQualifiers());
+                                                    Idx, "idx"),
+                            ExprTy.getCVRQualifiers());
   }
 }
 
@@ -501,9 +503,11 @@
   // size is a VLA.
   if (!E->getType()->isConstantSizeType())
     assert(0 && "VLA idx not implemented");
+  QualType ExprTy = CGM.getContext().getCanonicalType(E->getBase()->getType());
+
   return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"),
-    E->getBase()->getType().getCanonicalType()->getAsPointerType()
-    ->getPointeeType().getCVRQualifiers());
+                          ExprTy->getAsPointerType()->getPointeeType()
+                               .getCVRQualifiers());
 }
 
 static 

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sat Jul 26 17:17:49 2008
@@ -110,7 +110,8 @@
 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast. 
 /// If there is already an implicit cast, merge into the existing one.
 void Sema::ImpCastExprToType(Expr *&Expr, QualType Type) {
-  if (Expr->getType().getCanonicalType() == Type.getCanonicalType()) return;
+  if (Context.getCanonicalType(Expr->getType()) ==
+        Context.getCanonicalType(Type)) return;
   
   if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr))
     ImpCast->setType(Type);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Jul 26 17:17:49 2008
@@ -247,8 +247,8 @@
     return true;
   }
 
-  if (FAType.getCanonicalType().getUnqualifiedType() !=
-      SAType.getCanonicalType().getUnqualifiedType()) {
+  if (Context.getCanonicalType(FAType).getUnqualifiedType() !=
+      Context.getCanonicalType(SAType).getUnqualifiedType()) {
     Diag(TheCall->getLocStart(), diag::err_shufflevector_incompatible_vector,
          SourceRange(TheCall->getArg(0)->getLocStart(), 
                      TheCall->getArg(1)->getLocEnd()));

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jul 26 17:17:49 2008
@@ -384,7 +384,8 @@
 /// We need to check this explicitly as an incomplete array definition is
 /// considered a VariableArrayType, so will not match a complete array 
 /// definition that would be otherwise equivalent.
-static bool areEquivalentArrayTypes(QualType NewQType, QualType OldQType) {
+static bool areEquivalentArrayTypes(QualType NewQType, QualType OldQType,
+                                    ASTContext &Context) {
   const ArrayType *NewAT = NewQType->getAsArrayType();
   const ArrayType *OldAT = OldQType->getAsArrayType();
 
@@ -403,8 +404,8 @@
   if (NewAT->isIncompleteArrayType() || OldAT->isIncompleteArrayType()) {
     if (NewAT->getIndexTypeQualifier() != OldAT->getIndexTypeQualifier())
       return false;
-    NewQType = NewAT->getElementType().getCanonicalType();
-    OldQType = OldAT->getElementType().getCanonicalType();
+    NewQType = Context.getCanonicalType(NewAT->getElementType());
+    OldQType = Context.getCanonicalType(OldAT->getElementType());
   }
   
   return NewQType == OldQType;
@@ -432,7 +433,8 @@
   // Verify the types match.
   QualType OldCType = Context.getCanonicalType(Old->getType());
   QualType NewCType = Context.getCanonicalType(New->getType());
-  if (OldCType != NewCType && !areEquivalentArrayTypes(NewCType, OldCType)) {
+  if (OldCType != NewCType &&
+      !areEquivalentArrayTypes(NewCType, OldCType, Context)) {
     Diag(New->getLocation(), diag::err_redefinition, New->getName());
     Diag(Old->getLocation(), diag::err_previous_definition);
     return New;
@@ -1252,7 +1254,8 @@
   if (Init->isNullPointerConstant(Context))
     return false;
   if (Init->getType()->isArithmeticType()) {
-    QualType InitTy = Init->getType().getCanonicalType().getUnqualifiedType();
+    QualType InitTy = Context.getCanonicalType(Init->getType())
+                             .getUnqualifiedType();
     if (InitTy == Context.BoolTy) {
       // Special handling for pointers implicitly cast to bool;
       // (e.g. "_Bool rr = &rr;"). This is only legal at the top level.

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Jul 26 17:17:49 2008
@@ -42,12 +42,11 @@
 }
 
 static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
-  if (!T->isPointerType())
+  const PointerType *PT = T->getAsPointerType();
+  if (!PT)
     return false;
   
-  T = T->getAsPointerType()->getPointeeType().getCanonicalType();
-  ObjCInterfaceType* ClsT = dyn_cast<ObjCInterfaceType>(T.getTypePtr());
-  
+  const ObjCInterfaceType *ClsT =PT->getPointeeType()->getAsObjCInterfaceType();
   if (!ClsT)
     return false;
   
@@ -86,10 +85,9 @@
   }
   // unlike gcc's vector_size attribute, we do not allow vectors to be defined
   // in conjunction with complex types (pointers, arrays, functions, etc.).
-  Type *canonType = curType.getCanonicalType().getTypePtr();
-  if (!(canonType->isIntegerType() || canonType->isRealFloatingType())) {
+  if (!curType->isIntegerType() && !curType->isRealFloatingType()) {
     S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type,
-           curType.getCanonicalType().getAsString());
+           curType.getAsString());
     return;
   }
   // unlike gcc's vector_size attribute, the size is specified as the 
@@ -144,10 +142,8 @@
   }
   // navigate to the base type - we need to provide for vector pointers, 
   // vector arrays, and functions returning vectors.
-  Type *canonType = CurType.getCanonicalType().getTypePtr();
-  
-  if (canonType->isPointerType() || canonType->isArrayType() ||
-      canonType->isFunctionType()) {
+  if (CurType->isPointerType() || CurType->isArrayType() ||
+      CurType->isFunctionType()) {
     assert(0 && "HandleVector(): Complex type construction unimplemented");
     /* FIXME: rebuild the type from the inside out, vectorizing the inner type.
      do {
@@ -162,9 +158,9 @@
      */
   }
   // the base type must be integer or float.
-  if (!(canonType->isIntegerType() || canonType->isRealFloatingType())) {
+  if (!CurType->isIntegerType() && !CurType->isRealFloatingType()) {
     S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type,
-           CurType.getCanonicalType().getAsString());
+           CurType.getAsString());
     return;
   }
   unsigned typeSize = static_cast<unsigned>(S.Context.getTypeSize(CurType));
@@ -239,7 +235,6 @@
   // GCC ignores the nonnull attribute on K&R style function
   // prototypes, so we ignore it as well
   const FunctionTypeProto *proto = getFunctionProto(d);
-  
   if (!proto) {
     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type,
            "nonnull", "function");
@@ -275,7 +270,7 @@
     --x;
 
     // Is the function argument a pointer type?
-    if (!proto->getArgType(x).getCanonicalType()->isPointerType()) {
+    if (!proto->getArgType(x)->isPointerType()) {
       // FIXME: Should also highlight argument in decl.
       S.Diag(Attr.getLoc(), diag::err_nonnull_pointers_only,
              "nonnull", Ex->getSourceRange());

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Jul 26 17:17:49 2008
@@ -36,8 +36,7 @@
   /// diagnose the use of local variables or parameters within the
   /// default argument expression.
   class VISIBILITY_HIDDEN CheckDefaultArgumentVisitor 
-    : public StmtVisitor<CheckDefaultArgumentVisitor, bool>
-  {
+    : public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
     Expr *DefaultArg;
     Sema *S;
 
@@ -52,11 +51,9 @@
   /// VisitExpr - Visit all of the children of this expression.
   bool CheckDefaultArgumentVisitor::VisitExpr(Expr *Node) {
     bool IsInvalid = false;
-    for (Stmt::child_iterator first = Node->child_begin(), 
-           last = Node->child_end();
-         first != last; ++first)
-      IsInvalid |= Visit(*first);
-
+    for (Stmt::child_iterator I = Node->child_begin(), 
+         E = Node->child_end(); I != E; ++I)
+      IsInvalid |= Visit(*I);
     return IsInvalid;
   }
 
@@ -427,13 +424,14 @@
     // C++ 9.2p4: A member-declarator can contain a constant-initializer only
     // if it declares a static member of const integral or const enumeration
     // type.
-    if (CXXClassVarDecl *CVD =
-              dyn_cast<CXXClassVarDecl>(Member)) { // ...static member of...
+    if (CXXClassVarDecl *CVD = dyn_cast<CXXClassVarDecl>(Member)) {
+      // ...static member of...
       CVD->setInit(Init);
-      QualType MemberTy = CVD->getType().getCanonicalType();
       // ...const integral or const enumeration type.
-      if (MemberTy.isConstQualified() && MemberTy->isIntegralType()) {
-        if (CheckForConstantInitializer(Init, MemberTy)) // constant-initializer
+      if (Context.getCanonicalType(CVD->getType()).isConstQualified() &&
+          CVD->getType()->isIntegralType()) {
+        // constant-initializer
+        if (CheckForConstantInitializer(Init, CVD->getType()))
           InvalidDecl = true;
 
       } else {

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Jul 26 17:17:49 2008
@@ -727,8 +727,8 @@
 /// TODO: Handle protocol list; such as id<p1,p2> in type comparisons
 bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, 
                                       const ObjCMethodDecl *PrevMethod) {
-  if (Method->getResultType().getCanonicalType() !=
-      PrevMethod->getResultType().getCanonicalType())
+  if (Context.getCanonicalType(Method->getResultType()) !=
+      Context.getCanonicalType(PrevMethod->getResultType()))
     return false;
   for (unsigned i = 0, e = Method->getNumParams(); i != e; ++i) {
     ParmVarDecl *ParamDecl = Method->getParamDecl(i);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Jul 26 17:17:49 2008
@@ -105,8 +105,10 @@
   }
   // For conversion purposes, we ignore any qualifiers. 
   // For example, "const float" and "float" are equivalent.
-  QualType lhs = lhsExpr->getType().getCanonicalType().getUnqualifiedType();
-  QualType rhs = rhsExpr->getType().getCanonicalType().getUnqualifiedType();
+  QualType lhs =
+    Context.getCanonicalType(lhsExpr->getType()).getUnqualifiedType();
+  QualType rhs = 
+    Context.getCanonicalType(rhsExpr->getType()).getUnqualifiedType();
   
   // If both types are identical, no conversion is needed.
   if (lhs == rhs)
@@ -1318,8 +1320,8 @@
   rhptee = rhsType->getAsPointerType()->getPointeeType();
   
   // make sure we operate on the canonical type
-  lhptee = lhptee.getCanonicalType();
-  rhptee = rhptee.getCanonicalType();
+  lhptee = Context.getCanonicalType(lhptee);
+  rhptee = Context.getCanonicalType(rhptee);
 
   AssignConvertType ConvTy = Compatible;
   
@@ -1380,8 +1382,8 @@
 Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
   // Get canonical types.  We're not formatting these types, just comparing
   // them.
-  lhsType = lhsType.getCanonicalType().getUnqualifiedType();
-  rhsType = rhsType.getCanonicalType().getUnqualifiedType();
+  lhsType = Context.getCanonicalType(lhsType).getUnqualifiedType();
+  rhsType = Context.getCanonicalType(rhsType).getUnqualifiedType();
 
   if (lhsType == rhsType)
     return Compatible; // Common case: fast path an exact match.
@@ -1497,8 +1499,10 @@
                                                               Expr *&rex) {
   // For conversion purposes, we ignore any qualifiers. 
   // For example, "const float" and "float" are equivalent.
-  QualType lhsType = lex->getType().getCanonicalType().getUnqualifiedType();
-  QualType rhsType = rex->getType().getCanonicalType().getUnqualifiedType();
+  QualType lhsType =
+    Context.getCanonicalType(lex->getType()).getUnqualifiedType();
+  QualType rhsType =
+    Context.getCanonicalType(rex->getType()).getUnqualifiedType();
   
   // If the vector types are identical, return.
   if (lhsType == rhsType)
@@ -1744,9 +1748,9 @@
   // errors (when -pedantic-errors is enabled).
   if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
     QualType LCanPointeeTy =
-      lType->getAsPointerType()->getPointeeType().getCanonicalType();
+      Context.getCanonicalType(lType->getAsPointerType()->getPointeeType());
     QualType RCanPointeeTy =
-      rType->getAsPointerType()->getPointeeType().getCanonicalType();
+      Context.getCanonicalType(rType->getAsPointerType()->getPointeeType());
     
     if (!LHSIsNull && !RHSIsNull &&                       // C99 6.5.9p2
         !LCanPointeeTy->isVoidType() && !RCanPointeeTy->isVoidType() &&
@@ -2459,11 +2463,12 @@
 /// QualTypes that match the QualTypes of the arguments of the FnType.
 /// The number of arguments has already been validated to match the number of
 /// arguments in FnType.
-static bool ExprsMatchFnType(Expr **Args, const FunctionTypeProto *FnType) {
+static bool ExprsMatchFnType(Expr **Args, const FunctionTypeProto *FnType,
+                             ASTContext &Context) {
   unsigned NumParams = FnType->getNumArgs();
   for (unsigned i = 0; i != NumParams; ++i) {
-    QualType ExprTy = Args[i]->getType().getCanonicalType();
-    QualType ParmTy = FnType->getArgType(i).getCanonicalType();
+    QualType ExprTy = Context.getCanonicalType(Args[i]->getType());
+    QualType ParmTy = Context.getCanonicalType(FnType->getArgType(i));
 
     if (ExprTy.getUnqualifiedType() != ParmTy.getUnqualifiedType())
       return false;
@@ -2507,11 +2512,9 @@
     // UsualUnaryConversions will convert the function DeclRefExpr into a 
     // pointer to function.
     Expr *Fn = UsualUnaryConversions(Args[i]);
-    FunctionTypeProto *FnType = 0;
-    if (const PointerType *PT = Fn->getType()->getAsPointerType()) {
-      QualType PointeeType = PT->getPointeeType().getCanonicalType();
-      FnType = dyn_cast<FunctionTypeProto>(PointeeType);
-    }
+    const FunctionTypeProto *FnType = 0;
+    if (const PointerType *PT = Fn->getType()->getAsPointerType())
+      FnType = PT->getPointeeType()->getAsFunctionTypeProto();
  
     // The Expr type must be FunctionTypeProto, since FunctionTypeProto has no
     // parameters, and the number of parameters must match the value passed to
@@ -2523,7 +2526,7 @@
     // Scan the parameter list for the FunctionType, checking the QualType of
     // each parameter against the QualTypes of the arguments to the builtin.
     // If they match, return a new OverloadExpr.
-    if (ExprsMatchFnType(Args+1, FnType)) {
+    if (ExprsMatchFnType(Args+1, FnType, Context)) {
       if (OE)
         return Diag(Fn->getExprLoc(), diag::err_overload_multiple_match,
                     OE->getFn()->getSourceRange());

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=54105&r1=54104&r2=54105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Sat Jul 26 17:17:49 2008
@@ -233,19 +233,20 @@
 // ArgExprs is optional - if it is present, the number of expressions
 // is obtained from Sel.getNumArgs().
 Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
-  SourceLocation lbrac, SourceLocation rbrac, ExprTy **Args, unsigned NumArgs) 
-{
+                                            SourceLocation lbrac, 
+                                            SourceLocation rbrac,
+                                            ExprTy **Args, unsigned NumArgs) {
   assert(receiver && "missing receiver expression");
   
   Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
   Expr *RExpr = static_cast<Expr *>(receiver);
   QualType returnType;
 
-  QualType receiverType = 
-    RExpr->getType().getCanonicalType().getUnqualifiedType();
+  QualType ReceiverCType =
+    Context.getCanonicalType(RExpr->getType()).getUnqualifiedType();
   
   // Handle messages to id.
-  if (receiverType == Context.getObjCIdType().getCanonicalType()) {
+  if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType())) {
     ObjCMethodDecl *Method = InstanceMethodPool[Sel].Method;
     if (!Method)
       Method = FactoryMethodPool[Sel].Method;
@@ -264,7 +265,7 @@
   }
   
   // Handle messages to Class.
-  if (receiverType == Context.getObjCClassType().getCanonicalType()) {
+  if (ReceiverCType == Context.getCanonicalType(Context.getObjCClassType())) {
     ObjCMethodDecl *Method = 0;
     if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
       // If we have an implementation in scope, check "private" methods.
@@ -297,8 +298,7 @@
   
   // We allow sending a message to a qualified ID ("id<foo>"), which is ok as 
   // long as one of the protocols implements the selector (if not, warn).
-  if (ObjCQualifiedIdType *QIT = 
-           dyn_cast<ObjCQualifiedIdType>(receiverType)) {
+  if (ObjCQualifiedIdType *QIT = dyn_cast<ObjCQualifiedIdType>(ReceiverCType)) {
     // Search protocols
     for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
       ObjCProtocolDecl *PDecl = QIT->getProtocols(i);
@@ -310,7 +310,7 @@
            std::string("-"), Sel.getName(),
            RExpr->getSourceRange());
   } else if (const ObjCInterfaceType *OCIReceiver = 
-                receiverType->getAsPointerToObjCInterfaceType()) {
+                ReceiverCType->getAsPointerToObjCInterfaceType()) {
     // We allow sending a message to a pointer to an interface (an object).
     
     ClassDecl = OCIReceiver->getDecl();





More information about the cfe-commits mailing list