Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- PrintParserActions.cpp - Implement -parse-print-callbacks mode ---===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 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 Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | #include "clang/Parse/Action.h" |
| 17 | #include "clang/Parse/DeclSpec.h" |
Ted Kremenek | bdd30c2 | 2008-01-14 16:44:48 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Streams.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 19 | using namespace clang; |
| 20 | |
| 21 | namespace { |
| 22 | class ParserPrintActions : public MinimalAction { |
| 23 | |
Steve Naroff | b4292f2 | 2007-10-31 20:55:39 +0000 | [diff] [blame] | 24 | public: |
Daniel Dunbar | e10b0f2 | 2008-10-31 08:56:51 +0000 | [diff] [blame] | 25 | ParserPrintActions(Preprocessor &PP) : MinimalAction(PP) {} |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 26 | |
| 27 | // Printing Functions which also must call MinimalAction |
| 28 | |
Steve Naroff | 08d92e4 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 29 | /// ActOnDeclarator - This callback is invoked when a declarator is parsed |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 30 | /// and 'Init' specifies the initializer if any. This is for things like: |
| 31 | /// "int X = 4" or "typedef int foo". |
Steve Naroff | 08d92e4 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 32 | virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, |
Daniel Dunbar | 914701e | 2008-08-05 16:28:08 +0000 | [diff] [blame] | 33 | DeclTy *LastInGroup) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 34 | llvm::cout << __FUNCTION__ << " "; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 35 | if (IdentifierInfo *II = D.getIdentifier()) { |
Ted Kremenek | bdd30c2 | 2008-01-14 16:44:48 +0000 | [diff] [blame] | 36 | llvm::cout << "'" << II->getName() << "'"; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 37 | } else { |
Ted Kremenek | bdd30c2 | 2008-01-14 16:44:48 +0000 | [diff] [blame] | 38 | llvm::cout << "<anon>"; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 39 | } |
Ted Kremenek | bdd30c2 | 2008-01-14 16:44:48 +0000 | [diff] [blame] | 40 | llvm::cout << "\n"; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 41 | |
| 42 | // Pass up to EmptyActions so that the symbol table is maintained right. |
Daniel Dunbar | 914701e | 2008-08-05 16:28:08 +0000 | [diff] [blame] | 43 | return MinimalAction::ActOnDeclarator(S, D, LastInGroup); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 44 | } |
Steve Naroff | 640db42 | 2007-10-10 17:45:44 +0000 | [diff] [blame] | 45 | /// ActOnPopScope - This callback is called immediately before the specified |
| 46 | /// scope is popped and deleted. |
| 47 | virtual void ActOnPopScope(SourceLocation Loc, Scope *S) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 48 | 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 Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 111 | virtual void AddInitializerToDecl(DeclTy *Dcl, ExprArg Init) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 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. |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 143 | virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 144 | llvm::cout << __FUNCTION__ << "\n"; |
| 145 | return 0; |
| 146 | } |
| 147 | |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 148 | virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg AsmString) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 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 | } |
Douglas Gregor | e79837a | 2008-12-17 01:46:43 +0000 | [diff] [blame] | 159 | |
| 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 Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 164 | virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace, |
| 165 | SourceLocation RBrace, const char *Lang, |
Douglas Gregor | e79837a | 2008-12-17 01:46:43 +0000 | [diff] [blame] | 166 | unsigned StrSize, |
| 167 | DeclTy **Decls, unsigned NumDecls) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 168 | llvm::cout << __FUNCTION__ << "\n"; |
| 169 | return 0; |
| 170 | } |
Douglas Gregor | e79837a | 2008-12-17 01:46:43 +0000 | [diff] [blame] | 171 | |
| 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 Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 180 | //===--------------------------------------------------------------------===// |
| 181 | // Type Parsing Callbacks. |
| 182 | //===--------------------------------------------------------------------===// |
| 183 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 184 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 185 | llvm::cout << __FUNCTION__ << "\n"; |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK, |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 190 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 191 | IdentifierInfo *Name, SourceLocation NameLoc, |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 192 | AttributeList *Attr, |
| 193 | MultiTemplateParamsArg TemplateParameterLists) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 194 | // 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 Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 202 | virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 203 | IdentifierInfo *ClassName, |
| 204 | llvm::SmallVectorImpl<DeclTy*> &Decls) { |
| 205 | llvm::cout << __FUNCTION__ << "\n"; |
| 206 | } |
| 207 | |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 208 | virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD, |
| 209 | SourceLocation DeclStart, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 210 | 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 Dunbar | 1bfe1c2 | 2008-10-03 02:03:53 +0000 | [diff] [blame] | 224 | SourceLocation LBrac, SourceLocation RBrac, |
| 225 | AttributeList *AttrList) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 226 | 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 Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 245 | |
| 246 | virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 247 | llvm::cout << __FUNCTION__ << "\n"; |
Sebastian Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 248 | 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 Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 263 | } |
| 264 | |
Sebastian Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 265 | virtual OwningStmtResult ActOnExprStmt(ExprArg Expr) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 266 | llvm::cout << __FUNCTION__ << "\n"; |
Sebastian Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 267 | return OwningStmtResult(*this, Expr.release()); |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, |
| 271 | /// which can specify an RHS value. |
| 272 | virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal, |
| 273 | SourceLocation DotDotDotLoc, ExprTy *RHSVal, |
| 274 | SourceLocation ColonLoc, StmtTy *SubStmt) { |
| 275 | llvm::cout << __FUNCTION__ << "\n"; |
| 276 | return 0; |
| 277 | } |
| 278 | virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
| 279 | SourceLocation ColonLoc, StmtTy *SubStmt, |
| 280 | Scope *CurScope){ |
| 281 | llvm::cout << __FUNCTION__ << "\n"; |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II, |
| 286 | SourceLocation ColonLoc, StmtTy *SubStmt) { |
| 287 | llvm::cout << __FUNCTION__ << "\n"; |
| 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal, |
| 292 | StmtTy *ThenVal, SourceLocation ElseLoc, |
| 293 | StmtTy *ElseVal) { |
| 294 | llvm::cout << __FUNCTION__ << "\n"; |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond) { |
| 299 | llvm::cout << __FUNCTION__ << "\n"; |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, |
| 304 | StmtTy *Switch, ExprTy *Body) { |
| 305 | llvm::cout << __FUNCTION__ << "\n"; |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, |
| 310 | StmtTy *Body) { |
| 311 | llvm::cout << __FUNCTION__ << "\n"; |
| 312 | return 0; |
| 313 | } |
| 314 | virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body, |
| 315 | SourceLocation WhileLoc, ExprTy *Cond) { |
| 316 | llvm::cout << __FUNCTION__ << "\n"; |
| 317 | return 0; |
| 318 | } |
| 319 | virtual StmtResult ActOnForStmt(SourceLocation ForLoc, |
| 320 | SourceLocation LParenLoc, |
| 321 | StmtTy *First, ExprTy *Second, ExprTy *Third, |
| 322 | SourceLocation RParenLoc, StmtTy *Body) { |
| 323 | llvm::cout << __FUNCTION__ << "\n"; |
| 324 | return 0; |
| 325 | } |
| 326 | virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, |
| 327 | SourceLocation LParenLoc, |
| 328 | StmtTy *First, ExprTy *Second, |
| 329 | SourceLocation RParenLoc, StmtTy *Body) { |
| 330 | llvm::cout << __FUNCTION__ << "\n"; |
| 331 | return 0; |
| 332 | } |
| 333 | virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
| 334 | SourceLocation LabelLoc, |
| 335 | IdentifierInfo *LabelII) { |
| 336 | llvm::cout << __FUNCTION__ << "\n"; |
| 337 | return 0; |
| 338 | } |
| 339 | virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
| 340 | SourceLocation StarLoc, |
| 341 | ExprTy *DestExp) { |
| 342 | llvm::cout << __FUNCTION__ << "\n"; |
| 343 | return 0; |
| 344 | } |
| 345 | virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
| 346 | Scope *CurScope) { |
| 347 | llvm::cout << __FUNCTION__ << "\n"; |
| 348 | return 0; |
| 349 | } |
| 350 | virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope) { |
| 351 | llvm::cout << __FUNCTION__ << "\n"; |
| 352 | return 0; |
| 353 | } |
| 354 | virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
| 355 | ExprTy *RetValExp) { |
| 356 | llvm::cout << __FUNCTION__ << "\n"; |
| 357 | return 0; |
| 358 | } |
| 359 | virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc, |
| 360 | bool IsSimple, |
| 361 | bool IsVolatile, |
| 362 | unsigned NumOutputs, |
| 363 | unsigned NumInputs, |
| 364 | std::string *Names, |
| 365 | ExprTy **Constraints, |
| 366 | ExprTy **Exprs, |
| 367 | ExprTy *AsmString, |
| 368 | unsigned NumClobbers, |
| 369 | ExprTy **Clobbers, |
| 370 | SourceLocation RParenLoc) { |
| 371 | llvm::cout << __FUNCTION__ << "\n"; |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | // Objective-c statements |
| 376 | virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, |
| 377 | SourceLocation RParen, StmtTy *Parm, |
| 378 | StmtTy *Body, StmtTy *CatchList) { |
| 379 | llvm::cout << __FUNCTION__ << "\n"; |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, |
| 384 | StmtTy *Body) { |
| 385 | llvm::cout << __FUNCTION__ << "\n"; |
| 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, |
| 390 | StmtTy *Try, |
| 391 | StmtTy *Catch, StmtTy *Finally) { |
| 392 | llvm::cout << __FUNCTION__ << "\n"; |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, |
| 397 | StmtTy *Throw) { |
| 398 | llvm::cout << __FUNCTION__ << "\n"; |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| 403 | ExprTy *SynchExpr, |
| 404 | StmtTy *SynchBody) { |
| 405 | llvm::cout << __FUNCTION__ << "\n"; |
| 406 | return 0; |
| 407 | } |
Sebastian Redl | a0fd865 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 408 | |
| 409 | // C++ Statements |
| 410 | virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D) { |
| 411 | llvm::cout << __FUNCTION__ << "\n"; |
| 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, |
| 416 | DeclTy *ExceptionDecl, |
| 417 | StmtArg HandlerBlock) { |
| 418 | llvm::cout << __FUNCTION__ << "\n"; |
| 419 | return StmtEmpty(); |
| 420 | } |
| 421 | |
| 422 | virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc, |
| 423 | StmtArg TryBlock, |
| 424 | MultiStmtArg Handlers) { |
| 425 | llvm::cout << __FUNCTION__ << "\n"; |
| 426 | return StmtEmpty(); |
| 427 | } |
| 428 | |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 429 | //===--------------------------------------------------------------------===// |
| 430 | // Expression Parsing Callbacks. |
| 431 | //===--------------------------------------------------------------------===// |
| 432 | |
| 433 | // Primary Expressions. |
| 434 | |
| 435 | /// ActOnIdentifierExpr - Parse an identifier in expression context. |
| 436 | /// 'HasTrailingLParen' indicates whether or not the identifier has a '(' |
| 437 | /// token immediately after it. |
| 438 | virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc, |
| 439 | IdentifierInfo &II, |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 440 | bool HasTrailingLParen, |
| 441 | const CXXScopeSpec *SS) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 442 | llvm::cout << __FUNCTION__ << "\n"; |
| 443 | return 0; |
| 444 | } |
| 445 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 446 | virtual ExprResult ActOnPredefinedExpr(SourceLocation Loc, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 447 | tok::TokenKind Kind) { |
| 448 | llvm::cout << __FUNCTION__ << "\n"; |
| 449 | return 0; |
| 450 | } |
| 451 | |
| 452 | virtual ExprResult ActOnCharacterConstant(const Token &) { |
| 453 | llvm::cout << __FUNCTION__ << "\n"; |
| 454 | return 0; |
| 455 | } |
| 456 | |
| 457 | virtual ExprResult ActOnNumericConstant(const Token &) { |
| 458 | llvm::cout << __FUNCTION__ << "\n"; |
| 459 | return 0; |
| 460 | } |
| 461 | |
| 462 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
| 463 | /// fragments (e.g. "foo" "bar" L"baz"). |
| 464 | virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks) { |
| 465 | llvm::cout << __FUNCTION__ << "\n"; |
| 466 | return 0; |
| 467 | } |
| 468 | |
| 469 | virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
| 470 | ExprTy *Val) { |
| 471 | llvm::cout << __FUNCTION__ << "\n"; |
| 472 | return Val; // Default impl returns operand. |
| 473 | } |
| 474 | |
| 475 | // Postfix Expressions. |
Douglas Gregor | 7425373 | 2008-11-19 15:42:04 +0000 | [diff] [blame] | 476 | virtual ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 477 | tok::TokenKind Kind, ExprTy *Input) { |
| 478 | llvm::cout << __FUNCTION__ << "\n"; |
| 479 | return 0; |
| 480 | } |
Douglas Gregor | 337c6b9 | 2008-11-19 17:17:41 +0000 | [diff] [blame] | 481 | virtual ExprResult ActOnArraySubscriptExpr(Scope *S, ExprTy *Base, |
| 482 | SourceLocation LLoc, ExprTy *Idx, |
| 483 | SourceLocation RLoc) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 484 | llvm::cout << __FUNCTION__ << "\n"; |
| 485 | return 0; |
| 486 | } |
Douglas Gregor | 3fc749d | 2008-12-23 00:26:44 +0000 | [diff] [blame] | 487 | virtual ExprResult ActOnMemberReferenceExpr(Scope *S, ExprTy *Base, |
| 488 | SourceLocation OpLoc, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 489 | tok::TokenKind OpKind, |
| 490 | SourceLocation MemberLoc, |
| 491 | IdentifierInfo &Member) { |
| 492 | llvm::cout << __FUNCTION__ << "\n"; |
| 493 | return 0; |
| 494 | } |
| 495 | |
| 496 | /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. |
| 497 | /// This provides the location of the left/right parens and a list of comma |
| 498 | /// locations. There are guaranteed to be one fewer commas than arguments, |
| 499 | /// unless there are zero arguments. |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 500 | virtual ExprResult ActOnCallExpr(Scope *S, ExprTy *Fn, |
| 501 | SourceLocation LParenLoc, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 502 | ExprTy **Args, unsigned NumArgs, |
| 503 | SourceLocation *CommaLocs, |
| 504 | SourceLocation RParenLoc) { |
| 505 | llvm::cout << __FUNCTION__ << "\n"; |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | // Unary Operators. 'Tok' is the token for the operator. |
Douglas Gregor | 7425373 | 2008-11-19 15:42:04 +0000 | [diff] [blame] | 510 | virtual ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, |
| 511 | tok::TokenKind Op, ExprTy *Input) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 512 | llvm::cout << __FUNCTION__ << "\n"; |
| 513 | return 0; |
| 514 | } |
| 515 | virtual ExprResult |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 516 | ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, |
| 517 | void *TyOrEx, const SourceRange &ArgRange) { |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 518 | llvm::cout << __FUNCTION__ << "\n"; |
| 519 | return 0; |
| 520 | } |
| 521 | |
| 522 | virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty, |
| 523 | SourceLocation RParen, ExprTy *Op) { |
| 524 | llvm::cout << __FUNCTION__ << "\n"; |
| 525 | return 0; |
| 526 | } |
| 527 | virtual ExprResult ActOnInitList(SourceLocation LParenLoc, |
| 528 | ExprTy **InitList, unsigned NumInit, |
Chris Lattner | 220ad7c | 2008-10-26 23:35:51 +0000 | [diff] [blame] | 529 | InitListDesignations &Designators, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 530 | SourceLocation RParenLoc) { |
| 531 | llvm::cout << __FUNCTION__ << "\n"; |
| 532 | return 0; |
| 533 | } |
| 534 | virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, |
| 535 | SourceLocation RParenLoc, ExprTy *Op) { |
| 536 | llvm::cout << __FUNCTION__ << "\n"; |
| 537 | return 0; |
| 538 | } |
| 539 | |
Douglas Gregor | eaebc75 | 2008-11-06 23:29:22 +0000 | [diff] [blame] | 540 | virtual ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, |
| 541 | tok::TokenKind Kind, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 542 | ExprTy *LHS, ExprTy *RHS) { |
| 543 | llvm::cout << __FUNCTION__ << "\n"; |
| 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
| 548 | /// in the case of a the GNU conditional expr extension. |
| 549 | virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
| 550 | SourceLocation ColonLoc, |
| 551 | ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){ |
| 552 | llvm::cout << __FUNCTION__ << "\n"; |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | //===---------------------- GNU Extension Expressions -------------------===// |
| 557 | |
| 558 | virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, |
| 559 | IdentifierInfo *LabelII) { // "&&foo" |
| 560 | llvm::cout << __FUNCTION__ << "\n"; |
| 561 | return 0; |
| 562 | } |
| 563 | |
| 564 | virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt, |
| 565 | SourceLocation RPLoc) { // "({..})" |
| 566 | llvm::cout << __FUNCTION__ << "\n"; |
| 567 | return 0; |
| 568 | } |
| 569 | |
Douglas Gregor | 3fc749d | 2008-12-23 00:26:44 +0000 | [diff] [blame] | 570 | virtual ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 571 | SourceLocation TypeLoc, TypeTy *Arg1, |
| 572 | OffsetOfComponent *CompPtr, |
| 573 | unsigned NumComponents, |
| 574 | SourceLocation RParenLoc) { |
| 575 | llvm::cout << __FUNCTION__ << "\n"; |
| 576 | return 0; |
| 577 | } |
| 578 | |
| 579 | // __builtin_types_compatible_p(type1, type2) |
| 580 | virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
| 581 | TypeTy *arg1, TypeTy *arg2, |
| 582 | SourceLocation RPLoc) { |
| 583 | llvm::cout << __FUNCTION__ << "\n"; |
| 584 | return 0; |
| 585 | } |
| 586 | // __builtin_choose_expr(constExpr, expr1, expr2) |
| 587 | virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
| 588 | ExprTy *cond, ExprTy *expr1, ExprTy *expr2, |
| 589 | SourceLocation RPLoc) { |
| 590 | llvm::cout << __FUNCTION__ << "\n"; |
| 591 | return 0; |
| 592 | } |
| 593 | // __builtin_overload(...) |
| 594 | virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs, |
| 595 | SourceLocation *CommaLocs, |
| 596 | SourceLocation BuiltinLoc, |
| 597 | SourceLocation RPLoc) { |
| 598 | llvm::cout << __FUNCTION__ << "\n"; |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | |
| 603 | // __builtin_va_arg(expr, type) |
| 604 | virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc, |
| 605 | ExprTy *expr, TypeTy *type, |
| 606 | SourceLocation RPLoc) { |
| 607 | llvm::cout << __FUNCTION__ << "\n"; |
| 608 | return 0; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 609 | } |
| 610 | }; |
| 611 | } |
| 612 | |
Daniel Dunbar | e10b0f2 | 2008-10-31 08:56:51 +0000 | [diff] [blame] | 613 | MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP) { |
| 614 | return new ParserPrintActions(PP); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 615 | } |