aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PrintParserCallbacks.cpp
blob: f02d5d469c6483c0d32ae58354e68397dd533921 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
//===--- PrintParserActions.cpp - Implement -parse-print-callbacks mode ---===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This code simply runs the preprocessor on the input file and prints out the
// result.  This is the traditional behavior of the -E option.
//
//===----------------------------------------------------------------------===//

#include "clang/Frontend/Utils.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/DeclSpec.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;

namespace {
  class ParserPrintActions : public MinimalAction {
  llvm::raw_ostream& Out;

  public:
    ParserPrintActions(Preprocessor &PP, llvm::raw_ostream& OS)
      : MinimalAction(PP), Out(OS) {}

    // Printing Functions which also must call MinimalAction

    /// ActOnDeclarator - This callback is invoked when a declarator is parsed
    /// and 'Init' specifies the initializer if any.  This is for things like:
    /// "int X = 4" or "typedef int foo".
    virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
      Out << __FUNCTION__ << " ";
      if (IdentifierInfo *II = D.getIdentifier()) {
        Out << "'" << II->getName() << "'";
      } else {
        Out << "<anon>";
      }
      Out << "\n";
      
      // Pass up to EmptyActions so that the symbol table is maintained right.
      return MinimalAction::ActOnDeclarator(S, D);
    }
    /// ActOnPopScope - This callback is called immediately before the specified
    /// scope is popped and deleted.
    virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {
      Out << __FUNCTION__ << "\n";
      return MinimalAction::ActOnPopScope(Loc, S);
    }

