blob: c97e95a51a9f23cb4f4320796cf74ac0b4e43461 [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,
192 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.
271 virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
272 SourceLocation DotDotDotLoc, ExprTy *RHSVal,
273 SourceLocation ColonLoc, StmtTy *SubStmt) {
274 llvm::cout << __FUNCTION__ << "\n";
275 return 0;
276 }
277 virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
278 SourceLocation ColonLoc, StmtTy *SubStmt,
279 Scope *CurScope){
280 llvm::cout << __FUNCTION__ << "\n";
281 return 0;
282 }
283
284 virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
285 SourceLocation ColonLoc, StmtTy *SubStmt) {
286 llvm::cout << __FUNCTION__ << "\n";
287 return 0;
288 }
289
290 virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
291 StmtTy *ThenVal, SourceLocation ElseLoc,
292 StmtTy *ElseVal) {
293 llvm::cout << __FUNCTION__ << "\n";
294 return 0;
295 }
296
297 virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond) {
298 llvm::cout << __FUNCTION__ << "\n";
299 return 0;
300 }
301
302 virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
303 StmtTy *Switch, ExprTy *Body) {
304 llvm::cout << __FUNCTION__ << "\n";
305 return 0;
306 }
307
308 virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
309 StmtTy *Body) {
310 llvm::cout << __FUNCTION__ << "\n";
311 return 0;
312 }
313 virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
314 SourceLocation WhileLoc, ExprTy *Cond) {
315 llvm::cout << __FUNCTION__ << "\n";
316 return 0;
317 }
318 virtual StmtResult ActOnForStmt(SourceLocation ForLoc,
319 SourceLocation LParenLoc,
320 StmtTy *First, ExprTy *Second, ExprTy *Third,
321 SourceLocation RParenLoc, StmtTy *Body) {
322 llvm::cout << __FUNCTION__ << "\n";
323 return 0;
324 }
325 virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
326 SourceLocation LParenLoc,
327 StmtTy *First, ExprTy *Second,
328 SourceLocation RParenLoc, StmtTy *Body) {
329 llvm::cout << __FUNCTION__ << "\n";
330 return 0;
331 }
332 virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
333 SourceLocation LabelLoc,
334 IdentifierInfo *LabelII) {
335 llvm::cout << __FUNCTION__ << "\n";
336 return 0;
337 }
338 virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
339 SourceLocation StarLoc,
340 ExprTy *DestExp) {
341 llvm::cout << __FUNCTION__ << "\n";
342 return 0;
343 }
344 virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
345 Scope *CurScope) {
346 llvm::cout << __FUNCTION__ << "\n";
347 return 0;
348 }
349 virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope) {
350 llvm::cout << __FUNCTION__ << "\n";
351 return 0;
352 }
353 virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
354 ExprTy *RetValExp) {
355 llvm::cout << __FUNCTION__ << "\n";
356 return 0;
357 }
358 virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
359 bool IsSimple,
360 bool IsVolatile,
361 unsigned NumOutputs,
362 unsigned NumInputs,
363 std::string *Names,
364 ExprTy **Constraints,
365 ExprTy **Exprs,
366 ExprTy *AsmString,
367 unsigned NumClobbers,
368 ExprTy **Clobbers,
369 SourceLocation RParenLoc) {
370 llvm::cout << __FUNCTION__ << "\n";
371 return 0;
372 }
373
374 // Objective-c statements
375 virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
376 SourceLocation RParen, StmtTy *Parm,
377 StmtTy *Body, StmtTy *CatchList) {
378 llvm::cout << __FUNCTION__ << "\n";
379 return 0;
380 }
381
382 virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
383 StmtTy *Body) {
384 llvm::cout << __FUNCTION__ << "\n";
385 return 0;
386 }
387
388 virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
389 StmtTy *Try,
390 StmtTy *Catch, StmtTy *Finally) {
391 llvm::cout << __FUNCTION__ << "\n";
392 return 0;
393 }
394
395 virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
396 StmtTy *Throw) {
397 llvm::cout << __FUNCTION__ << "\n";
398 return 0;
399 }
400
401 virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
402 ExprTy *SynchExpr,
403 StmtTy *SynchBody) {
404 llvm::cout << __FUNCTION__ << "\n";
405 return 0;
406 }
Sebastian Redla0fd8652008-12-21 16:41:36 +0000407
408 // C++ Statements
409 virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D) {
410 llvm::cout << __FUNCTION__ << "\n";
411 return 0;
412 }
413
414 virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
415 DeclTy *ExceptionDecl,
416 StmtArg HandlerBlock) {
417 llvm::cout << __FUNCTION__ << "\n";
418 return StmtEmpty();
419 }
420
421 virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
422 StmtArg TryBlock,
423 MultiStmtArg Handlers) {
424 llvm::cout << __FUNCTION__ << "\n";
425 return StmtEmpty();
426 }
427
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000428 //===--------------------------------------------------------------------===//
429 // Expression Parsing Callbacks.
430 //===--------------------------------------------------------------------===//
431
432 // Primary Expressions.
433
434 /// ActOnIdentifierExpr - Parse an identifier in expression context.
435 /// 'HasTrailingLParen' indicates whether or not the identifier has a '('
436 /// token immediately after it.
437 virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
438 IdentifierInfo &II,
Argyrios Kyrtzidiseb83ecd2008-11-08 16:45:02 +0000439 bool HasTrailingLParen,
440 const CXXScopeSpec *SS) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000441 llvm::cout << __FUNCTION__ << "\n";
442 return 0;
443 }
444
Chris Lattnerd9f69102008-08-10 01:53:14 +0000445 virtual ExprResult ActOnPredefinedExpr(SourceLocation Loc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000446 tok::TokenKind Kind) {
447 llvm::cout << __FUNCTION__ << "\n";
448 return 0;
449 }
450
451 virtual ExprResult ActOnCharacterConstant(const Token &) {
452 llvm::cout << __FUNCTION__ << "\n";
453 return 0;
454 }
455
456 virtual ExprResult ActOnNumericConstant(const Token &) {
457 llvm::cout << __FUNCTION__ << "\n";
458 return 0;
459 }
460
461 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
462 /// fragments (e.g. "foo" "bar" L"baz").
463 virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks) {
464 llvm::cout << __FUNCTION__ << "\n";
465 return 0;
466 }
467
468 virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
469 ExprTy *Val) {
470 llvm::cout << __FUNCTION__ << "\n";
471 return Val; // Default impl returns operand.
472 }
473
474 // Postfix Expressions.
Douglas Gregor74253732008-11-19 15:42:04 +0000475 virtual ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000476 tok::TokenKind Kind, ExprTy *Input) {
477 llvm::cout << __FUNCTION__ << "\n";
478 return 0;
479 }
Douglas Gregor337c6b92008-11-19 17:17:41 +0000480 virtual ExprResult ActOnArraySubscriptExpr(Scope *S, ExprTy *Base,
481 SourceLocation LLoc, ExprTy *Idx,
482 SourceLocation RLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000483 llvm::cout << __FUNCTION__ << "\n";
484 return 0;
485 }
Douglas Gregor3fc749d2008-12-23 00:26:44 +0000486 virtual ExprResult ActOnMemberReferenceExpr(Scope *S, ExprTy *Base,
487 SourceLocation OpLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000488 tok::TokenKind OpKind,
489 SourceLocation MemberLoc,
490 IdentifierInfo &Member) {
491 llvm::cout << __FUNCTION__ << "\n";
492 return 0;
493 }
494
495 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
496 /// This provides the location of the left/right parens and a list of comma
497 /// locations. There are guaranteed to be one fewer commas than arguments,
498 /// unless there are zero arguments.
Douglas Gregor5c37de72008-12-06 00:22:45 +0000499 virtual ExprResult ActOnCallExpr(Scope *S, ExprTy *Fn,
500 SourceLocation LParenLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000501 ExprTy **Args, unsigned NumArgs,
502 SourceLocation *CommaLocs,
503 SourceLocation RParenLoc) {
504 llvm::cout << __FUNCTION__ << "\n";
505 return 0;
506 }
507
508 // Unary Operators. 'Tok' is the token for the operator.
Douglas Gregor74253732008-11-19 15:42:04 +0000509 virtual ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
510 tok::TokenKind Op, ExprTy *Input) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000511 llvm::cout << __FUNCTION__ << "\n";
512 return 0;
513 }
514 virtual ExprResult
Sebastian Redl05189992008-11-11 17:56:53 +0000515 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
516 void *TyOrEx, const SourceRange &ArgRange) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000517 llvm::cout << __FUNCTION__ << "\n";
518 return 0;
519 }
520
521 virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty,
522 SourceLocation RParen, ExprTy *Op) {
523 llvm::cout << __FUNCTION__ << "\n";
524 return 0;
525 }
526 virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
527 ExprTy **InitList, unsigned NumInit,
Chris Lattner220ad7c2008-10-26 23:35:51 +0000528 InitListDesignations &Designators,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000529 SourceLocation RParenLoc) {
530 llvm::cout << __FUNCTION__ << "\n";
531 return 0;
532 }
533 virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
534 SourceLocation RParenLoc, ExprTy *Op) {
535 llvm::cout << __FUNCTION__ << "\n";
536 return 0;
537 }
538
Douglas Gregoreaebc752008-11-06 23:29:22 +0000539 virtual ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
540 tok::TokenKind Kind,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000541 ExprTy *LHS, ExprTy *RHS) {
542 llvm::cout << __FUNCTION__ << "\n";
543 return 0;
544 }
545
546 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
547 /// in the case of a the GNU conditional expr extension.
548 virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
549 SourceLocation ColonLoc,
550 ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){
551 llvm::cout << __FUNCTION__ << "\n";
552 return 0;
553 }
554
555 //===---------------------- GNU Extension Expressions -------------------===//
556
557 virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
558 IdentifierInfo *LabelII) { // "&&foo"
559 llvm::cout << __FUNCTION__ << "\n";
560 return 0;
561 }
562
563 virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
564 SourceLocation RPLoc) { // "({..})"
565 llvm::cout << __FUNCTION__ << "\n";
566 return 0;
567 }
568
Douglas Gregor3fc749d2008-12-23 00:26:44 +0000569 virtual ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000570 SourceLocation TypeLoc, TypeTy *Arg1,
571 OffsetOfComponent *CompPtr,
572 unsigned NumComponents,
573 SourceLocation RParenLoc) {
574 llvm::cout << __FUNCTION__ << "\n";
575 return 0;
576 }
577
578 // __builtin_types_compatible_p(type1, type2)
579 virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
580 TypeTy *arg1, TypeTy *arg2,
581 SourceLocation RPLoc) {
582 llvm::cout << __FUNCTION__ << "\n";
583 return 0;
584 }
585 // __builtin_choose_expr(constExpr, expr1, expr2)
586 virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
587 ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
588 SourceLocation RPLoc) {
589 llvm::cout << __FUNCTION__ << "\n";
590 return 0;
591 }
592 // __builtin_overload(...)
593 virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs,
594 SourceLocation *CommaLocs,
595 SourceLocation BuiltinLoc,
596 SourceLocation RPLoc) {
597 llvm::cout << __FUNCTION__ << "\n";
598 return 0;
599 }
600
601
602 // __builtin_va_arg(expr, type)
603 virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
604 ExprTy *expr, TypeTy *type,
605 SourceLocation RPLoc) {
606 llvm::cout << __FUNCTION__ << "\n";
607 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +0000608 }
609 };
610}
611
Daniel Dunbare10b0f22008-10-31 08:56:51 +0000612MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
613 return new ParserPrintActions(PP);
Reid Spencer5f016e22007-07-11 17:01:13 +0000614}