SuppressUnwrittenScope(false), SuppressInitializers(false),
ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
SuppressStrongLifetime(false), Bool(LO.Bool),
- TerseOutput(false), SuppressAttributes(false),
+ TerseOutput(false), PolishForDeclaration(false),
DumpSourceManager(0) { }
/// \brief What language we're printing.
/// only the requested declaration.
unsigned TerseOutput : 1;
- /// \brief When true, do not print attributes attached to the declaration.
+ /// \brief When true, do certain refinement needed for producing proper
+ /// declaration tag; such as, do not print attributes attached to the declaration.
///
- unsigned SuppressAttributes : 1;
+ unsigned PolishForDeclaration : 1;
/// \brief If we are "dumping" rather than "pretty-printing", this points to
/// a SourceManager which will be used to dump SourceLocations. Dumping
}
void DeclPrinter::prettyPrintAttributes(Decl *D) {
- if (Policy.SuppressAttributes)
+ if (Policy.PolishForDeclaration)
return;
if (D->hasAttrs()) {
OMD->getBody()->printPretty(Out, 0, Policy);
Out << '\n';
}
- else
+ else if (Policy.PolishForDeclaration)
Out << ';';
}
Out << "@class " << I << ";";
return;
}
-
+ bool eolnOut = false;
if (SID)
Out << "@interface " << I << " : " << *SID;
else
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end(); I != E; ++I)
Out << (I == Protocols.begin() ? '<' : ',') << **I;
- }
-
- if (!Protocols.empty())
Out << "> ";
+ }
if (OID->ivar_size() > 0) {
Out << "{\n";
+ eolnOut = true;
Indentation += Policy.Indentation;
for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
E = OID->ivar_end(); I != E; ++I) {
Indentation -= Policy.Indentation;
Out << "}\n";
}
+ else if (SID) {
+ Out << "\n";
+ eolnOut = true;
+ }
VisitDeclContext(OID, false);
+ if (!eolnOut)
+ Out << ' ';
Out << "@end";
// FIXME: implement the rest...
}
void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
if (!PID->isThisDeclarationADefinition()) {
- Out << "@protocol " << PID->getIdentifier() << ";\n";
+ Out << "@protocol " << *PID << ";\n";
return;
}
-
- Out << "@protocol " << *PID << '\n';
+ // Protocols?
+ const ObjCList<ObjCProtocolDecl> &Protocols = PID->getReferencedProtocols();
+ if (!Protocols.empty()) {
+ Out << "@protocol " << *PID;
+ for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
+ E = Protocols.end(); I != E; ++I)
+ Out << (I == Protocols.begin() ? '<' : ',') << **I;
+ Out << ">\n";
+ } else
+ Out << "@protocol " << *PID << '\n';
VisitDeclContext(PID, false);
Out << "@end";
}
(void) first; // Silence dead store warning due to idiomatic code.
Out << " )";
}
- Out << ' ' << PDecl->getType().getAsString(Policy) << ' ' << *PDecl << ';';
+ Out << ' ' << PDecl->getType().getAsString(Policy) << ' ' << *PDecl;
+ if (Policy.PolishForDeclaration)
+ Out << ';';
}
void DeclPrinter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PID) {
const LangOptions &LangOpts = Context.getLangOpts();
llvm::raw_svector_ostream OS(Str);
PrintingPolicy PPolicy(LangOpts);
- PPolicy.SuppressAttributes = true;
+ PPolicy.PolishForDeclaration = true;
PPolicy.TerseOutput = true;
ThisDecl->CurrentDecl->print(OS, PPolicy,
/*Indentation*/0, /*PrintInstantiation*/true);