    /// ActOnTranslationUnitScope - This callback is called once, immediately
    /// after creating the translation unit scope (in Parser::Initialize).
    virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
      Out << __FUNCTION__ << "\n";
      MinimalAction::ActOnTranslationUnitScope(Loc, S);
    }


    Action::DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
                                               IdentifierInfo *ClassName,
                                               SourceLocation ClassLoc,
                                               IdentifierInfo *SuperName,
                                               SourceLocation SuperLoc,
                                               const DeclPtrTy *ProtoRefs,
                                               unsigned NumProtocols,
                                               SourceLocation EndProtoLoc,
                                               AttributeList *AttrList) {
      Out << __FUNCTION__ << "\n";
      return MinimalAction::ActOnStartClassInterface(AtInterfaceLoc,
                                                     ClassName, ClassLoc, 
                                                     SuperName, SuperLoc,
                                                     ProtoRefs, NumProtocols,
                                                     EndProtoLoc, AttrList);
    }

    /// ActOnForwardClassDeclaration - 
    /// Scope will always be top level file scope. 
    Action::DeclPtrTy ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
                                                   IdentifierInfo **IdentList, 
                                                   unsigned NumElts) {
      Out << __FUNCTION__ << "\n";
      return MinimalAction::ActOnForwardClassDeclaration(AtClassLoc, IdentList,
                                                         NumElts);
    }

    // Pure Printing

    /// ActOnParamDeclarator - This callback is invoked when a parameter
    /// declarator is parsed. This callback only occurs for functions
    /// with prototypes. S is the function prototype scope for the
    /// parameters (C++ [basic.scope.proto]).
    virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) {
      Out << __FUNCTION__ << " ";
      if (IdentifierInfo *II = D.getIdentifier()) {
        Out << "'" << II->getName() << "'";
      } else {
        Out << "<anon>";
      }
      Out << "\n";
      return DeclPtrTy();
    }
    
    /// AddInitializerToDecl - This action is called immediately after 
    /// ParseDeclarator (when an initializer is present). The code is factored 
    /// this way to make sure we are able to handle the following:
    ///   void func() { int xx = xx; }
    /// This allows ActOnDeclarator to register "xx" prior to parsing the
    /// initializer. The declaration above should still result in a warning, 
    /// since the reference to "xx" is uninitialized.
    virtual void AddInitializerToDecl(DeclPtrTy Dcl, FullExprArg Init) {
      Out << __FUNCTION__ << "\n";
    }

    /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed,
    /// this gives the actions implementation a chance to process the group as
    /// a whole.
    virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS,
                                                   DeclPtrTy *Group,
                                                   unsigned NumDecls) {
      Out << __FUNCTION__ << "\n";
      return DeclGroupPtrTy();
    }

    /// ActOnStartOfFunctionDef - This is called at the start of a function
    /// definition, instead of calling ActOnDeclarator.  The Declarator includes
    /// information about formal arguments that are part of this function.
    virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope,
                                              Declarator &D){
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    /// ActOnStartOfFunctionDef - This is called at the start of a function
    /// definition, after the FunctionDecl has already been created.
    virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
      Out << __FUNCTION__ << "\n";
    }
  
    /// ActOnFunctionDefBody - This is called when a function body has completed
    /// parsing.  Decl is the DeclTy returned by ParseStartOfFunctionDef.
    virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc,
                                            ExprArg AsmString) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
  
    /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
    /// no declarator (e.g. "struct foo;") is parsed.
    virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
    
    /// ActOnLinkageSpec - Parsed a C++ linkage-specification that
    /// contained braces. Lang/StrSize contains the language string that
    /// was parsed at location Loc. Decls/NumDecls provides the
    /// declarations parsed inside the linkage specification.
    virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc,
                                       SourceLocation LBrace,
                                       SourceLocation RBrace, const char *Lang,
                                       unsigned StrSize, 
                                       DeclPtrTy *Decls, unsigned NumDecls) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
    
    /// ActOnLinkageSpec - Parsed a C++ linkage-specification without
    /// braces. Lang/StrSize contains the language string that was
    /// parsed at location Loc. D is the declaration parsed.
    virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc, const char *Lang,
                                       unsigned StrSize, DeclPtrTy D) {
      return DeclPtrTy();
    }
    
    //===------------------------------------------------------------------===//
    // Type Parsing Callbacks.
    //===------------------------------------------------------------------===//
  
    virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
      Out << __FUNCTION__ << "\n";
      return TypeResult();
    }
  
    virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagType, TagKind TK,
                               SourceLocation KWLoc, const CXXScopeSpec &SS,
                               IdentifierInfo *Name, SourceLocation NameLoc,
                               AttributeList *Attr, AccessSpecifier AS,
                               bool &Owned) {
      // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
      // is (struct/union/enum/class).
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
  
    /// Act on @defs() element found when parsing a structure.  ClassName is the
    /// name of the referenced class.   
    virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
                           IdentifierInfo *ClassName,
                           llvm::SmallVectorImpl<DeclPtrTy> &Decls) {
      Out << __FUNCTION__ << "\n";
    }

    virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD, 
                                 SourceLocation DeclStart,
                                 Declarator &D, ExprTy *BitfieldWidth) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
  
    virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
                                Declarator &D, ExprTy *BitfieldWidth,
                                tok::ObjCKeywordKind visibility) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
  
    virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl,
                             DeclPtrTy *Fields, unsigned NumFields, 
                             SourceLocation LBrac, SourceLocation RBrac,
                             AttributeList *AttrList) {
      Out << __FUNCTION__ << "\n";
    }
  
    virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
                                        DeclPtrTy LastEnumConstant,
                                        SourceLocation IdLoc,IdentifierInfo *Id,
                                        SourceLocation EqualLoc, ExprTy *Val) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
                               SourceLocation RBraceLoc, DeclPtrTy EnumDecl,
                               DeclPtrTy *Elements, unsigned NumElements) {
      Out << __FUNCTION__ << "\n";
    }

    //===------------------------------------------------------------------===//
    // Statement Parsing Callbacks.
    //===------------------------------------------------------------------===//

    virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L,
                                               SourceLocation R,
                                               MultiStmtArg Elts,
                                               bool isStmtExpr) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
                                           SourceLocation StartLoc,
                                           SourceLocation EndLoc) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
  
    virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) {
      Out << __FUNCTION__ << "\n";
      return OwningStmtResult(*this, Expr->release());
    }
  
    /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
    /// which can specify an RHS value.
    virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc,
                                           ExprArg LHSVal,
                                           SourceLocation DotDotDotLoc,
                                           ExprArg RHSVal,
                                           SourceLocation ColonLoc) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
                                              SourceLocation ColonLoc,
                                              StmtArg SubStmt, Scope *CurScope){
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
                                            IdentifierInfo *II,
                                            SourceLocation ColonLoc,
                                            StmtArg SubStmt) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, 
                                         FullExprArg CondVal, StmtArg ThenVal,
                                         SourceLocation ElseLoc,
                                         StmtArg ElseVal) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
                                                   StmtArg Switch,
                                                   StmtArg Body) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
                                            FullExprArg Cond, StmtArg Body) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
                                         SourceLocation WhileLoc, ExprArg Cond){
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
                                        SourceLocation LParenLoc,
                                        StmtArg First, ExprArg Second,
                                        ExprArg Third, SourceLocation RParenLoc,
                                        StmtArg Body) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnObjCForCollectionStmt(
                                       SourceLocation ForColLoc,
                                       SourceLocation LParenLoc,
                                       StmtArg First, ExprArg Second,
                                       SourceLocation RParenLoc, StmtArg Body) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
                                           SourceLocation LabelLoc,
                                           IdentifierInfo *LabelII) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
                                                   SourceLocation StarLoc,
                                                   ExprArg DestExp) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
                                               Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
                                            Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
                                             FullExprArg RetValExp) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }
    virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
                                          bool IsSimple,
                                          bool IsVolatile,
                                          unsigned NumOutputs,
                                          unsigned NumInputs,
                                          std::string *Names,
                                          MultiExprArg Constraints,
                                          MultiExprArg Exprs,
                                          ExprArg AsmString,
                                          MultiExprArg Clobbers,
                                          SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    // Objective-c statements
    virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
                                                  SourceLocation RParen,
                                                  DeclPtrTy Parm, StmtArg Body,
                                                  StmtArg CatchList) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
                                                    StmtArg Body) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
                                                StmtArg Try, StmtArg Catch,
                                                StmtArg Finally) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
                                                  ExprArg Throw,
                                                  Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
                                                         ExprArg SynchExpr,
                                                         StmtArg SynchBody) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    // C++ Statements
    virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
                                                DeclPtrTy ExceptionDecl,
                                                StmtArg HandlerBlock) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
                                              StmtArg TryBlock,
                                              MultiStmtArg Handlers) {
      Out << __FUNCTION__ << "\n";
      return StmtEmpty();
    }

    //===------------------------------------------------------------------===//
    // Expression Parsing Callbacks.
    //===------------------------------------------------------------------===//

    // Primary Expressions.

    /// ActOnIdentifierExpr - Parse an identifier in expression context.
    /// 'HasTrailingLParen' indicates whether or not the identifier has a '('
    /// token immediately after it.
    virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
                                                 IdentifierInfo &II,
                                                 bool HasTrailingLParen,
                                                 const CXXScopeSpec *SS,
                                                 bool isAddressOfOperand) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr(
                               Scope *S, SourceLocation OperatorLoc,
                               OverloadedOperatorKind Op,
                               bool HasTrailingLParen, const CXXScopeSpec &SS,
                               bool isAddressOfOperand) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXConversionFunctionExpr(
                               Scope *S, SourceLocation OperatorLoc,
                               TypeTy *Type, bool HasTrailingLParen,
                               const CXXScopeSpec &SS,bool isAddressOfOperand) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
                                                 tok::TokenKind Kind) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCharacterConstant(const Token &) { 
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnNumericConstant(const Token &) { 
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    /// ActOnStringLiteral - The specified tokens were lexed as pasted string
    /// fragments (e.g. "foo" "bar" L"baz").
    virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
                                                unsigned NumToks) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
                                            ExprArg Val) {
      Out << __FUNCTION__ << "\n";
      return move(Val);  // Default impl returns operand.
    }

    // Postfix Expressions.
    virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, 
                                                 tok::TokenKind Kind,
                                                 ExprArg Input) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
    virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
                                                     SourceLocation LLoc,
                                                     ExprArg Idx,
                                                     SourceLocation RLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
    virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base,
                                                      SourceLocation OpLoc,
                                                      tok::TokenKind OpKind,
                                                      SourceLocation MemberLoc,
                                                      IdentifierInfo &Member,
                                                      DeclPtrTy ImplDecl) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
                                           SourceLocation LParenLoc,
                                           MultiExprArg Args,
                                           SourceLocation *CommaLocs,
                                           SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    // Unary Operators.  'Tok' is the token for the operator.
    virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
                                          tok::TokenKind Op, ExprArg Input) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
    virtual OwningExprResult
      ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
                             void *TyOrEx, const SourceRange &ArgRange) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen,
                                                  TypeTy *Ty,
                                                  SourceLocation RParen,
                                                  ExprArg Op) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
    virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
                                           MultiExprArg InitList,
                                           SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
    virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
                                           SourceLocation RParenLoc,ExprArg Op){
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
                                        tok::TokenKind Kind,
                                        ExprArg LHS, ExprArg RHS) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
    /// in the case of a the GNU conditional expr extension.
    virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
                                                SourceLocation ColonLoc,
                                                ExprArg Cond, ExprArg LHS,
                                                ExprArg RHS) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    //===--------------------- GNU Extension Expressions ------------------===//

    virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc,
                                            SourceLocation LabLoc,
                                            IdentifierInfo *LabelII) {// "&&foo"
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc,
                                           StmtArg SubStmt,
                                           SourceLocation RPLoc) { // "({..})"
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
                                                  SourceLocation BuiltinLoc,
                                                  SourceLocation TypeLoc,
                                                  TypeTy *Arg1,
                                                  OffsetOfComponent *CompPtr,
                                                  unsigned NumComponents,
                                                  SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    // __builtin_types_compatible_p(type1, type2)
    virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
                                                      TypeTy *arg1,TypeTy *arg2,
                                                      SourceLocation RPLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
    // __builtin_choose_expr(constExpr, expr1, expr2)
    virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
                                             ExprArg cond, ExprArg expr1,
                                             ExprArg expr2,
                                             SourceLocation RPLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    // __builtin_va_arg(expr, type)
    virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
                                  ExprArg expr, TypeTy *type,
                                  SourceLocation RPLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
    }

    virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
    }

    virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
    }

    virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc,
                                                StmtArg Body,
                                                Scope *CurScope) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
                                             IdentifierInfo *Ident,
                                             SourceLocation LBrace) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace) {
      Out << __FUNCTION__ << "\n";
      return;
    }

