[cfe-commits] r111782 - in /cfe/trunk: include/clang/AST/Type.h lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/member-function-pointers.cpp

Douglas Gregor dgregor at apple.com
Sun Aug 22 11:26:35 PDT 2010


Author: dgregor
Date: Sun Aug 22 13:26:35 2010
New Revision: 111782

URL: http://llvm.org/viewvc/llvm-project?rev=111782&view=rev
Log:
Eliminate a stale assertion. Fixes Clang self-host.

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
    cfe/trunk/test/CodeGenCXX/member-function-pointers.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=111782&r1=111781&r2=111782&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Aug 22 13:26:35 2010
@@ -897,6 +897,7 @@
   bool isFunctionPointerType() const;
   bool isMemberPointerType() const;
   bool isMemberFunctionPointerType() const;
+  bool isMemberDataPointerType() const;
   bool isArrayType() const;
   bool isConstantArrayType() const;
   bool isIncompleteArrayType() const;
@@ -3486,6 +3487,12 @@
   else
     return false;
 }
+inline bool Type::isMemberDataPointerType() const {
+  if (const MemberPointerType* T = getAs<MemberPointerType>())
+    return !T->getPointeeType()->isFunctionType();
+  else
+    return false;
+}
 inline bool Type::isArrayType() const {
   return isa<ArrayType>(CanonicalType);
 }

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=111782&r1=111781&r2=111782&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sun Aug 22 13:26:35 2010
@@ -569,12 +569,9 @@
 Value *ScalarExprEmitter::EmitNullValue(QualType Ty) {
   const llvm::Type *LTy = ConvertType(Ty);
   
-  if (!Ty->isMemberPointerType())
+  if (!Ty->isMemberDataPointerType())
     return llvm::Constant::getNullValue(LTy);
   
-  assert(!Ty->isMemberFunctionPointerType() &&
-         "member function pointers are not scalar!");
-
   // Itanium C++ ABI 2.3:
   //   A NULL pointer is represented as -1.
   return llvm::ConstantInt::get(LTy, -1ULL, /*isSigned=*/true);  

Modified: cfe/trunk/test/CodeGenCXX/member-function-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/member-function-pointers.cpp?rev=111782&r1=111781&r2=111782&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/member-function-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/member-function-pointers.cpp Sun Aug 22 13:26:35 2010
@@ -198,3 +198,14 @@
   void (C::*ptr4)() = &B::vfoo;
   void (C::*ptr5)() = &C::vfoo;
 }
+
+namespace test8 {
+  struct X { };
+  typedef int (X::*pmf)(int);
+  
+  // CHECK: {{define.*_ZN5test81fEv}}
+  pmf f() {
+    // CHECK: {{ret.*zeroinitializer}}
+    return pmf();
+  }
+}





More information about the cfe-commits mailing list