blob: 08e2238a66aec28e7a5b9d30a349ad68ad191cd7 [file] [log] [blame]
Chris Lattner97e8b6f2007-10-07 06:04:32 +00001//===--- ASTConsumers.cpp - ASTConsumer implementations -------------------===//
Reid Spencer5f016e22007-07-11 17:01:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner97e8b6f2007-10-07 06:04:32 +000010// AST Consumer Implementations.
Reid Spencer5f016e22007-07-11 17:01:13 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner97e8b6f2007-10-07 06:04:32 +000014#include "ASTConsumers.h"
Ted Kremenek77cda502007-12-18 21:34:28 +000015#include "clang/AST/TranslationUnit.h"
Chris Lattner8ee3c032008-02-06 02:01:47 +000016#include "clang/Basic/Diagnostic.h"
Ted Kremenek54117722007-12-20 00:34:58 +000017#include "clang/Basic/SourceManager.h"
18#include "clang/Basic/FileManager.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000019#include "clang/AST/AST.h"
Chris Lattner3d4997d2007-09-15 23:02:28 +000020#include "clang/AST/ASTConsumer.h"
Ted Kremenekfddd5182007-08-21 21:42:03 +000021#include "clang/AST/CFG.h"
Ted Kremenekcf6e41b2007-12-21 21:42:19 +000022#include "clang/Analysis/Analyses/LiveVariables.h"
Ted Kremeneke01c9872008-02-14 22:36:46 +000023#include "clang/Analysis/Analyses/GRSimpleVals.h"
Ted Kremenek055c2752007-09-06 23:00:42 +000024#include "clang/Analysis/LocalCheckers.h"
Ted Kremenekea75c552007-11-28 21:32:21 +000025#include "llvm/Support/Streams.h"
Chris Lattner6000dac2007-08-08 22:51:59 +000026using namespace clang;
Reid Spencer5f016e22007-07-11 17:01:13 +000027
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000028//===----------------------------------------------------------------------===//
29/// DeclPrinter - Utility class for printing top-level decls.
Chris Lattner6000dac2007-08-08 22:51:59 +000030
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000031namespace {
32 class DeclPrinter {
33 public:
Ted Kremenekea75c552007-11-28 21:32:21 +000034 std::ostream& Out;
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000035
Chris Lattner4b1daf02008-01-10 01:43:14 +000036 DeclPrinter(std::ostream* out) : Out(out ? *out : *llvm::cerr.stream()) {}
Ted Kremenekea75c552007-11-28 21:32:21 +000037 DeclPrinter() : Out(*llvm::cerr.stream()) {}
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000038
Chris Lattneref5a85d2008-01-02 21:04:16 +000039 void PrintDecl(Decl *D);
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000040 void PrintFunctionDeclStart(FunctionDecl *FD);
41 void PrintTypeDefDecl(TypedefDecl *TD);
Chris Lattnerc6fdc342008-01-12 07:05:38 +000042 void PrintLinkageSpec(LinkageSpecDecl *LS);
Ted Kremeneka526c5c2008-01-07 19:49:32 +000043 void PrintObjCMethodDecl(ObjCMethodDecl *OMD);
44 void PrintObjCImplementationDecl(ObjCImplementationDecl *OID);
45 void PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID);
46 void PrintObjCProtocolDecl(ObjCProtocolDecl *PID);
47 void PrintObjCCategoryImplDecl(ObjCCategoryImplDecl *PID);
48 void PrintObjCCategoryDecl(ObjCCategoryDecl *PID);
49 void PrintObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *AID);
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000050 };
51} // end anonymous namespace
52
Chris Lattneref5a85d2008-01-02 21:04:16 +000053void DeclPrinter:: PrintDecl(Decl *D) {
54 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
55 PrintFunctionDeclStart(FD);
56
57 if (FD->getBody()) {
58 Out << ' ';
59 FD->getBody()->printPretty(Out);
60 Out << '\n';
61 }
Ted Kremeneka526c5c2008-01-07 19:49:32 +000062 } else if (isa<ObjCMethodDecl>(D)) {
Chris Lattneref5a85d2008-01-02 21:04:16 +000063 // Do nothing, methods definitions are printed in
Ted Kremeneka526c5c2008-01-07 19:49:32 +000064 // PrintObjCImplementationDecl.
Chris Lattneref5a85d2008-01-02 21:04:16 +000065 } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
66 PrintTypeDefDecl(TD);
Ted Kremeneka526c5c2008-01-07 19:49:32 +000067 } else if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(D)) {
68 PrintObjCInterfaceDecl(OID);
69 } else if (ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(D)) {
70 PrintObjCProtocolDecl(PID);
71 } else if (ObjCForwardProtocolDecl *OFPD =
72 dyn_cast<ObjCForwardProtocolDecl>(D)) {
Chris Lattneref5a85d2008-01-02 21:04:16 +000073 Out << "@protocol ";
74 for (unsigned i = 0, e = OFPD->getNumForwardDecls(); i != e; ++i) {
Ted Kremeneka526c5c2008-01-07 19:49:32 +000075 const ObjCProtocolDecl *D = OFPD->getForwardProtocolDecl(i);
Chris Lattneref5a85d2008-01-02 21:04:16 +000076 if (i) Out << ", ";
77 Out << D->getName();
78 }
79 Out << ";\n";
Ted Kremeneka526c5c2008-01-07 19:49:32 +000080 } else if (ObjCImplementationDecl *OID =
81 dyn_cast<ObjCImplementationDecl>(D)) {
82 PrintObjCImplementationDecl(OID);
83 } else if (ObjCCategoryImplDecl *OID =
84 dyn_cast<ObjCCategoryImplDecl>(D)) {
85 PrintObjCCategoryImplDecl(OID);
86 } else if (ObjCCategoryDecl *OID =
87 dyn_cast<ObjCCategoryDecl>(D)) {
88 PrintObjCCategoryDecl(OID);
89 } else if (ObjCCompatibleAliasDecl *OID =
90 dyn_cast<ObjCCompatibleAliasDecl>(D)) {
91 PrintObjCCompatibleAliasDecl(OID);
92 } else if (isa<ObjCClassDecl>(D)) {
Chris Lattneref5a85d2008-01-02 21:04:16 +000093 Out << "@class [printing todo]\n";
94 } else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
95 Out << "Read top-level tag decl: '" << TD->getName() << "'\n";
96 } else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {
97 Out << "Read top-level variable decl: '" << SD->getName() << "'\n";
Chris Lattnerc6fdc342008-01-12 07:05:38 +000098 } else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {
99 PrintLinkageSpec(LSD);
Anders Carlssondfab6cb2008-02-08 00:33:21 +0000100 } else if (FileScopeAsmDecl *AD = dyn_cast<FileScopeAsmDecl>(D)) {
101 Out << "asm(";
102 AD->getAsmString()->printPretty(Out);
103 Out << ")\n";
Chris Lattneref5a85d2008-01-02 21:04:16 +0000104 } else {
105 assert(0 && "Unknown decl type!");
106 }
107}
108
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000109void DeclPrinter::PrintFunctionDeclStart(FunctionDecl *FD) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000110 bool HasBody = FD->getBody();
111
Ted Kremenekea75c552007-11-28 21:32:21 +0000112 Out << '\n';
Chris Lattner70c8b2e2007-08-26 04:02:13 +0000113
114 switch (FD->getStorageClass()) {
115 default: assert(0 && "Unknown storage class");
116 case FunctionDecl::None: break;
Ted Kremenekea75c552007-11-28 21:32:21 +0000117 case FunctionDecl::Extern: Out << "extern "; break;
118 case FunctionDecl::Static: Out << "static "; break;
Chris Lattner70c8b2e2007-08-26 04:02:13 +0000119 }
120
121 if (FD->isInline())
Ted Kremenekea75c552007-11-28 21:32:21 +0000122 Out << "inline ";
Chris Lattner70c8b2e2007-08-26 04:02:13 +0000123
Reid Spencer5f016e22007-07-11 17:01:13 +0000124 std::string Proto = FD->getName();
Chris Lattner0d6ca112007-12-03 21:43:25 +0000125 const FunctionType *AFT = FD->getType()->getAsFunctionType();
Reid Spencer5f016e22007-07-11 17:01:13 +0000126
Chris Lattner0d6ca112007-12-03 21:43:25 +0000127 if (const FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(AFT)) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000128 Proto += "(";
129 for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
130 if (i) Proto += ", ";
131 std::string ParamStr;
132 if (HasBody) ParamStr = FD->getParamDecl(i)->getName();
133
134 FT->getArgType(i).getAsStringInternal(ParamStr);
135 Proto += ParamStr;
136 }
137
138 if (FT->isVariadic()) {
139 if (FD->getNumParams()) Proto += ", ";
140 Proto += "...";
141 }
142 Proto += ")";
143 } else {
144 assert(isa<FunctionTypeNoProto>(AFT));
145 Proto += "()";
146 }
147
148 AFT->getResultType().getAsStringInternal(Proto);
Ted Kremenekea75c552007-11-28 21:32:21 +0000149 Out << Proto;
Reid Spencer5f016e22007-07-11 17:01:13 +0000150
Chris Lattner6000dac2007-08-08 22:51:59 +0000151 if (!FD->getBody())
Ted Kremenekea75c552007-11-28 21:32:21 +0000152 Out << ";\n";
Chris Lattner6000dac2007-08-08 22:51:59 +0000153 // Doesn't print the body.
Reid Spencer5f016e22007-07-11 17:01:13 +0000154}
155
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000156void DeclPrinter::PrintTypeDefDecl(TypedefDecl *TD) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000157 std::string S = TD->getName();
158 TD->getUnderlyingType().getAsStringInternal(S);
Ted Kremenekea75c552007-11-28 21:32:21 +0000159 Out << "typedef " << S << ";\n";
Reid Spencer5f016e22007-07-11 17:01:13 +0000160}
161
Chris Lattnerc6fdc342008-01-12 07:05:38 +0000162void DeclPrinter::PrintLinkageSpec(LinkageSpecDecl *LS) {
163 const char *l;
164 if (LS->getLanguage() == LinkageSpecDecl::lang_c)
165 l = "C";
166 else if (LS->getLanguage() == LinkageSpecDecl::lang_cxx)
167 l = "C++";
168 else assert(0 && "unknown language in linkage specification");
169 Out << "extern \"" << l << "\" { ";
170 PrintDecl(LS->getDecl());
171 Out << "}\n";
172}
173
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000174void DeclPrinter::PrintObjCMethodDecl(ObjCMethodDecl *OMD) {
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000175 if (OMD->isInstance())
Ted Kremenekea75c552007-11-28 21:32:21 +0000176 Out << "\n- ";
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000177 else
Ted Kremenekea75c552007-11-28 21:32:21 +0000178 Out << "\n+ ";
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000179 if (!OMD->getResultType().isNull())
Ted Kremenekea75c552007-11-28 21:32:21 +0000180 Out << '(' << OMD->getResultType().getAsString() << ") ";
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000181 // FIXME: just print original selector name!
Ted Kremenekea75c552007-11-28 21:32:21 +0000182 Out << OMD->getSelector().getName();
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000183
184 for (int i = 0; i < OMD->getNumParams(); i++) {
185 ParmVarDecl *PDecl = OMD->getParamDecl(i);
Ted Kremenekea75c552007-11-28 21:32:21 +0000186 // FIXME: selector is missing here!
187 Out << " :(" << PDecl->getType().getAsString() << ") " << PDecl->getName();
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000188 }
189}
190
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000191void DeclPrinter::PrintObjCImplementationDecl(ObjCImplementationDecl *OID) {
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000192 std::string I = OID->getName();
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000193 ObjCInterfaceDecl *SID = OID->getSuperClass();
Ted Kremenekea75c552007-11-28 21:32:21 +0000194
195 if (SID)
196 Out << "@implementation " << I << " : " << SID->getName();
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000197 else
Ted Kremenekea75c552007-11-28 21:32:21 +0000198 Out << "@implementation " << I;
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000199
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000200 for (ObjCImplementationDecl::instmeth_iterator I = OID->instmeth_begin(),
Chris Lattnerab4c4d52007-12-12 07:46:12 +0000201 E = OID->instmeth_end(); I != E; ++I) {
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000202 ObjCMethodDecl *OMD = *I;
203 PrintObjCMethodDecl(OMD);
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000204 if (OMD->getBody()) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000205 Out << ' ';
206 OMD->getBody()->printPretty(Out);
207 Out << '\n';
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000208 }
209 }
210
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000211 for (ObjCImplementationDecl::classmeth_iterator I = OID->classmeth_begin(),
Chris Lattnerab4c4d52007-12-12 07:46:12 +0000212 E = OID->classmeth_end(); I != E; ++I) {
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000213 ObjCMethodDecl *OMD = *I;
214 PrintObjCMethodDecl(OMD);
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000215 if (OMD->getBody()) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000216 Out << ' ';
217 OMD->getBody()->printPretty(Out);
218 Out << '\n';
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000219 }
220 }
221
Ted Kremenekea75c552007-11-28 21:32:21 +0000222 Out << "@end\n";
Fariborz Jahaniandb8f3d32007-11-10 20:59:13 +0000223}
224
225
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000226void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000227 std::string I = OID->getName();
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000228 ObjCInterfaceDecl *SID = OID->getSuperClass();
Ted Kremenekea75c552007-11-28 21:32:21 +0000229
230 if (SID)
231 Out << "@interface " << I << " : " << SID->getName();
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000232 else
Ted Kremenekea75c552007-11-28 21:32:21 +0000233 Out << "@interface " << I;
234
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000235 // Protocols?
236 int count = OID->getNumIntfRefProtocols();
Ted Kremenekea75c552007-11-28 21:32:21 +0000237
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000238 if (count > 0) {
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000239 ObjCProtocolDecl **refProtocols = OID->getReferencedProtocols();
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000240 for (int i = 0; i < count; i++)
Ted Kremenekea75c552007-11-28 21:32:21 +0000241 Out << (i == 0 ? '<' : ',') << refProtocols[i]->getName();
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000242 }
Ted Kremenekea75c552007-11-28 21:32:21 +0000243
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000244 if (count > 0)
Ted Kremenekea75c552007-11-28 21:32:21 +0000245 Out << ">\n";
Fariborz Jahaniane37882a2007-10-08 23:06:41 +0000246 else
Ted Kremenekea75c552007-11-28 21:32:21 +0000247 Out << '\n';
Fariborz Jahanianedcfb422007-10-26 16:29:12 +0000248
Chris Lattnerbe6df082007-12-12 07:56:42 +0000249 if (OID->getNumInstanceVariables() > 0) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000250 Out << '{';
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000251 for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
Chris Lattnerbe6df082007-12-12 07:56:42 +0000252 E = OID->ivar_end(); I != E; ++I) {
253 Out << '\t' << (*I)->getType().getAsString()
254 << ' ' << (*I)->getName() << ";\n";
Fariborz Jahanianedcfb422007-10-26 16:29:12 +0000255 }
Ted Kremenekea75c552007-11-28 21:32:21 +0000256 Out << "}\n";
Fariborz Jahanianedcfb422007-10-26 16:29:12 +0000257 }
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000258
259 int NumProperties = OID->getNumPropertyDecl();
260 if (NumProperties > 0) {
261 for (int i = 0; i < NumProperties; i++) {
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000262 ObjCPropertyDecl *PDecl = OID->getPropertyDecl()[i];
Ted Kremenekea75c552007-11-28 21:32:21 +0000263 Out << "@property";
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000264 if (PDecl->getPropertyAttributes() != ObjCPropertyDecl::OBJC_PR_noattr) {
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000265 bool first = true;
Ted Kremenekea75c552007-11-28 21:32:21 +0000266 Out << " (";
Chris Lattner4b1daf02008-01-10 01:43:14 +0000267 if (PDecl->getPropertyAttributes() &
268 ObjCPropertyDecl::OBJC_PR_readonly) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000269 Out << (first ? ' ' : ',') << "readonly";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000270 first = false;
271 }
272
Chris Lattner4b1daf02008-01-10 01:43:14 +0000273 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000274 Out << (first ? ' ' : ',') << "getter = "
275 << PDecl->getGetterName()->getName();
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000276 first = false;
277 }
Chris Lattner4b1daf02008-01-10 01:43:14 +0000278 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000279 Out << (first ? ' ' : ',') << "setter = "
280 << PDecl->getSetterName()->getName();
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000281 first = false;
282 }
283
Chris Lattner4b1daf02008-01-10 01:43:14 +0000284 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_assign) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000285 Out << (first ? ' ' : ',') << "assign";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000286 first = false;
287 }
288
Chris Lattner4b1daf02008-01-10 01:43:14 +0000289 if (PDecl->getPropertyAttributes() &
290 ObjCPropertyDecl::OBJC_PR_readwrite) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000291 Out << (first ? ' ' : ',') << "readwrite";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000292 first = false;
293 }
294
Chris Lattner4b1daf02008-01-10 01:43:14 +0000295 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000296 Out << (first ? ' ' : ',') << "retain";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000297 first = false;
298 }
299
Chris Lattner4b1daf02008-01-10 01:43:14 +0000300 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000301 Out << (first ? ' ' : ',') << "copy";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000302 first = false;
303 }
304
Chris Lattner4b1daf02008-01-10 01:43:14 +0000305 if (PDecl->getPropertyAttributes() &
306 ObjCPropertyDecl::OBJC_PR_nonatomic) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000307 Out << (first ? ' ' : ',') << "nonatomic";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000308 first = false;
309 }
Ted Kremenekea75c552007-11-28 21:32:21 +0000310 Out << " )";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000311 }
Ted Kremenekea75c552007-11-28 21:32:21 +0000312
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000313 ObjCIvarDecl **IDecl = PDecl->getPropertyDecls();
Ted Kremenekea75c552007-11-28 21:32:21 +0000314
315 Out << ' ' << IDecl[0]->getType().getAsString()
316 << ' ' << IDecl[0]->getName();
317
318 for (int j = 1; j < PDecl->getNumPropertyDecls(); j++)
319 Out << ", " << IDecl[j]->getName();
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000320
Ted Kremenekea75c552007-11-28 21:32:21 +0000321 Out << ";\n";
Fariborz Jahanian82a5fe32007-11-06 22:01:00 +0000322 }
323 }
Ted Kremenekea75c552007-11-28 21:32:21 +0000324
325 Out << "@end\n";
Steve Naroff2bd42fa2007-09-10 20:51:04 +0000326 // FIXME: implement the rest...
327}
328
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000329void DeclPrinter::PrintObjCProtocolDecl(ObjCProtocolDecl *PID) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000330 Out << "@protocol " << PID->getName() << '\n';
Fariborz Jahanianab0aeb02007-10-08 18:53:38 +0000331 // FIXME: implement the rest...
332}
333
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000334void DeclPrinter::PrintObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000335 Out << "@implementation "
336 << PID->getClassInterface()->getName()
337 << '(' << PID->getName() << ");\n";
338
Fariborz Jahanianab0aeb02007-10-08 18:53:38 +0000339 // FIXME: implement the rest...
340}
341
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000342void DeclPrinter::PrintObjCCategoryDecl(ObjCCategoryDecl *PID) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000343 Out << "@interface "
344 << PID->getClassInterface()->getName()
345 << '(' << PID->getName() << ");\n";
Fariborz Jahanianab0aeb02007-10-08 18:53:38 +0000346 // FIXME: implement the rest...
347}
348
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000349void DeclPrinter::PrintObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *AID) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000350 Out << "@compatibility_alias " << AID->getName()
351 << ' ' << AID->getClassInterface()->getName() << ";\n";
Fariborz Jahanian243b64b2007-10-11 23:42:27 +0000352}
353
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000354//===----------------------------------------------------------------------===//
355/// ASTPrinter - Pretty-printer of ASTs
356
Chris Lattner3d4997d2007-09-15 23:02:28 +0000357namespace {
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000358 class ASTPrinter : public ASTConsumer, public DeclPrinter {
359 public:
Ted Kremenekea75c552007-11-28 21:32:21 +0000360 ASTPrinter(std::ostream* o = NULL) : DeclPrinter(o) {}
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000361
Chris Lattner3d4997d2007-09-15 23:02:28 +0000362 virtual void HandleTopLevelDecl(Decl *D) {
Chris Lattneref5a85d2008-01-02 21:04:16 +0000363 PrintDecl(D);
Reid Spencer5f016e22007-07-11 17:01:13 +0000364 }
Chris Lattner3d4997d2007-09-15 23:02:28 +0000365 };
Reid Spencer5f016e22007-07-11 17:01:13 +0000366}
Chris Lattner6000dac2007-08-08 22:51:59 +0000367
Ted Kremenekea75c552007-11-28 21:32:21 +0000368ASTConsumer *clang::CreateASTPrinter(std::ostream* out) {
369 return new ASTPrinter(out);
370}
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000371
372//===----------------------------------------------------------------------===//
373/// ASTDumper - Low-level dumper of ASTs
Chris Lattner3d4997d2007-09-15 23:02:28 +0000374
375namespace {
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000376 class ASTDumper : public ASTConsumer, public DeclPrinter {
Chris Lattner3d4997d2007-09-15 23:02:28 +0000377 SourceManager *SM;
378 public:
Ted Kremenekea75c552007-11-28 21:32:21 +0000379 ASTDumper() : DeclPrinter() {}
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000380
Ted Kremenek95041a22007-12-19 22:51:13 +0000381 void Initialize(ASTContext &Context) {
Ted Kremenek7a9d49f2007-12-11 21:27:55 +0000382 SM = &Context.getSourceManager();
Chris Lattner6000dac2007-08-08 22:51:59 +0000383 }
Chris Lattner3d4997d2007-09-15 23:02:28 +0000384
385 virtual void HandleTopLevelDecl(Decl *D) {
386 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
387 PrintFunctionDeclStart(FD);
388
389 if (FD->getBody()) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000390 Out << '\n';
391 // FIXME: convert dumper to use std::ostream?
Chris Lattner3d4997d2007-09-15 23:02:28 +0000392 FD->getBody()->dumpAll(*SM);
Ted Kremenekea75c552007-11-28 21:32:21 +0000393 Out << '\n';
Chris Lattner3d4997d2007-09-15 23:02:28 +0000394 }
395 } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
396 PrintTypeDefDecl(TD);
397 } else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000398 Out << "Read top-level variable decl: '" << SD->getName() << "'\n";
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000399 } else if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000400 Out << "Read objc interface '" << OID->getName() << "'\n";
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000401 } else if (ObjCProtocolDecl *OPD = dyn_cast<ObjCProtocolDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000402 Out << "Read objc protocol '" << OPD->getName() << "'\n";
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000403 } else if (ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000404 Out << "Read objc category '" << OCD->getName() << "'\n";
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000405 } else if (isa<ObjCForwardProtocolDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000406 Out << "Read objc fwd protocol decl\n";
Ted Kremeneka526c5c2008-01-07 19:49:32 +0000407 } else if (isa<ObjCClassDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000408 Out << "Read objc fwd class decl\n";
Anders Carlssondfab6cb2008-02-08 00:33:21 +0000409 } else if (isa<FileScopeAsmDecl>(D)) {
410 Out << "Read file scope asm decl\n";
Chris Lattner9fa5e652007-10-06 18:52:10 +0000411 } else {
412 assert(0 && "Unknown decl type!");
Chris Lattner3d4997d2007-09-15 23:02:28 +0000413 }
414 }
415 };
Chris Lattner6000dac2007-08-08 22:51:59 +0000416}
417
Chris Lattner3d4997d2007-09-15 23:02:28 +0000418ASTConsumer *clang::CreateASTDumper() { return new ASTDumper(); }
419
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +0000420//===----------------------------------------------------------------------===//
421/// ASTViewer - AST Visualization
422
Ted Kremenek80de08f2007-09-19 21:29:43 +0000423namespace {
424 class ASTViewer : public ASTConsumer {
425 SourceManager *SM;
426 public:
Ted Kremenek95041a22007-12-19 22:51:13 +0000427 void Initialize(ASTContext &Context) {
Ted Kremenek7a9d49f2007-12-11 21:27:55 +0000428 SM = &Context.getSourceManager();
Ted Kremenek80de08f2007-09-19 21:29:43 +0000429 }
430
431 virtual void HandleTopLevelDecl(Decl *D) {
432 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000433 DeclPrinter().PrintFunctionDeclStart(FD);
Ted Kremenek80de08f2007-09-19 21:29:43 +0000434
435 if (FD->getBody()) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000436 llvm::cerr << '\n';
Ted Kremenek80de08f2007-09-19 21:29:43 +0000437 FD->getBody()->viewAST();
Ted Kremenekea75c552007-11-28 21:32:21 +0000438 llvm::cerr << '\n';
Ted Kremenek80de08f2007-09-19 21:29:43 +0000439 }
440 }
441 }
442 };
443}
444
445ASTConsumer *clang::CreateASTViewer() { return new ASTViewer(); }
446
447
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000448//===----------------------------------------------------------------------===//
449// CFGVisitor & VisitCFGs - Boilerplate interface and logic to visit
450// the CFGs for all function definitions.
451
452namespace {
453
Chris Lattnerc0508f92007-09-15 23:21:08 +0000454class CFGVisitor : public ASTConsumer {
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000455public:
Chris Lattnerc0508f92007-09-15 23:21:08 +0000456 // CFG Visitor interface to be implemented by subclass.
Ted Kremenekbffaa832008-01-29 05:13:23 +0000457 virtual void VisitCFG(CFG& C, FunctionDecl& FD) = 0;
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000458 virtual bool printFuncDeclStart() { return true; }
Chris Lattnerc0508f92007-09-15 23:21:08 +0000459
460 virtual void HandleTopLevelDecl(Decl *D);
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000461};
462
463} // end anonymous namespace
464
Chris Lattnerc0508f92007-09-15 23:21:08 +0000465void CFGVisitor::HandleTopLevelDecl(Decl *D) {
466 FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
467 if (!FD || !FD->getBody())
468 return;
469
470 if (printFuncDeclStart()) {
Ted Kremenekea75c552007-11-28 21:32:21 +0000471 DeclPrinter().PrintFunctionDeclStart(FD);
472 llvm::cerr << '\n';
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000473 }
Chris Lattnerc0508f92007-09-15 23:21:08 +0000474
Ted Kremenek12259662007-09-17 17:10:02 +0000475 CFG *C = CFG::buildCFG(FD->getBody());
Ted Kremenekbffaa832008-01-29 05:13:23 +0000476 VisitCFG(*C, *FD);
Ted Kremenek12259662007-09-17 17:10:02 +0000477 delete C;
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000478}
479
480//===----------------------------------------------------------------------===//
481// DumpCFGs - Dump CFGs to stderr or visualize with Graphviz
482
483namespace {
484 class CFGDumper : public CFGVisitor {
485 const bool UseGraphviz;
486 public:
487 CFGDumper(bool use_graphviz) : UseGraphviz(use_graphviz) {}
488
Ted Kremenekbffaa832008-01-29 05:13:23 +0000489 virtual void VisitCFG(CFG& C, FunctionDecl&) {
Chris Lattnerc0508f92007-09-15 23:21:08 +0000490 if (UseGraphviz)
491 C.viewCFG();
492 else
493 C.dump();
494 }
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000495 };
496} // end anonymous namespace
497
Chris Lattnerc0508f92007-09-15 23:21:08 +0000498ASTConsumer *clang::CreateCFGDumper(bool ViewGraphs) {
499 return new CFGDumper(ViewGraphs);
Ted Kremenekfddd5182007-08-21 21:42:03 +0000500}
501
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000502//===----------------------------------------------------------------------===//
503// AnalyzeLiveVariables - perform live variable analysis and dump results
504
505namespace {
506 class LivenessVisitor : public CFGVisitor {
Chris Lattnerc0508f92007-09-15 23:21:08 +0000507 SourceManager *SM;
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000508 public:
Ted Kremenek95041a22007-12-19 22:51:13 +0000509 virtual void Initialize(ASTContext &Context) {
Ted Kremenek7a9d49f2007-12-11 21:27:55 +0000510 SM = &Context.getSourceManager();
Chris Lattnerc0508f92007-09-15 23:21:08 +0000511 }
512
Ted Kremenekbffaa832008-01-29 05:13:23 +0000513 virtual void VisitCFG(CFG& C, FunctionDecl& FD) {
514 LiveVariables L(C, FD);
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000515 L.runOnCFG(C);
Ted Kremenekfdd225e2007-09-25 04:31:27 +0000516 L.dumpBlockLiveness(*SM);
Ted Kremeneke4e63342007-09-06 00:17:54 +0000517 }
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000518 };
519} // end anonymous namespace
520
Chris Lattnerc0508f92007-09-15 23:21:08 +0000521ASTConsumer *clang::CreateLiveVarAnalyzer() {
522 return new LivenessVisitor();
Ted Kremeneke4e63342007-09-06 00:17:54 +0000523}
524
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000525//===----------------------------------------------------------------------===//
Ted Kremenek2bf55142007-09-17 20:49:30 +0000526// DeadStores - run checker to locate dead stores in a function
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000527
528namespace {
529 class DeadStoreVisitor : public CFGVisitor {
Chris Lattnerc0508f92007-09-15 23:21:08 +0000530 Diagnostic &Diags;
531 ASTContext *Ctx;
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000532 public:
Chris Lattnerc0508f92007-09-15 23:21:08 +0000533 DeadStoreVisitor(Diagnostic &diags) : Diags(diags) {}
Ted Kremenek95041a22007-12-19 22:51:13 +0000534 virtual void Initialize(ASTContext &Context) {
Chris Lattnerc0508f92007-09-15 23:21:08 +0000535 Ctx = &Context;
536 }
537
Ted Kremenekbffaa832008-01-29 05:13:23 +0000538 virtual void VisitCFG(CFG& C, FunctionDecl& FD) {
539 CheckDeadStores(C, FD, *Ctx, Diags);
540 }
541
Ted Kremenek567a7e62007-09-07 23:54:15 +0000542 virtual bool printFuncDeclStart() { return false; }
Ted Kremenek74bf2c92007-09-07 23:47:56 +0000543 };
544} // end anonymous namespace
545
Chris Lattnerc0508f92007-09-15 23:21:08 +0000546ASTConsumer *clang::CreateDeadStoreChecker(Diagnostic &Diags) {
547 return new DeadStoreVisitor(Diags);
Ted Kremenek055c2752007-09-06 23:00:42 +0000548}
Chris Lattner580980b2007-09-16 19:46:59 +0000549
550//===----------------------------------------------------------------------===//
Ted Kremenek2bf55142007-09-17 20:49:30 +0000551// Unitialized Values - run checker to flag potential uses of uninitalized
552// variables.
553
554namespace {
555 class UninitValsVisitor : public CFGVisitor {
556 Diagnostic &Diags;
557 ASTContext *Ctx;
558 public:
559 UninitValsVisitor(Diagnostic &diags) : Diags(diags) {}
Ted Kremenek95041a22007-12-19 22:51:13 +0000560 virtual void Initialize(ASTContext &Context) {
Ted Kremenek2bf55142007-09-17 20:49:30 +0000561 Ctx = &Context;
562 }
563
Ted Kremenekbffaa832008-01-29 05:13:23 +0000564 virtual void VisitCFG(CFG& C, FunctionDecl&) {
565 CheckUninitializedValues(C, *Ctx, Diags);
566 }
567
Ted Kremenek2bf55142007-09-17 20:49:30 +0000568 virtual bool printFuncDeclStart() { return false; }
569 };
570} // end anonymous namespace
571
572ASTConsumer *clang::CreateUnitValsChecker(Diagnostic &Diags) {
573 return new UninitValsVisitor(Diags);
574}
575
576//===----------------------------------------------------------------------===//
Ted Kremeneke01c9872008-02-14 22:36:46 +0000577// GRSimpleVals - Perform intra-procedural, path-sensitive constant propagation.
Ted Kremeneke603df42008-01-08 18:04:06 +0000578
579namespace {
Ted Kremeneke01c9872008-02-14 22:36:46 +0000580 class GRSimpleValsVisitor : public CFGVisitor {
Ted Kremenek19227e32008-02-07 06:33:19 +0000581 Diagnostic &Diags;
Ted Kremenek874d63f2008-01-24 02:02:54 +0000582 ASTContext* Ctx;
Ted Kremeneke603df42008-01-08 18:04:06 +0000583 public:
Ted Kremeneke01c9872008-02-14 22:36:46 +0000584 GRSimpleValsVisitor(Diagnostic &diags) : Diags(diags) {}
Ted Kremeneke603df42008-01-08 18:04:06 +0000585
Ted Kremenekcb48b9c2008-01-29 00:33:40 +0000586 virtual void Initialize(ASTContext &Context) { Ctx = &Context; }
Ted Kremenekbffaa832008-01-29 05:13:23 +0000587 virtual void VisitCFG(CFG& C, FunctionDecl&);
Ted Kremeneke603df42008-01-08 18:04:06 +0000588 };
589} // end anonymous namespace
590
Ted Kremeneke01c9872008-02-14 22:36:46 +0000591ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags) {
592 return new GRSimpleValsVisitor(Diags);
Ted Kremeneke603df42008-01-08 18:04:06 +0000593}
594
Ted Kremeneke01c9872008-02-14 22:36:46 +0000595void GRSimpleValsVisitor::VisitCFG(CFG& C, FunctionDecl& FD) {
596 RunGRSimpleVals(C, FD, *Ctx, Diags);
Ted Kremenekcb48b9c2008-01-29 00:33:40 +0000597}
598
Ted Kremeneke603df42008-01-08 18:04:06 +0000599//===----------------------------------------------------------------------===//
Ted Kremeneka1fa3a12007-12-13 00:37:31 +0000600// AST Serializer
601
602namespace {
Ted Kremenekf06c9282007-12-19 23:49:37 +0000603
604class ASTSerializer : public ASTConsumer {
605protected:
606 Diagnostic &Diags;
607 TranslationUnit TU;
608public:
609 ASTSerializer(Diagnostic& diags, const LangOptions& LO)
610 : Diags(diags), TU(LO) {}
611
612 virtual void Initialize(ASTContext &Context) {
613 TU.setContext(&Context);
614 }
615
616 virtual void HandleTopLevelDecl(Decl *D) {
617 if (Diags.hasErrorOccurred())
618 return;
619
620 TU.AddTopLevelDecl(D);
621 }
622};
623
624class SingleFileSerializer : public ASTSerializer {
625 const llvm::sys::Path FName;
626public:
627 SingleFileSerializer(const llvm::sys::Path& F, Diagnostic &diags,
628 const LangOptions &LO)
629 : ASTSerializer(diags,LO), FName(F) {}
630
631 ~SingleFileSerializer() {
632 EmitASTBitcodeFile(TU,FName);
633 }
634};
635
636class BuildSerializer : public ASTSerializer {
637 llvm::sys::Path EmitDir;
638public:
639 BuildSerializer(const llvm::sys::Path& dir, Diagnostic &diags,
Ted Kremeneka1fa3a12007-12-13 00:37:31 +0000640 const LangOptions &LO)
Ted Kremenekf06c9282007-12-19 23:49:37 +0000641 : ASTSerializer(diags,LO), EmitDir(dir) {}
642
Ted Kremenek54117722007-12-20 00:34:58 +0000643 ~BuildSerializer() {
644 SourceManager& SourceMgr = TU.getASTContext()->getSourceManager();
645 unsigned ID = SourceMgr.getMainFileID();
646 assert (ID && "MainFileID not set!");
647 const FileEntry* FE = SourceMgr.getFileEntryForID(ID);
648 assert (FE && "No FileEntry for main file.");
649
650 // FIXME: This is not portable to Windows.
651 // FIXME: This logic should probably be moved elsewhere later.
652
Ted Kremenekee533642007-12-20 19:47:16 +0000653 llvm::sys::Path FName(EmitDir);
Ted Kremenek54117722007-12-20 00:34:58 +0000654
655 std::vector<char> buf;
656 buf.reserve(strlen(FE->getName())+100);
657
658 sprintf(&buf[0], "dev_%llx", (uint64_t) FE->getDevice());
Ted Kremenekee533642007-12-20 19:47:16 +0000659 FName.appendComponent(&buf[0]);
660 FName.createDirectoryOnDisk(true);
661 if (!FName.canWrite() || !FName.isDirectory()) {
Ted Kremenek54117722007-12-20 00:34:58 +0000662 assert (false && "Could not create 'device' serialization directory.");
663 return;
664 }
Ted Kremenekee533642007-12-20 19:47:16 +0000665
Ted Kremenek54117722007-12-20 00:34:58 +0000666 sprintf(&buf[0], "%s-%llX.ast", FE->getName(), (uint64_t) FE->getInode());
Ted Kremenekee533642007-12-20 19:47:16 +0000667 FName.appendComponent(&buf[0]);
668 EmitASTBitcodeFile(TU,FName);
Ted Kremenek54117722007-12-20 00:34:58 +0000669
Ted Kremenekee533642007-12-20 19:47:16 +0000670 // Now emit the sources.
671
Ted Kremenek54117722007-12-20 00:34:58 +0000672 }
Ted Kremenekf06c9282007-12-19 23:49:37 +0000673};
674
675
Ted Kremeneka1fa3a12007-12-13 00:37:31 +0000676} // end anonymous namespace
677
678
Ted Kremenekfdfc1982007-12-19 22:24:34 +0000679ASTConsumer* clang::CreateASTSerializer(const std::string& InFile,
Ted Kremenekf06c9282007-12-19 23:49:37 +0000680 const std::string& OutputFile,
Ted Kremeneka1fa3a12007-12-13 00:37:31 +0000681 Diagnostic &Diags,
682 const LangOptions &Features) {
Ted Kremenek3910c7c2007-12-19 17:25:59 +0000683
Ted Kremenekf06c9282007-12-19 23:49:37 +0000684 if (OutputFile.size()) {
Ted Kremenek54117722007-12-20 00:34:58 +0000685 if (InFile == "-") {
686 llvm::cerr <<
687 "error: Cannot use --serialize with -o for source read from STDIN.\n";
688 return NULL;
689 }
690
Ted Kremenekf06c9282007-12-19 23:49:37 +0000691 // The user specified an AST-emission directory. Determine if the path
692 // is absolute.
693 llvm::sys::Path EmitDir(OutputFile);
694
695 if (!EmitDir.isAbsolute()) {
696 llvm::cerr <<
697 "error: Output directory for --serialize must be an absolute path.\n";
698
699 return NULL;
700 }
701
702 // Create the directory if it does not exist.
703 EmitDir.createDirectoryOnDisk(true);
704 if (!EmitDir.canWrite() || !EmitDir.isDirectory()) {
705 llvm::cerr <<
706 "error: Could not create output directory for --serialize.\n";
707
708 return NULL;
709 }
710
Ted Kremenek54117722007-12-20 00:34:58 +0000711 // FIXME: We should probably only allow using BuildSerializer when
712 // the ASTs come from parsed source files, and not from .ast files.
Ted Kremenekf06c9282007-12-19 23:49:37 +0000713 return new BuildSerializer(EmitDir, Diags, Features);
714 }
715
716 // The user did not specify an output directory for serialized ASTs.
717 // Serialize the translation to a single file whose name is the same
718 // as the input file with the ".ast" extension appended.
Ted Kremenek63ea8632007-12-19 19:27:38 +0000719
Ted Kremenekf06c9282007-12-19 23:49:37 +0000720 llvm::sys::Path FName(InFile.c_str());
Ted Kremenek54117722007-12-20 00:34:58 +0000721 FName.appendSuffix("ast");
Ted Kremenekf06c9282007-12-19 23:49:37 +0000722 return new SingleFileSerializer(FName, Diags, Features);
Ted Kremeneka1fa3a12007-12-13 00:37:31 +0000723}