blob: b8957e520cf119658e1cd5f6783b20fbf5e30318 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- PrintParserActions.cpp - Implement -parse-print-callbacks mode ---===//
2//
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//
10// This code simply runs the preprocessor on the input file and prints out the
11// result. This is the traditional behavior of the -E option.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000016#include "clang/Parse/Action.h"
17#include "clang/Parse/DeclSpec.h"
Ted Kremenekbdd30c22008-01-14 16:44:48 +000018#include "llvm/Support/Streams.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000019using namespace clang;
20
21namespace {
22 class ParserPrintActions : public MinimalAction {
23
Steve Naroffb4292f22007-10-31 20:55:39 +000024 public:
Daniel Dunbare10b0f22008-10-31 08:56:51 +000025 ParserPrintActions(Preprocessor &PP) : MinimalAction(PP) {}
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +000026
27 // Printing Functions which also must call MinimalAction
28
Steve Naroff08d92e42007-09-15 18:49:24 +000029 /// ActOnDeclarator - This callback is invoked when a declarator is parsed
Reid Spencer5f016e22007-07-11 17:01:13 +000030 /// and 'Init' specifies the initializer if any. This is for things like:
31 /// "int X = 4" or "typedef int foo".
Steve Naroff08d92e42007-09-15 18:49:24 +000032 virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D,
Daniel Dunbar914701e2008-08-05 16:28:08 +000033 DeclTy *LastInGroup) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +000034 llvm::cout << __FUNCTION__ << " ";
Reid Spencer5f016e22007-07-11 17:01:13 +000035 if (IdentifierInfo *II = D.getIdentifier()) {
Ted Kremenekbdd30c22008-01-14 16:44:48 +000036 llvm::cout << "'" << II->getName() << "'";
Reid Spencer5f016e22007-07-11 17:01:13 +000037 } else {
Ted Kremenekbdd30c22008-01-14 16:44:48 +000038 llvm::cout << "<anon>";
Reid Spencer5f016e22007-07-11 17:01:13 +000039 }
Ted Kremenekbdd30c22008-01-14 16:44:48 +000040 llvm::cout << "\n";
Reid Spencer5f016e22007-07-11 17:01:13 +000041
42 // Pass up to EmptyActions so that the symbol table is maintained right.
Daniel Dunbar914701e2008-08-05 16:28:08 +000043 return MinimalAction::ActOnDeclarator(S, D, LastInGroup);
Reid Spencer5f016e22007-07-11 17:01:13 +000044 }
Steve Naroff640db422007-10-10 17:45:44 +000045 /// ActOnPopScope - This callback is called immediately before the specified
46 /// scope is popped and deleted.
47 virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +000048 llvm::cout << __FUNCTION__ << "\n";
49 return MinimalAction::ActOnPopScope(Loc, S);
50 }
51
52 /// ActOnTranslationUnitScope - This callback is called once, immediately
53 /// after creating the translation unit scope (in Parser::Initialize).
54 virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
55 llvm::cout << __FUNCTION__ << "\n";
56 MinimalAction::ActOnTranslationUnitScope(Loc, S);
57 }
58
59
60 Action::DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
61 IdentifierInfo *ClassName,
62 SourceLocation ClassLoc,
63 IdentifierInfo *SuperName,
64 SourceLocation SuperLoc,
65 DeclTy * const *ProtoRefs,
66 unsigned NumProtocols,
67 SourceLocation EndProtoLoc,
68 AttributeList *AttrList) {
69 llvm::cout << __FUNCTION__ << "\n";
70 return MinimalAction::ActOnStartClassInterface(AtInterfaceLoc,
71 ClassName, ClassLoc,
72 SuperName, SuperLoc,
73 ProtoRefs, NumProtocols,
74 EndProtoLoc, AttrList);
75 }
76
77 /// ActOnForwardClassDeclaration -
78 /// Scope will always be top level file scope.
79 Action::DeclTy *ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
80 IdentifierInfo **IdentList,
81 unsigned NumElts) {
82 llvm::cout << __FUNCTION__ << "\n";
83 return MinimalAction::ActOnForwardClassDeclaration(AtClassLoc, IdentList,
84 NumElts);
85 }
86
87 // Pure Printing
88
89 /// ActOnParamDeclarator - This callback is invoked when a parameter
90 /// declarator is parsed. This callback only occurs for functions
91 /// with prototypes. S is the function prototype scope for the
92 /// parameters (C++ [basic.scope.proto]).
93 virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D) {
94 llvm::cout << __FUNCTION__ << " ";
95 if (IdentifierInfo *II = D.getIdentifier()) {
96 llvm::cout << "'" << II->getName() << "'";
97 } else {
98 llvm::cout << "<anon>";
99 }
100 llvm::cout << "\n";
101 return 0;
102 }
103
104 /// AddInitializerToDecl - This action is called immediately after
105 /// ParseDeclarator (when an initializer is present). The code is factored
106 /// this way to make sure we are able to handle the following:
107 /// void func() { int xx = xx; }
108 /// This allows ActOnDeclarator to register "xx" prior to parsing the
109 /// initializer. The declaration above should still result in a warning,
110 /// since the reference to "xx" is uninitialized.
Sebastian Redl798d1192008-12-13 16:23:55 +0000111 virtual void AddInitializerToDecl(DeclTy *Dcl, ExprArg Init) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000112 llvm::cout << __FUNCTION__ << "\n";
113 }
114
115 /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this
116 /// gives the actions implementation a chance to process the group as a whole.
117 virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group) {
118 llvm::cout << __FUNCTION__ << "\n";
119 return 0;
120 }
121
122 /// ActOnStartOfFunctionDef - This is called at the start of a function
123 /// definition, instead of calling ActOnDeclarator. The Declarator includes
124 /// information about formal arguments that are part of this function.
125 virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
126 llvm::cout << __FUNCTION__ << "\n";
127 return 0;
128 }
129
130 /// ActOnStartOfFunctionDef - This is called at the start of a function
131 /// definition, after the FunctionDecl has already been created.
132 virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
133 llvm::cout << __FUNCTION__ << "\n";
134 return 0;
135 }
136
137 virtual void ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
138 llvm::cout << __FUNCTION__ << "\n";
139 }
140
141 /// ActOnFunctionDefBody - This is called when a function body has completed
142 /// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef.
Sebastian Redl798d1192008-12-13 16:23:55 +0000143 virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000144 llvm::cout << __FUNCTION__ << "\n";
145 return 0;
146 }
147
Sebastian Redl798d1192008-12-13 16:23:55 +0000148 virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg AsmString) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000149 llvm::cout << __FUNCTION__ << "\n";
150 return 0;
151 }
152
153 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
154 /// no declarator (e.g. "struct foo;") is parsed.
155 virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
156 llvm::cout << __FUNCTION__ << "\n";
157 return 0;
158 }
Douglas Gregore79837a2008-12-17 01:46:43 +0000159
160 /// ActOnLinkageSpec - Parsed a C++ linkage-specification that
161 /// contained braces. Lang/StrSize contains the language string that
162 /// was parsed at location Loc. Decls/NumDecls provides the
163 /// declarations parsed inside the linkage specification.
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000164 virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
165 SourceLocation RBrace, const char *Lang,
Douglas Gregore79837a2008-12-17 01:46:43 +0000166 unsigned StrSize,
167 DeclTy **Decls, unsigned NumDecls) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000168 llvm::cout << __FUNCTION__ << "\n";
169 return 0;
170 }
Douglas Gregore79837a2008-12-17 01:46:43 +0000171
172 /// ActOnLinkageSpec - Parsed a C++ linkage-specification without
173 /// braces. Lang/StrSize contains the language string that was
174 /// parsed at location Loc. D is the declaration parsed.
175 virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, const char *Lang,
176 unsigned StrSize, DeclTy *D) {
177 return 0;
178 }
179
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000180 //===--------------------------------------------------------------------===//
181 // Type Parsing Callbacks.
182 //===--------------------------------------------------------------------===//
183
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000184 virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000185 llvm::cout << __FUNCTION__ << "\n";
186 return 0;
187 }
188
189 virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK,
Argyrios Kyrtzidiseb83ecd2008-11-08 16:45:02 +0000190 SourceLocation KWLoc, const CXXScopeSpec &SS,
191 IdentifierInfo *Name, SourceLocation NameLoc,
Douglas Gregorddc29e12009-02-06 22:42:48 +0000192 AttributeList *Attr) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000193 // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
194 // is (struct/union/enum/class).
195 llvm::cout << __FUNCTION__ << "\n";
196 return 0;
197 }
198
199 /// Act on @defs() element found when parsing a structure. ClassName is the
200 /// name of the referenced class.
Douglas Gregor44b43212008-12-11 16:49:14 +0000201 virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000202 IdentifierInfo *ClassName,
203 llvm::SmallVectorImpl<DeclTy*> &Decls) {
204 llvm::cout << __FUNCTION__ << "\n";
205 }
206
Douglas Gregor44b43212008-12-11 16:49:14 +0000207 virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD,
208 SourceLocation DeclStart,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000209 Declarator &D, ExprTy *BitfieldWidth) {
210 llvm::cout << __FUNCTION__ << "\n";
211 return 0;
212 }
213
214 virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
215 Declarator &D, ExprTy *BitfieldWidth,
216 tok::ObjCKeywordKind visibility) {
217 llvm::cout << __FUNCTION__ << "\n";
218 return 0;
219 }
220
221 virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl,
222 DeclTy **Fields, unsigned NumFields,
Daniel Dunbar1bfe1c22008-10-03 02:03:53 +0000223 SourceLocation LBrac, SourceLocation RBrac,
224 AttributeList *AttrList) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000225 llvm::cout << __FUNCTION__ << "\n";
226 }
227
228 virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
229 DeclTy *LastEnumConstant,
230 SourceLocation IdLoc, IdentifierInfo *Id,
231 SourceLocation EqualLoc, ExprTy *Val) {
232 llvm::cout << __FUNCTION__ << "\n";
233 return 0;
234 }
235
236 virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
237 DeclTy **Elements, unsigned NumElements) {
238 llvm::cout << __FUNCTION__ << "\n";
239 }
240
241 //===--------------------------------------------------------------------===//
242 // Statement Parsing Callbacks.
243 //===--------------------------------------------------------------------===//
Sebastian Redla60528c2008-12-21 12:04:03 +0000244
245 virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000246 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redla60528c2008-12-21 12:04:03 +0000247 return StmtEmpty();
248 }
249
250 virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L,
251 SourceLocation R,
252 MultiStmtArg Elts,
253 bool isStmtExpr) {
254 llvm::cout << __FUNCTION__ << "\n";
255 return StmtEmpty();
256 }
257 virtual OwningStmtResult ActOnDeclStmt(DeclTy *Decl,
258 SourceLocation StartLoc,
259 SourceLocation EndLoc) {
260 llvm::cout << __FUNCTION__ << "\n";
261 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000262 }
263
Sebastian Redla60528c2008-12-21 12:04:03 +0000264 virtual OwningStmtResult ActOnExprStmt(ExprArg Expr) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000265 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redla60528c2008-12-21 12:04:03 +0000266 return OwningStmtResult(*this, Expr.release());
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000267 }
268
269 /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
270 /// which can specify an RHS value.
Sebastian Redl117054a2008-12-28 16:13:43 +0000271 virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc,
272 ExprArg LHSVal,
273 SourceLocation DotDotDotLoc,
274 ExprArg RHSVal,
275 SourceLocation ColonLoc,
276 StmtArg SubStmt) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000277 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl117054a2008-12-28 16:13:43 +0000278 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000279 }
Sebastian Redl117054a2008-12-28 16:13:43 +0000280 virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
281 SourceLocation ColonLoc,
282 StmtArg SubStmt, Scope *CurScope){
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000283 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl117054a2008-12-28 16:13:43 +0000284 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000285 }
Sebastian Redlde307472009-01-11 00:38:46 +0000286
287 virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
288 IdentifierInfo *II,
289 SourceLocation ColonLoc,
290 StmtArg SubStmt) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000291 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000292 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000293 }
Sebastian Redlde307472009-01-11 00:38:46 +0000294
295 virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
296 StmtArg ThenVal,SourceLocation ElseLoc,
297 StmtArg ElseVal) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000298 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000299 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000300 }
Sebastian Redlde307472009-01-11 00:38:46 +0000301
302 virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000303 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000304 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000305 }
Sebastian Redlde307472009-01-11 00:38:46 +0000306
307 virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
308 StmtArg Switch,
309 StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000310 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000311 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000312 }
313
Sebastian Redlf05b1522009-01-16 23:28:06 +0000314 virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
315 ExprArg Cond, StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000316 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000317 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000318 }
Sebastian Redlf05b1522009-01-16 23:28:06 +0000319 virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
320 SourceLocation WhileLoc, ExprArg Cond){
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000321 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000322 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000323 }
Sebastian Redlf05b1522009-01-16 23:28:06 +0000324 virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
325 SourceLocation LParenLoc,
326 StmtArg First, ExprArg Second,
327 ExprArg Third, SourceLocation RParenLoc,
328 StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000329 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000330 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000331 }
Sebastian Redlf05b1522009-01-16 23:28:06 +0000332 virtual OwningStmtResult ActOnObjCForCollectionStmt(
333 SourceLocation ForColLoc,
334 SourceLocation LParenLoc,
335 StmtArg First, ExprArg Second,
336 SourceLocation RParenLoc, StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000337 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000338 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000339 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000340 virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
341 SourceLocation LabelLoc,
342 IdentifierInfo *LabelII) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000343 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000344 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000345 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000346 virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
347 SourceLocation StarLoc,
348 ExprArg DestExp) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000349 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000350 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000351 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000352 virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
353 Scope *CurScope) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000354 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000355 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000356 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000357 virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
358 Scope *CurScope) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000359 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000360 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000361 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000362 virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
363 ExprArg RetValExp) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000364 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000365 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000366 }
Sebastian Redl3037ed02009-01-18 16:53:17 +0000367 virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
368 bool IsSimple,
369 bool IsVolatile,
370 unsigned NumOutputs,
371 unsigned NumInputs,
372 std::string *Names,
373 MultiExprArg Constraints,
374 MultiExprArg Exprs,
375 ExprArg AsmString,
376 MultiExprArg Clobbers,
377 SourceLocation RParenLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000378 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl3037ed02009-01-18 16:53:17 +0000379 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000380 }
Sebastian Redl3037ed02009-01-18 16:53:17 +0000381
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000382 // Objective-c statements
Sebastian Redl431e90e2009-01-18 17:43:11 +0000383 virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
384 SourceLocation RParen,
385 StmtArg Parm, StmtArg Body,
386 StmtArg CatchList) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000387 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000388 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000389 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000390
391 virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
392 StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000393 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000394 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000395 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000396
397 virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
398 StmtArg Try, StmtArg Catch,
399 StmtArg Finally) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000400 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000401 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000402 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000403
404 virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
405 ExprArg Throw) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000406 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000407 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000408 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000409
410 virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
411 ExprArg SynchExpr,
412 StmtArg SynchBody) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000413 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000414 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000415 }
Sebastian Redla0fd8652008-12-21 16:41:36 +0000416
417 // C++ Statements
418 virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D) {
419 llvm::cout << __FUNCTION__ << "\n";
420 return 0;
421 }
422
423 virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
424 DeclTy *ExceptionDecl,
425 StmtArg HandlerBlock) {
426 llvm::cout << __FUNCTION__ << "\n";
427 return StmtEmpty();
428 }
429
430 virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
431 StmtArg TryBlock,
432 MultiStmtArg Handlers) {
433 llvm::cout << __FUNCTION__ << "\n";
434 return StmtEmpty();
435 }
436
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000437 //===--------------------------------------------------------------------===//
438 // Expression Parsing Callbacks.
439 //===--------------------------------------------------------------------===//
Sebastian Redlcd965b92009-01-18 18:53:16 +0000440
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000441 // Primary Expressions.
Sebastian Redlcd965b92009-01-18 18:53:16 +0000442
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000443 /// ActOnIdentifierExpr - Parse an identifier in expression context.
444 /// 'HasTrailingLParen' indicates whether or not the identifier has a '('
445 /// token immediately after it.
Sebastian Redlcd965b92009-01-18 18:53:16 +0000446 virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
447 IdentifierInfo &II,
448 bool HasTrailingLParen,
Sebastian Redlebc07d52009-02-03 20:19:35 +0000449 const CXXScopeSpec *SS,
450 bool isAddressOfOperand) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000451 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000452 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000453 }
454
Sebastian Redlcd965b92009-01-18 18:53:16 +0000455 virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr(
456 Scope *S, SourceLocation OperatorLoc,
457 OverloadedOperatorKind Op,
Sebastian Redlebc07d52009-02-03 20:19:35 +0000458 bool HasTrailingLParen, const CXXScopeSpec &SS,
459 bool isAddressOfOperand) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000460 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000461 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000462 }
463
Sebastian Redlcd965b92009-01-18 18:53:16 +0000464 virtual OwningExprResult ActOnCXXConversionFunctionExpr(
465 Scope *S, SourceLocation OperatorLoc,
466 TypeTy *Type, bool HasTrailingLParen,
Sebastian Redlebc07d52009-02-03 20:19:35 +0000467 const CXXScopeSpec &SS,bool isAddressOfOperand) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000468 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000469 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000470 }
Sebastian Redlcd965b92009-01-18 18:53:16 +0000471
472 virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
473 tok::TokenKind Kind) {
474 llvm::cout << __FUNCTION__ << "\n";
475 return ExprEmpty();
476 }
477
478 virtual OwningExprResult ActOnCharacterConstant(const Token &) {
479 llvm::cout << __FUNCTION__ << "\n";
480 return ExprEmpty();
481 }
482
483 virtual OwningExprResult ActOnNumericConstant(const Token &) {
484 llvm::cout << __FUNCTION__ << "\n";
485 return ExprEmpty();
486 }
487
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000488 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
489 /// fragments (e.g. "foo" "bar" L"baz").
Sebastian Redlcd965b92009-01-18 18:53:16 +0000490 virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
491 unsigned NumToks) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000492 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000493 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000494 }
Sebastian Redlcd965b92009-01-18 18:53:16 +0000495
496 virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
497 ExprArg Val) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000498 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl76ad2e82009-02-05 15:02:23 +0000499 return move(Val); // Default impl returns operand.
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000500 }
Sebastian Redlcd965b92009-01-18 18:53:16 +0000501
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000502 // Postfix Expressions.
Sebastian Redl0eb23302009-01-19 00:08:26 +0000503 virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
504 tok::TokenKind Kind,
505 ExprArg Input) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000506 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000507 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000508 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000509 virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
510 SourceLocation LLoc,
511 ExprArg Idx,
512 SourceLocation RLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000513 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000514 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000515 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000516 virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base,
517 SourceLocation OpLoc,
518 tok::TokenKind OpKind,
519 SourceLocation MemberLoc,
520 IdentifierInfo &Member) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000521 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000522 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000523 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000524
525 virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
526 SourceLocation LParenLoc,
527 MultiExprArg Args,
528 SourceLocation *CommaLocs,
529 SourceLocation RParenLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000530 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000531 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000532 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000533
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000534 // Unary Operators. 'Tok' is the token for the operator.
Sebastian Redl0eb23302009-01-19 00:08:26 +0000535 virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
536 tok::TokenKind Op, ExprArg Input) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000537 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000538 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000539 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000540 virtual OwningExprResult
541 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
542 void *TyOrEx, const SourceRange &ArgRange) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000543 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000544 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000545 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000546
547 virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen,
548 TypeTy *Ty,
549 SourceLocation RParen,
550 ExprArg Op) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000551 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000552 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000553 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000554 virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
555 MultiExprArg InitList,
556 InitListDesignations &Designators,
557 SourceLocation RParenLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000558 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000559 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000560 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000561 virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
562 SourceLocation RParenLoc,ExprArg Op){
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000563 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000564 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000565 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000566
567 virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
568 tok::TokenKind Kind,
569 ExprArg LHS, ExprArg RHS) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000570 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000571 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000572 }
573
574 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
575 /// in the case of a the GNU conditional expr extension.
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000576 virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
577 SourceLocation ColonLoc,
578 ExprArg Cond, ExprArg LHS,
579 ExprArg RHS) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000580 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000581 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000582 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000583
584 //===--------------------- GNU Extension Expressions ------------------===//
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000585
586 virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
587 IdentifierInfo *LabelII) { // "&&foo"
588 llvm::cout << __FUNCTION__ << "\n";
589 return 0;
590 }
591
592 virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
593 SourceLocation RPLoc) { // "({..})"
594 llvm::cout << __FUNCTION__ << "\n";
595 return 0;
596 }
597
Douglas Gregor3fc749d2008-12-23 00:26:44 +0000598 virtual ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000599 SourceLocation TypeLoc, TypeTy *Arg1,
600 OffsetOfComponent *CompPtr,
601 unsigned NumComponents,
602 SourceLocation RParenLoc) {
603 llvm::cout << __FUNCTION__ << "\n";
604 return 0;
605 }
606
607 // __builtin_types_compatible_p(type1, type2)
608 virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
609 TypeTy *arg1, TypeTy *arg2,
610 SourceLocation RPLoc) {
611 llvm::cout << __FUNCTION__ << "\n";
612 return 0;
613 }
614 // __builtin_choose_expr(constExpr, expr1, expr2)
615 virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
616 ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
617 SourceLocation RPLoc) {
618 llvm::cout << __FUNCTION__ << "\n";
619 return 0;
620 }
621 // __builtin_overload(...)
622 virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs,
623 SourceLocation *CommaLocs,
624 SourceLocation BuiltinLoc,
625 SourceLocation RPLoc) {
626 llvm::cout << __FUNCTION__ << "\n";
627 return 0;
628 }
629
630
631 // __builtin_va_arg(expr, type)
632 virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
633 ExprTy *expr, TypeTy *type,
634 SourceLocation RPLoc) {
635 llvm::cout << __FUNCTION__ << "\n";
636 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +0000637 }
638 };
639}
640
Daniel Dunbare10b0f22008-10-31 08:56:51 +0000641MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
642 return new ParserPrintActions(PP);
Reid Spencer5f016e22007-07-11 17:01:13 +0000643}