r202181 - Pretty Printer: Print constexpr and ref qualifiers. Don't print return types on destructors.
Benjamin Kramer
benny.kra at googlemail.com
Tue Feb 25 10:49:49 PST 2014
Author: d0k
Date: Tue Feb 25 12:49:49 2014
New Revision: 202181
URL: http://llvm.org/viewvc/llvm-project?rev=202181&view=rev
Log:
Pretty Printer: Print constexpr and ref qualifiers. Don't print return types on destructors.
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Index/comment-cplus-decls.cpp
cfe/trunk/test/Index/comment-cplus-template-decls.cpp
cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
cfe/trunk/unittests/AST/DeclPrinterTest.cpp
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=202181&r1=202180&r2=202181&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Feb 25 12:49:49 2014
@@ -399,6 +399,7 @@ void DeclPrinter::VisitFunctionDecl(Func
if (D->isInlineSpecified()) Out << "inline ";
if (D->isVirtualAsWritten()) Out << "virtual ";
if (D->isModulePrivate()) Out << "__module_private__ ";
+ if (D->isConstexpr() && !D->isExplicitlyDefaulted()) Out << "constexpr ";
if ((CDecl && CDecl->isExplicitSpecified()) ||
(ConversionDecl && ConversionDecl->isExplicit()))
Out << "explicit ";
@@ -449,6 +450,17 @@ void DeclPrinter::VisitFunctionDecl(Func
Proto += " volatile";
if (FT->isRestrict())
Proto += " restrict";
+
+ switch (FT->getRefQualifier()) {
+ case RQ_None:
+ break;
+ case RQ_LValue:
+ Proto += " &";
+ break;
+ case RQ_RValue:
+ Proto += " &&";
+ break;
+ }
}
if (FT && FT->hasDynamicExceptionSpec()) {
@@ -537,8 +549,10 @@ void DeclPrinter::VisitFunctionDecl(Func
}
}
Out << ")";
+ if (BMInitializer->isPackExpansion())
+ Out << "...";
}
- } else if (!ConversionDecl) {
+ } else if (!ConversionDecl && !isa<CXXDestructorDecl>(D)) {
if (FT && FT->hasTrailingReturn()) {
Out << "auto " << Proto << " -> ";
Proto.clear();
Modified: cfe/trunk/test/Index/comment-cplus-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-cplus-decls.cpp?rev=202181&r1=202180&r2=202181&view=diff
==============================================================================
--- cfe/trunk/test/Index/comment-cplus-decls.cpp (original)
+++ cfe/trunk/test/Index/comment-cplus-decls.cpp Tue Feb 25 12:49:49 2014
@@ -42,7 +42,7 @@ protected:
// CHECK: <Declaration>class Test {}</Declaration>
// CHECK: <Declaration>Test() : reserved(new Test::data())</Declaration>
// CHECK: <Declaration>unsigned int getID() const</Declaration>
-// CHECK: <Declaration>void ~Test()</Declaration>
+// CHECK: <Declaration>~Test()</Declaration>
// CHECK: <Declaration>Test::data *reserved</Declaration>
Modified: cfe/trunk/test/Index/comment-cplus-template-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-cplus-template-decls.cpp?rev=202181&r1=202180&r2=202181&view=diff
==============================================================================
--- cfe/trunk/test/Index/comment-cplus-template-decls.cpp (original)
+++ cfe/trunk/test/Index/comment-cplus-template-decls.cpp Tue Feb 25 12:49:49 2014
@@ -27,7 +27,7 @@ template<typename T> struct A {
};
// CHECK: <Declaration>template <typename T> struct A {}</Declaration>
// CHECK: <Declaration>A<T>()</Declaration>
-// CHECK: <Declaration>void ~A<T>()</Declaration>
+// CHECK: <Declaration>~A<T>()</Declaration>
/**
* \Brief Eee
Modified: cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp?rev=202181&r1=202180&r2=202181&view=diff
==============================================================================
--- cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp (original)
+++ cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp Tue Feb 25 12:49:49 2014
@@ -734,7 +734,7 @@ class comment_to_xml_conversion_01 {
/// Aaa.
~comment_to_xml_conversion_01();
-// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: CXXDestructor=~comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="3"><Name>~comment_to_xml_conversion_01</Name><USR>c:@C at comment_to_xml_conversion_01@F@~comment_to_xml_conversion_01#</USR><Declaration>void ~comment_to_xml_conversion_01()</Declaration><Abstract><Para> Aaa.</Para></Abstract></Function>]
+// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: CXXDestructor=~comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="3"><Name>~comment_to_xml_conversion_01</Name><USR>c:@C at comment_to_xml_conversion_01@F@~comment_to_xml_conversion_01#</USR><Declaration>~comment_to_xml_conversion_01()</Declaration><Abstract><Para> Aaa.</Para></Abstract></Function>]
/// \param aaa Blah blah.
int comment_to_xml_conversion_02(int aaa);
Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=202181&r1=202180&r2=202181&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Tue Feb 25 12:49:49 2014
@@ -354,8 +354,8 @@ TEST(DeclPrinter, TestFunctionDecl7) {
ASSERT_TRUE(PrintedDeclCXX11Matches(
"constexpr int A(int a);",
"A",
- "int A(int a)"));
- // WRONG; Should be: "constexpr int A(int a);"
+ "constexpr int A(int a)"));
+ // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl8) {
@@ -480,8 +480,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl
" constexpr A();"
"};",
constructorDecl(ofClass(hasName("A"))).bind("id"),
- "A()"));
- // WRONG; Should be: "constexpr A();"
+ "constexpr A()"));
}
TEST(DeclPrinter, TestCXXConstructorDecl8) {
@@ -519,8 +518,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl
" A(T&&... ts) : T(ts)... {}"
"};",
constructorDecl(ofClass(hasName("A"))).bind("id"),
- "A<T...>(T &&ts...) : T(ts)"));
- // WRONG; Should be: "A(T&&... ts) : T(ts)..."
+ "A<T...>(T &&ts...) : T(ts)..."));
}
TEST(DeclPrinter, TestCXXDestructorDecl1) {
@@ -529,8 +527,7 @@ TEST(DeclPrinter, TestCXXDestructorDecl1
" ~A();"
"};",
destructorDecl(ofClass(hasName("A"))).bind("id"),
- "void ~A()"));
- // WRONG; Should be: "~A();"
+ "~A()"));
}
TEST(DeclPrinter, TestCXXDestructorDecl2) {
@@ -539,8 +536,7 @@ TEST(DeclPrinter, TestCXXDestructorDecl2
" virtual ~A();"
"};",
destructorDecl(ofClass(hasName("A"))).bind("id"),
- "virtual void ~A()"));
- // WRONG; Should be: "virtual ~A();"
+ "virtual ~A()"));
}
TEST(DeclPrinter, TestCXXConversionDecl1) {
@@ -765,8 +761,8 @@ TEST(DeclPrinter, TestCXXMethodDecl_RefQ
" void A(int a) &;"
"};",
"A",
- "void A(int a)"));
- // WRONG; Should be: "void A(int a) &;"
+ "void A(int a) &"));
+ // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_RefQualifier2) {
@@ -775,8 +771,8 @@ TEST(DeclPrinter, TestCXXMethodDecl_RefQ
" void A(int a) &&;"
"};",
"A",
- "void A(int a)"));
- // WRONG; Should be: "void A(int a) &&;"
+ "void A(int a) &&"));
+ // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification1) {
More information about the cfe-commits
mailing list