#if 0
    // FIXME: AttrList should be deleted by this function, but the definition
    // would have to be available.
    virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
                                          SourceLocation UsingLoc,
                                          SourceLocation NamespcLoc,
                                          const CXXScopeSpec &SS,
                                          SourceLocation IdentLoc,
                                          IdentifierInfo *NamespcName,
                                          AttributeList *AttrList) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }
#endif

    virtual void ActOnParamDefaultArgument(DeclPtrTy param,
                                           SourceLocation EqualLoc,
                                           ExprArg defarg) {
      Out << __FUNCTION__ << "\n";
    }

    virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
                                                   SourceLocation EqualLoc) {
      Out << __FUNCTION__ << "\n";
    }

    virtual void ActOnParamDefaultArgumentError(DeclPtrTy param) {
      Out << __FUNCTION__ << "\n";
    }

    virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
                                               SourceLocation LParenLoc,
                                               MultiExprArg Exprs,
                                               SourceLocation *CommaLocs,
                                               SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return;
    }

    virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
                                                       DeclPtrTy Method)
    {
      Out << __FUNCTION__ << "\n";
    }

    virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param) {
      Out << __FUNCTION__ << "\n";
    }

    virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
                                                        DeclPtrTy Method) {
      Out << __FUNCTION__ << "\n";
    }

    virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
                                                   ExprArg AssertExpr,
                                                   ExprArg AssertMessageExpr) {
      Out << __FUNCTION__ << "\n";
      return DeclPtrTy();
    }

    virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
                                               tok::TokenKind Kind,
                                               SourceLocation LAngleBracketLoc,
                                               TypeTy *Ty,
                                               SourceLocation RAngleBracketLoc,
                                               SourceLocation LParenLoc,
                                               ExprArg Op,
                                               SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc,
                                            SourceLocation LParenLoc,
                                            bool isType, void *TyOrExpr,
                                            SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
                                                 tok::TokenKind Kind) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc, ExprArg Op) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
                                                     TypeTy *TypeRep,
                                                     SourceLocation LParenLoc,
                                                     MultiExprArg Exprs,
                                                     SourceLocation *CommaLocs,
                                                     SourceLocation RParenLoc) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXConditionDeclarationExpr(Scope *S,
                                                        SourceLocation StartLoc,
                                                        Declarator &D,
                                                        SourceLocation EqualLoc,
                                                        ExprArg AssignExprVal) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc,
                                         bool UseGlobal,
                                         SourceLocation PlacementLParen,
                                         MultiExprArg PlacementArgs,
                                         SourceLocation PlacementRParen,
                                         bool ParenTypeId, Declarator &D,
                                         SourceLocation ConstructorLParen,
                                         MultiExprArg ConstructorArgs,
                                         SourceLocation ConstructorRParen) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc,
                                            bool UseGlobal, bool ArrayForm,
                                            ExprArg Operand) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }

    virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
                                                 SourceLocation KWLoc,
                                                 SourceLocation LParen,
                                                 TypeTy *Ty,
                                                 SourceLocation RParen) {
      Out << __FUNCTION__ << "\n";
      return ExprEmpty();
    }
  };
}

MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP,
                                                     llvm::raw_ostream* OS) {
  return new ParserPrintActions(PP, *OS);
}