blob: 02203d356d49bd06f5420cda3186ac5ee00f7c20 [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.
111 virtual void AddInitializerToDecl(DeclTy *Dcl, ExprTy *Init) {
112 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.
143 virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body) {
144 llvm::cout << __FUNCTION__ << "\n";
145 return 0;
146 }
147
148 virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *AsmString) {
149 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 }
159
160 virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
161 SourceLocation RBrace, const char *Lang,
162 unsigned StrSize, DeclTy *D) {
163 llvm::cout << __FUNCTION__ << "\n";
164 return 0;
165 }
166
167 //===--------------------------------------------------------------------===//
168 // Type Parsing Callbacks.
169 //===--------------------------------------------------------------------===//
170
Sebastian Redl4c5d3202008-11-21 19:14:01 +0000171 virtual TypeResult ActOnTypeName(Scope *S, Declarator &D, bool CXXNewMode) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000172 llvm::cout << __FUNCTION__ << "\n";
173 return 0;
174 }
175
176 virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK,
Argyrios Kyrtzidiseb83ecd2008-11-08 16:45:02 +0000177 SourceLocation KWLoc, const CXXScopeSpec &SS,
178 IdentifierInfo *Name, SourceLocation NameLoc,
179 AttributeList *Attr) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000180 // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
181 // is (struct/union/enum/class).
182 llvm::cout << __FUNCTION__ << "\n";
183 return 0;
184 }
185
186 /// Act on @defs() element found when parsing a structure. ClassName is the
187 /// name of the referenced class.
188 virtual void ActOnDefs(Scope *S, SourceLocation DeclStart,
189 IdentifierInfo *ClassName,
190 llvm::SmallVectorImpl<DeclTy*> &Decls) {
191 llvm::cout << __FUNCTION__ << "\n";
192 }
193
194 virtual DeclTy *ActOnField(Scope *S, SourceLocation DeclStart,
195 Declarator &D, ExprTy *BitfieldWidth) {
196 llvm::cout << __FUNCTION__ << "\n";
197 return 0;
198 }
199
200 virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
201 Declarator &D, ExprTy *BitfieldWidth,
202 tok::ObjCKeywordKind visibility) {
203 llvm::cout << __FUNCTION__ << "\n";
204 return 0;
205 }
206
207 virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl,
208 DeclTy **Fields, unsigned NumFields,
Daniel Dunbar1bfe1c22008-10-03 02:03:53 +0000209 SourceLocation LBrac, SourceLocation RBrac,
210 AttributeList *AttrList) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000211 llvm::cout << __FUNCTION__ << "\n";
212 }
213
214 virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
215 DeclTy *LastEnumConstant,
216 SourceLocation IdLoc, IdentifierInfo *Id,
217 SourceLocation EqualLoc, ExprTy *Val) {
218 llvm::cout << __FUNCTION__ << "\n";
219 return 0;
220 }
221
222 virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
223 DeclTy **Elements, unsigned NumElements) {
224 llvm::cout << __FUNCTION__ << "\n";
225 }
226
227 //===--------------------------------------------------------------------===//
228 // Statement Parsing Callbacks.
229 //===--------------------------------------------------------------------===//
230
231 virtual StmtResult ActOnNullStmt(SourceLocation SemiLoc) {
232 llvm::cout << __FUNCTION__ << "\n";
233 return 0;
234 }
235
236 virtual StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
237 StmtTy **Elts, unsigned NumElts,
238 bool isStmtExpr) {
239 llvm::cout << __FUNCTION__ << "\n";
240 return 0;
241 }
242 virtual StmtResult ActOnDeclStmt(DeclTy *Decl, SourceLocation StartLoc,
243 SourceLocation EndLoc) {
244 llvm::cout << __FUNCTION__ << "\n";
245 return 0;
246 }
247
248 virtual StmtResult ActOnExprStmt(ExprTy *Expr) {
249 llvm::cout << __FUNCTION__ << "\n";
250 return StmtResult(Expr);
251 }
252
253 /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
254 /// which can specify an RHS value.
255 virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
256 SourceLocation DotDotDotLoc, ExprTy *RHSVal,
257 SourceLocation ColonLoc, StmtTy *SubStmt) {
258 llvm::cout << __FUNCTION__ << "\n";
259 return 0;
260 }
261 virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
262 SourceLocation ColonLoc, StmtTy *SubStmt,
263 Scope *CurScope){
264 llvm::cout << __FUNCTION__ << "\n";
265 return 0;
266 }
267
268 virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
269 SourceLocation ColonLoc, StmtTy *SubStmt) {
270 llvm::cout << __FUNCTION__ << "\n";
271 return 0;
272 }
273
274 virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
275 StmtTy *ThenVal, SourceLocation ElseLoc,
276 StmtTy *ElseVal) {
277 llvm::cout << __FUNCTION__ << "\n";
278 return 0;
279 }
280
281 virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond) {
282 llvm::cout << __FUNCTION__ << "\n";
283 return 0;
284 }
285
286 virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
287 StmtTy *Switch, ExprTy *Body) {
288 llvm::cout << __FUNCTION__ << "\n";
289 return 0;
290 }
291
292 virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
293 StmtTy *Body) {
294 llvm::cout << __FUNCTION__ << "\n";
295 return 0;
296 }
297 virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body,
298 SourceLocation WhileLoc, ExprTy *Cond) {
299 llvm::cout << __FUNCTION__ << "\n";
300 return 0;
301 }
302 virtual StmtResult ActOnForStmt(SourceLocation ForLoc,
303 SourceLocation LParenLoc,
304 StmtTy *First, ExprTy *Second, ExprTy *Third,
305 SourceLocation RParenLoc, StmtTy *Body) {
306 llvm::cout << __FUNCTION__ << "\n";
307 return 0;
308 }
309 virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
310 SourceLocation LParenLoc,
311 StmtTy *First, ExprTy *Second,
312 SourceLocation RParenLoc, StmtTy *Body) {
313 llvm::cout << __FUNCTION__ << "\n";
314 return 0;
315 }
316 virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
317 SourceLocation LabelLoc,
318 IdentifierInfo *LabelII) {
319 llvm::cout << __FUNCTION__ << "\n";
320 return 0;
321 }
322 virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
323 SourceLocation StarLoc,
324 ExprTy *DestExp) {
325 llvm::cout << __FUNCTION__ << "\n";
326 return 0;
327 }
328 virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
329 Scope *CurScope) {
330 llvm::cout << __FUNCTION__ << "\n";
331 return 0;
332 }
333 virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope) {
334 llvm::cout << __FUNCTION__ << "\n";
335 return 0;
336 }
337 virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
338 ExprTy *RetValExp) {
339 llvm::cout << __FUNCTION__ << "\n";
340 return 0;
341 }
342 virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
343 bool IsSimple,
344 bool IsVolatile,
345 unsigned NumOutputs,
346 unsigned NumInputs,
347 std::string *Names,
348 ExprTy **Constraints,
349 ExprTy **Exprs,
350 ExprTy *AsmString,
351 unsigned NumClobbers,
352 ExprTy **Clobbers,
353 SourceLocation RParenLoc) {
354 llvm::cout << __FUNCTION__ << "\n";
355 return 0;
356 }
357
358 // Objective-c statements
359 virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
360 SourceLocation RParen, StmtTy *Parm,
361 StmtTy *Body, StmtTy *CatchList) {
362 llvm::cout << __FUNCTION__ << "\n";
363 return 0;
364 }
365
366 virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
367 StmtTy *Body) {
368 llvm::cout << __FUNCTION__ << "\n";
369 return 0;
370 }
371
372 virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
373 StmtTy *Try,
374 StmtTy *Catch, StmtTy *Finally) {
375 llvm::cout << __FUNCTION__ << "\n";
376 return 0;
377 }
378
379 virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
380 StmtTy *Throw) {
381 llvm::cout << __FUNCTION__ << "\n";
382 return 0;
383 }
384
385 virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
386 ExprTy *SynchExpr,
387 StmtTy *SynchBody) {
388 llvm::cout << __FUNCTION__ << "\n";
389 return 0;
390 }
391
392 //===--------------------------------------------------------------------===//
393 // Expression Parsing Callbacks.
394 //===--------------------------------------------------------------------===//
395
396 // Primary Expressions.
397
398 /// ActOnIdentifierExpr - Parse an identifier in expression context.
399 /// 'HasTrailingLParen' indicates whether or not the identifier has a '('
400 /// token immediately after it.
401 virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
402 IdentifierInfo &II,
Argyrios Kyrtzidiseb83ecd2008-11-08 16:45:02 +0000403 bool HasTrailingLParen,
404 const CXXScopeSpec *SS) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000405 llvm::cout << __FUNCTION__ << "\n";
406 return 0;
407 }
408
Chris Lattnerd9f69102008-08-10 01:53:14 +0000409 virtual ExprResult ActOnPredefinedExpr(SourceLocation Loc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000410 tok::TokenKind Kind) {
411 llvm::cout << __FUNCTION__ << "\n";
412 return 0;
413 }
414
415 virtual ExprResult ActOnCharacterConstant(const Token &) {
416 llvm::cout << __FUNCTION__ << "\n";
417 return 0;
418 }
419
420 virtual ExprResult ActOnNumericConstant(const Token &) {
421 llvm::cout << __FUNCTION__ << "\n";
422 return 0;
423 }
424
425 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
426 /// fragments (e.g. "foo" "bar" L"baz").
427 virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks) {
428 llvm::cout << __FUNCTION__ << "\n";
429 return 0;
430 }
431
432 virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
433 ExprTy *Val) {
434 llvm::cout << __FUNCTION__ << "\n";
435 return Val; // Default impl returns operand.
436 }
437
438 // Postfix Expressions.
Douglas Gregor74253732008-11-19 15:42:04 +0000439 virtual ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000440 tok::TokenKind Kind, ExprTy *Input) {
441 llvm::cout << __FUNCTION__ << "\n";
442 return 0;
443 }
Douglas Gregor337c6b92008-11-19 17:17:41 +0000444 virtual ExprResult ActOnArraySubscriptExpr(Scope *S, ExprTy *Base,
445 SourceLocation LLoc, ExprTy *Idx,
446 SourceLocation RLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000447 llvm::cout << __FUNCTION__ << "\n";
448 return 0;
449 }
450 virtual ExprResult ActOnMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
451 tok::TokenKind OpKind,
452 SourceLocation MemberLoc,
453 IdentifierInfo &Member) {
454 llvm::cout << __FUNCTION__ << "\n";
455 return 0;
456 }
457
458 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
459 /// This provides the location of the left/right parens and a list of comma
460 /// locations. There are guaranteed to be one fewer commas than arguments,
461 /// unless there are zero arguments.
462 virtual ExprResult ActOnCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
463 ExprTy **Args, unsigned NumArgs,
464 SourceLocation *CommaLocs,
465 SourceLocation RParenLoc) {
466 llvm::cout << __FUNCTION__ << "\n";
467 return 0;
468 }
469
470 // Unary Operators. 'Tok' is the token for the operator.
Douglas Gregor74253732008-11-19 15:42:04 +0000471 virtual ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
472 tok::TokenKind Op, ExprTy *Input) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000473 llvm::cout << __FUNCTION__ << "\n";
474 return 0;
475 }
476 virtual ExprResult
Sebastian Redl05189992008-11-11 17:56:53 +0000477 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
478 void *TyOrEx, const SourceRange &ArgRange) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000479 llvm::cout << __FUNCTION__ << "\n";
480 return 0;
481 }
482
483 virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty,
484 SourceLocation RParen, ExprTy *Op) {
485 llvm::cout << __FUNCTION__ << "\n";
486 return 0;
487 }
488 virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
489 ExprTy **InitList, unsigned NumInit,
Chris Lattner220ad7c2008-10-26 23:35:51 +0000490 InitListDesignations &Designators,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000491 SourceLocation RParenLoc) {
492 llvm::cout << __FUNCTION__ << "\n";
493 return 0;
494 }
495 virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
496 SourceLocation RParenLoc, ExprTy *Op) {
497 llvm::cout << __FUNCTION__ << "\n";
498 return 0;
499 }
500
Douglas Gregoreaebc752008-11-06 23:29:22 +0000501 virtual ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
502 tok::TokenKind Kind,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000503 ExprTy *LHS, ExprTy *RHS) {
504 llvm::cout << __FUNCTION__ << "\n";
505 return 0;
506 }
507
508 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
509 /// in the case of a the GNU conditional expr extension.
510 virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
511 SourceLocation ColonLoc,
512 ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){
513 llvm::cout << __FUNCTION__ << "\n";
514 return 0;
515 }
516
517 //===---------------------- GNU Extension Expressions -------------------===//
518
519 virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
520 IdentifierInfo *LabelII) { // "&&foo"
521 llvm::cout << __FUNCTION__ << "\n";
522 return 0;
523 }
524
525 virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
526 SourceLocation RPLoc) { // "({..})"
527 llvm::cout << __FUNCTION__ << "\n";
528 return 0;
529 }
530
531 virtual ExprResult ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc,
532 SourceLocation TypeLoc, TypeTy *Arg1,
533 OffsetOfComponent *CompPtr,
534 unsigned NumComponents,
535 SourceLocation RParenLoc) {
536 llvm::cout << __FUNCTION__ << "\n";
537 return 0;
538 }
539
540 // __builtin_types_compatible_p(type1, type2)
541 virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
542 TypeTy *arg1, TypeTy *arg2,
543 SourceLocation RPLoc) {
544 llvm::cout << __FUNCTION__ << "\n";
545 return 0;
546 }
547 // __builtin_choose_expr(constExpr, expr1, expr2)
548 virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
549 ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
550 SourceLocation RPLoc) {
551 llvm::cout << __FUNCTION__ << "\n";
552 return 0;
553 }
554 // __builtin_overload(...)
555 virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs,
556 SourceLocation *CommaLocs,
557 SourceLocation BuiltinLoc,
558 SourceLocation RPLoc) {
559 llvm::cout << __FUNCTION__ << "\n";
560 return 0;
561 }
562
563
564 // __builtin_va_arg(expr, type)
565 virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
566 ExprTy *expr, TypeTy *type,
567 SourceLocation RPLoc) {
568 llvm::cout << __FUNCTION__ << "\n";
569 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +0000570 }
571 };
572}
573
Daniel Dunbare10b0f22008-10-31 08:56:51 +0000574MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
575 return new ParserPrintActions(PP);
Reid Spencer5f016e22007-07-11 17:01:13 +0000576}