[cfe-commits] r69004 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGen/function-decay.m

Steve Naroff snaroff at apple.com
Mon Apr 13 17:03:58 PDT 2009


Author: snaroff
Date: Mon Apr 13 19:03:58 2009
New Revision: 69004

URL: http://llvm.org/viewvc/llvm-project?rev=69004&view=rev
Log:
Fix crasher in ASTContext::getObjCEncodingForMethodDecl().

This was exposed as a result of something else that was recently fixed.

Added:
    cfe/trunk/test/CodeGen/function-decay.m
Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Apr 13 19:03:58 2009
@@ -2081,11 +2081,13 @@
     ParmVarDecl *PVDecl = *PI;
     QualType PType = PVDecl->getOriginalType(); 
     if (const ArrayType *AT =
-          dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) 
-        // Use array's original type only if it has known number of
-        // elements.
-        if (!dyn_cast<ConstantArrayType>(AT))
-          PType = PVDecl->getType();
+          dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
+      // Use array's original type only if it has known number of
+      // elements.
+      if (!dyn_cast<ConstantArrayType>(AT))
+        PType = PVDecl->getType();
+    } else if (PType->isFunctionType())
+      PType = PVDecl->getType();
     // Process argument qualifiers for user supplied arguments; such as,
     // 'in', 'inout', etc.
     getObjCEncodingForTypeQualifier(PVDecl->getObjCDeclQualifier(), S);

Added: cfe/trunk/test/CodeGen/function-decay.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-decay.m?rev=69004&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/function-decay.m (added)
+++ cfe/trunk/test/CodeGen/function-decay.m Mon Apr 13 19:03:58 2009
@@ -0,0 +1,10 @@
+// RUN: clang-cc %s -emit-llvm
+
+ at interface I0 @end
+ at implementation I0
+- (void) im0: (int (void)) a0 {
+}
+ at end
+
+void func(int pf(void)) {
+}





More information about the cfe-commits mailing list