Don't hit an assertion failure when calculating the __PRETTY_FUNCTION__
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 14 Dec 2012 19:44:11 +0000 (19:44 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 14 Dec 2012 19:44:11 +0000 (19:44 +0000)
of a member function with parenthesized declarator.

Like this test case:

class Foo {
  const char *(baz)() {
    return __PRETTY_FUNCTION__;
  }
};

llvm-svn: 170233

clang/lib/AST/Expr.cpp
clang/test/CodeGenCXX/predefined-expr.cpp

index e6171eb..d3f8ac0 100644 (file)
@@ -510,7 +510,7 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
     POut << ")";
 
     if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
-      const FunctionType *FT = cast<FunctionType>(MD->getType().getTypePtr());
+      const FunctionType *FT = MD->getType()->castAs<FunctionType>();
       if (FT->isConst())
         POut << " const";
       if (FT->isVolatile())
index 1795ec8..24ead8f 100644 (file)
@@ -142,7 +142,7 @@ public:
     printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
   }
 
-  inline void inlineFunction() {
+  inline void (inlineFunction)() {
     printf("__func__ %s\n", __func__);
     printf("__FUNCTION__ %s\n", __FUNCTION__);
     printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);