[cfe-commits] r92171 - in /cfe/trunk: lib/AST/Expr.cpp test/CodeGenCXX/predefined-expr.cpp
Sam Weinig
sam.weinig at gmail.com
Sat Dec 26 17:38:21 PST 2009
Author: weinig
Date: Sat Dec 26 19:38:20 2009
New Revision: 92171
URL: http://llvm.org/viewvc/llvm-project?rev=92171&view=rev
Log:
Fix for PR5872. Add static specifier and const/volatile qualifiers to member functions in __PRETTY_FUNCTION__ predefined expressions.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CodeGenCXX/predefined-expr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=92171&r1=92170&r2=92171&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Dec 26 19:38:20 2009
@@ -174,6 +174,8 @@
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
if (MD->isVirtual())
Out << "virtual ";
+ if (MD->isStatic())
+ Out << "static ";
}
PrintingPolicy Policy(Context.getLangOptions());
@@ -203,6 +205,14 @@
}
Proto += ")";
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+ Qualifiers ThisQuals = Qualifiers::fromCVRMask(MD->getTypeQualifiers());
+ if (ThisQuals.hasConst())
+ Proto += " const";
+ if (ThisQuals.hasVolatile())
+ Proto += " volatile";
+ }
+
if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
AFT->getResultType().getAsStringInternal(Proto, Policy);
Modified: cfe/trunk/test/CodeGenCXX/predefined-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/predefined-expr.cpp?rev=92171&r1=92170&r2=92171&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/predefined-expr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/predefined-expr.cpp Sat Dec 26 19:38:20 2009
@@ -31,6 +31,15 @@
// CHECK: private constant [16 x i8] c"virtualFunction\00"
// CHECK: private constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
+// CHECK: private constant [22 x i8] c"constVolatileFunction\00"
+// CHECK: private constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
+
+// CHECK: private constant [17 x i8] c"volatileFunction\00"
+// CHECK: private constant [43 x i8] c"void NS::Base::volatileFunction() volatile\00"
+
+// CHECK: private constant [14 x i8] c"constFunction\00"
+// CHECK: private constant [37 x i8] c"void NS::Base::constFunction() const\00"
+
// CHECK: private constant [26 x i8] c"functionReturingTemplate2\00"
// CHECK: private constant [64 x i8] c"ClassTemplate<NS::Base *> NS::Base::functionReturingTemplate2()\00"
@@ -57,8 +66,8 @@
// CHECK: private constant [15 x i8] c"inlineFunction\00"
// CHECK: private constant [32 x i8] c"void NS::Base::inlineFunction()\00"
-// CHECK: private constant [11 x i8] c"staticFunc\00"
-// CHECK: private constant [28 x i8] c"void NS::Base::staticFunc()\00"
+// CHECK: private constant [15 x i8] c"staticFunction\00"
+// CHECK: private constant [39 x i8] c"static void NS::Base::staticFunction()\00"
// CHECK: private constant [26 x i8] c"topLevelNamespaceFunction\00"
// CHECK: private constant [59 x i8] c"void ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
@@ -104,7 +113,7 @@
class Base {
public:
- static void staticFunc() {
+ static void staticFunction() {
printf("__func__ %s\n", __func__);
printf("__FUNCTION__ %s\n", __FUNCTION__);
printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
@@ -173,6 +182,24 @@
printf("__FUNCTION__ %s\n", __FUNCTION__);
printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
}
+
+ void constFunction() const {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void volatileFunction() volatile {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void constVolatileFunction() const volatile {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
};
class Derived : public Base {
@@ -258,7 +285,7 @@
ClassInTopLevelNamespace topLevelNamespace;
topLevelNamespace.topLevelNamespaceFunction();
- NS::Base::staticFunc();
+ NS::Base::staticFunction();
NS::Base b;
b.inlineFunction();
@@ -273,7 +300,10 @@
b.functionReturingTemplate2();
b.functionTemplate1<int>(0);
b.functionTemplate1<NS::Base *>(0);
-
+ b.constFunction();
+ b.volatileFunction();
+ b.constVolatileFunction();
+
NS::Derived d;
d.virtualFunction();
More information about the cfe-commits
mailing list