]> granicus.if.org Git - clang/commitdiff
Never suppress specifiers when printing the parameters of a function
authorDouglas Gregor <dgregor@apple.com>
Sat, 30 May 2009 05:39:39 +0000 (05:39 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 30 May 2009 05:39:39 +0000 (05:39 +0000)
declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72613 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclPrinter.cpp
test/Coverage/c-language-features.inc

index 72f97035ef1af7ede58c2b69a2e5b15bbffd3e46..6412f750ae9713f201fe60e9a1c8e454ae874adf 100644 (file)
@@ -296,6 +296,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
     if (D->isVirtualAsWritten()) Out << "virtual ";
   }
 
+  PrintingPolicy SubPolicy(Policy);
+  SubPolicy.SuppressSpecifiers = false;
   std::string Proto = D->getNameAsString();
   if (isa<FunctionType>(D->getType().getTypePtr())) {
     const FunctionType *AFT = D->getType()->getAsFunctionType();
@@ -307,7 +309,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
     Proto += "(";
     if (FT) {
       llvm::raw_string_ostream POut(Proto);
-      DeclPrinter ParamPrinter(POut, Context, Policy, Indentation);
+      DeclPrinter ParamPrinter(POut, Context, SubPolicy, Indentation);
       for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {
         if (i) POut << ", ";
         ParamPrinter.VisitParmVarDecl(D->getParamDecl(i));
@@ -342,17 +344,18 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
       // This is a K&R function definition, so we need to print the
       // parameters.
       Out << '\n';
+      DeclPrinter ParamPrinter(Out, Context, SubPolicy, Indentation);
       Indentation += Policy.Indentation;
       for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {
         Indent();
-        VisitParmVarDecl(D->getParamDecl(i));
+        ParamPrinter.VisitParmVarDecl(D->getParamDecl(i));
         Out << ";\n";
       }
       Indentation -= Policy.Indentation;
     } else
       Out << ' ';
 
-    D->getBody(Context)->printPretty(Out, Context, 0, Policy, Indentation);
+    D->getBody(Context)->printPretty(Out, Context, 0, SubPolicy, Indentation);
     Out << '\n';
   }
 }
index 27fae62d3e801d1d64102bb41b5acb4199c6ceac..5258040cc11c27a5956f0c4631eac0dbc01c6a4c 100644 (file)
@@ -138,6 +138,8 @@ void f4(int a0, int a1, int a2, va_list ap) {
   _Complex float t32_a, t32_b;
   int t32_cond;
   int t32 = __real (t32_cond ? t32_a : t32_b);
+
+  struct { int x, y; } t33, *t34, t35[12], t36(int, float);
 }
 
 // Extended vectors