blob: 90cdf45270794456ec4a98a781068a72586fcba6 [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 Gregorc4b4e7b2008-12-24 02:52:09 +0000192 AttributeList *Attr,
193 MultiTemplateParamsArg TemplateParameterLists) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000194 // TagType is an instance of DeclSpec::TST, indicating what kind of tag this
195 // is (struct/union/enum/class).
196 llvm::cout << __FUNCTION__ << "\n";
197 return 0;
198 }
199
200 /// Act on @defs() element found when parsing a structure. ClassName is the
201 /// name of the referenced class.
Douglas Gregor44b43212008-12-11 16:49:14 +0000202 virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000203 IdentifierInfo *ClassName,
204 llvm::SmallVectorImpl<DeclTy*> &Decls) {
205 llvm::cout << __FUNCTION__ << "\n";
206 }
207
Douglas Gregor44b43212008-12-11 16:49:14 +0000208 virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD,
209 SourceLocation DeclStart,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000210 Declarator &D, ExprTy *BitfieldWidth) {
211 llvm::cout << __FUNCTION__ << "\n";
212 return 0;
213 }
214
215 virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart,
216 Declarator &D, ExprTy *BitfieldWidth,
217 tok::ObjCKeywordKind visibility) {
218 llvm::cout << __FUNCTION__ << "\n";
219 return 0;
220 }
221
222 virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl,
223 DeclTy **Fields, unsigned NumFields,
Daniel Dunbar1bfe1c22008-10-03 02:03:53 +0000224 SourceLocation LBrac, SourceLocation RBrac,
225 AttributeList *AttrList) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000226 llvm::cout << __FUNCTION__ << "\n";
227 }
228
229 virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl,
230 DeclTy *LastEnumConstant,
231 SourceLocation IdLoc, IdentifierInfo *Id,
232 SourceLocation EqualLoc, ExprTy *Val) {
233 llvm::cout << __FUNCTION__ << "\n";
234 return 0;
235 }
236
237 virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
238 DeclTy **Elements, unsigned NumElements) {
239 llvm::cout << __FUNCTION__ << "\n";
240 }
241
242 //===--------------------------------------------------------------------===//
243 // Statement Parsing Callbacks.
244 //===--------------------------------------------------------------------===//
Sebastian Redla60528c2008-12-21 12:04:03 +0000245
246 virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000247 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redla60528c2008-12-21 12:04:03 +0000248 return StmtEmpty();
249 }
250
251 virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L,
252 SourceLocation R,
253 MultiStmtArg Elts,
254 bool isStmtExpr) {
255 llvm::cout << __FUNCTION__ << "\n";
256 return StmtEmpty();
257 }
258 virtual OwningStmtResult ActOnDeclStmt(DeclTy *Decl,
259 SourceLocation StartLoc,
260 SourceLocation EndLoc) {
261 llvm::cout << __FUNCTION__ << "\n";
262 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000263 }
264
Sebastian Redla60528c2008-12-21 12:04:03 +0000265 virtual OwningStmtResult ActOnExprStmt(ExprArg Expr) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000266 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redla60528c2008-12-21 12:04:03 +0000267 return OwningStmtResult(*this, Expr.release());
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000268 }
269
270 /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
271 /// which can specify an RHS value.
Sebastian Redl117054a2008-12-28 16:13:43 +0000272 virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc,
273 ExprArg LHSVal,
274 SourceLocation DotDotDotLoc,
275 ExprArg RHSVal,
276 SourceLocation ColonLoc,
277 StmtArg SubStmt) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000278 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl117054a2008-12-28 16:13:43 +0000279 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000280 }
Sebastian Redl117054a2008-12-28 16:13:43 +0000281 virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
282 SourceLocation ColonLoc,
283 StmtArg SubStmt, Scope *CurScope){
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000284 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl117054a2008-12-28 16:13:43 +0000285 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000286 }
Sebastian Redlde307472009-01-11 00:38:46 +0000287
288 virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
289 IdentifierInfo *II,
290 SourceLocation ColonLoc,
291 StmtArg SubStmt) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000292 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000293 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000294 }
Sebastian Redlde307472009-01-11 00:38:46 +0000295
296 virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
297 StmtArg ThenVal,SourceLocation ElseLoc,
298 StmtArg ElseVal) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000299 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000300 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000301 }
Sebastian Redlde307472009-01-11 00:38:46 +0000302
303 virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000304 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000305 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000306 }
Sebastian Redlde307472009-01-11 00:38:46 +0000307
308 virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
309 StmtArg Switch,
310 StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000311 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlde307472009-01-11 00:38:46 +0000312 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000313 }
314
Sebastian Redlf05b1522009-01-16 23:28:06 +0000315 virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
316 ExprArg Cond, StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000317 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000318 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000319 }
Sebastian Redlf05b1522009-01-16 23:28:06 +0000320 virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
321 SourceLocation WhileLoc, ExprArg Cond){
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000322 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000323 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000324 }
Sebastian Redlf05b1522009-01-16 23:28:06 +0000325 virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
326 SourceLocation LParenLoc,
327 StmtArg First, ExprArg Second,
328 ExprArg Third, SourceLocation RParenLoc,
329 StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000330 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000331 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000332 }
Sebastian Redlf05b1522009-01-16 23:28:06 +0000333 virtual OwningStmtResult ActOnObjCForCollectionStmt(
334 SourceLocation ForColLoc,
335 SourceLocation LParenLoc,
336 StmtArg First, ExprArg Second,
337 SourceLocation RParenLoc, StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000338 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlf05b1522009-01-16 23:28:06 +0000339 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000340 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000341 virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
342 SourceLocation LabelLoc,
343 IdentifierInfo *LabelII) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000344 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000345 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000346 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000347 virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
348 SourceLocation StarLoc,
349 ExprArg DestExp) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000350 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000351 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000352 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000353 virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
354 Scope *CurScope) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000355 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000356 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000357 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000358 virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
359 Scope *CurScope) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000360 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000361 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000362 }
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000363 virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
364 ExprArg RetValExp) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000365 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl4cffe2f2009-01-18 13:19:59 +0000366 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000367 }
Sebastian Redl3037ed02009-01-18 16:53:17 +0000368 virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
369 bool IsSimple,
370 bool IsVolatile,
371 unsigned NumOutputs,
372 unsigned NumInputs,
373 std::string *Names,
374 MultiExprArg Constraints,
375 MultiExprArg Exprs,
376 ExprArg AsmString,
377 MultiExprArg Clobbers,
378 SourceLocation RParenLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000379 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl3037ed02009-01-18 16:53:17 +0000380 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000381 }
Sebastian Redl3037ed02009-01-18 16:53:17 +0000382
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000383 // Objective-c statements
Sebastian Redl431e90e2009-01-18 17:43:11 +0000384 virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
385 SourceLocation RParen,
386 StmtArg Parm, StmtArg Body,
387 StmtArg CatchList) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000388 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000389 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000390 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000391
392 virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
393 StmtArg Body) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000394 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000395 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000396 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000397
398 virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
399 StmtArg Try, StmtArg Catch,
400 StmtArg Finally) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000401 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000402 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000403 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000404
405 virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
406 ExprArg Throw) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000407 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000408 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000409 }
Sebastian Redl431e90e2009-01-18 17:43:11 +0000410
411 virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
412 ExprArg SynchExpr,
413 StmtArg SynchBody) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000414 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl431e90e2009-01-18 17:43:11 +0000415 return StmtEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000416 }
Sebastian Redla0fd8652008-12-21 16:41:36 +0000417
418 // C++ Statements
419 virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D) {
420 llvm::cout << __FUNCTION__ << "\n";
421 return 0;
422 }
423
424 virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
425 DeclTy *ExceptionDecl,
426 StmtArg HandlerBlock) {
427 llvm::cout << __FUNCTION__ << "\n";
428 return StmtEmpty();
429 }
430
431 virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
432 StmtArg TryBlock,
433 MultiStmtArg Handlers) {
434 llvm::cout << __FUNCTION__ << "\n";
435 return StmtEmpty();
436 }
437
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000438 //===--------------------------------------------------------------------===//
439 // Expression Parsing Callbacks.
440 //===--------------------------------------------------------------------===//
Sebastian Redlcd965b92009-01-18 18:53:16 +0000441
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000442 // Primary Expressions.
Sebastian Redlcd965b92009-01-18 18:53:16 +0000443
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000444 /// ActOnIdentifierExpr - Parse an identifier in expression context.
445 /// 'HasTrailingLParen' indicates whether or not the identifier has a '('
446 /// token immediately after it.
Sebastian Redlcd965b92009-01-18 18:53:16 +0000447 virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
448 IdentifierInfo &II,
449 bool HasTrailingLParen,
Sebastian Redlebc07d52009-02-03 20:19:35 +0000450 const CXXScopeSpec *SS,
451 bool isAddressOfOperand) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000452 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000453 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000454 }
455
Sebastian Redlcd965b92009-01-18 18:53:16 +0000456 virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr(
457 Scope *S, SourceLocation OperatorLoc,
458 OverloadedOperatorKind Op,
Sebastian Redlebc07d52009-02-03 20:19:35 +0000459 bool HasTrailingLParen, const CXXScopeSpec &SS,
460 bool isAddressOfOperand) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000461 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000462 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000463 }
464
Sebastian Redlcd965b92009-01-18 18:53:16 +0000465 virtual OwningExprResult ActOnCXXConversionFunctionExpr(
466 Scope *S, SourceLocation OperatorLoc,
467 TypeTy *Type, bool HasTrailingLParen,
Sebastian Redlebc07d52009-02-03 20:19:35 +0000468 const CXXScopeSpec &SS,bool isAddressOfOperand) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000469 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000470 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000471 }
Sebastian Redlcd965b92009-01-18 18:53:16 +0000472
473 virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
474 tok::TokenKind Kind) {
475 llvm::cout << __FUNCTION__ << "\n";
476 return ExprEmpty();
477 }
478
479 virtual OwningExprResult ActOnCharacterConstant(const Token &) {
480 llvm::cout << __FUNCTION__ << "\n";
481 return ExprEmpty();
482 }
483
484 virtual OwningExprResult ActOnNumericConstant(const Token &) {
485 llvm::cout << __FUNCTION__ << "\n";
486 return ExprEmpty();
487 }
488
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000489 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
490 /// fragments (e.g. "foo" "bar" L"baz").
Sebastian Redlcd965b92009-01-18 18:53:16 +0000491 virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
492 unsigned NumToks) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000493 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000494 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000495 }
Sebastian Redlcd965b92009-01-18 18:53:16 +0000496
497 virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
498 ExprArg Val) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000499 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlcd965b92009-01-18 18:53:16 +0000500 return move_res(Val); // Default impl returns operand.
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000501 }
Sebastian Redlcd965b92009-01-18 18:53:16 +0000502
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000503 // Postfix Expressions.
Sebastian Redl0eb23302009-01-19 00:08:26 +0000504 virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
505 tok::TokenKind Kind,
506 ExprArg Input) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000507 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000508 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000509 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000510 virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
511 SourceLocation LLoc,
512 ExprArg Idx,
513 SourceLocation RLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000514 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000515 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000516 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000517 virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base,
518 SourceLocation OpLoc,
519 tok::TokenKind OpKind,
520 SourceLocation MemberLoc,
521 IdentifierInfo &Member) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000522 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000523 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000524 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000525
526 virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
527 SourceLocation LParenLoc,
528 MultiExprArg Args,
529 SourceLocation *CommaLocs,
530 SourceLocation RParenLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000531 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000532 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000533 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000534
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000535 // Unary Operators. 'Tok' is the token for the operator.
Sebastian Redl0eb23302009-01-19 00:08:26 +0000536 virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
537 tok::TokenKind Op, ExprArg Input) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000538 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000539 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000540 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000541 virtual OwningExprResult
542 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
543 void *TyOrEx, const SourceRange &ArgRange) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000544 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redl0eb23302009-01-19 00:08:26 +0000545 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000546 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000547
548 virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen,
549 TypeTy *Ty,
550 SourceLocation RParen,
551 ExprArg Op) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000552 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000553 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000554 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000555 virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
556 MultiExprArg InitList,
557 InitListDesignations &Designators,
558 SourceLocation RParenLoc) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000559 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000560 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000561 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000562 virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
563 SourceLocation RParenLoc,ExprArg Op){
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000564 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000565 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000566 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000567
568 virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
569 tok::TokenKind Kind,
570 ExprArg LHS, ExprArg RHS) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000571 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000572 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000573 }
574
575 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
576 /// in the case of a the GNU conditional expr extension.
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000577 virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
578 SourceLocation ColonLoc,
579 ExprArg Cond, ExprArg LHS,
580 ExprArg RHS) {
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000581 llvm::cout << __FUNCTION__ << "\n";
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000582 return ExprEmpty();
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000583 }
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000584
585 //===--------------------- GNU Extension Expressions ------------------===//
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000586
587 virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
588 IdentifierInfo *LabelII) { // "&&foo"
589 llvm::cout << __FUNCTION__ << "\n";
590 return 0;
591 }
592
593 virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
594 SourceLocation RPLoc) { // "({..})"
595 llvm::cout << __FUNCTION__ << "\n";
596 return 0;
597 }
598
Douglas Gregor3fc749d2008-12-23 00:26:44 +0000599 virtual ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc,
Daniel Dunbarbb8f4e62008-08-01 00:41:12 +0000600 SourceLocation TypeLoc, TypeTy *Arg1,
601 OffsetOfComponent *CompPtr,
602 unsigned NumComponents,
603 SourceLocation RParenLoc) {
604 llvm::cout << __FUNCTION__ << "\n";
605 return 0;
606 }
607
608 // __builtin_types_compatible_p(type1, type2)
609 virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
610 TypeTy *arg1, TypeTy *arg2,
611 SourceLocation RPLoc) {
612 llvm::cout << __FUNCTION__ << "\n";
613 return 0;
614 }
615 // __builtin_choose_expr(constExpr, expr1, expr2)
616 virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
617 ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
618 SourceLocation RPLoc) {
619 llvm::cout << __FUNCTION__ << "\n";
620 return 0;
621 }
622 // __builtin_overload(...)
623 virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs,
624 SourceLocation *CommaLocs,
625 SourceLocation BuiltinLoc,
626 SourceLocation RPLoc) {
627 llvm::cout << __FUNCTION__ << "\n";
628 return 0;
629 }
630
631
632 // __builtin_va_arg(expr, type)
633 virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
634 ExprTy *expr, TypeTy *type,
635 SourceLocation RPLoc) {
636 llvm::cout << __FUNCTION__ << "\n";
637 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +0000638 }
639 };
640}
641
Daniel Dunbare10b0f22008-10-31 08:56:51 +0000642MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) {
643 return new ParserPrintActions(PP);
Reid Spencer5f016e22007-07-11 17:01:13 +0000644}