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: |
| 25 | ParserPrintActions(IdentifierTable &IT) : MinimalAction(IT) {} |
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. |
| 111 | virtual void AddInitializerToDecl(DeclTy *Dcl, ExprTy *Init) { |
| 112 | llvm::cout << __FUNCTION__ << "\n"; |
| 113 | } |
| 114 | |
| 115 | /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this |
| 116 | /// gives the actions implementation a chance to process the group as a whole. |
| 117 | virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group) { |
| 118 | llvm::cout << __FUNCTION__ << "\n"; |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | /// ActOnStartOfFunctionDef - This is called at the start of a function |
| 123 | /// definition, instead of calling ActOnDeclarator. The Declarator includes |
| 124 | /// information about formal arguments that are part of this function. |
| 125 | virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) { |
| 126 | llvm::cout << __FUNCTION__ << "\n"; |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | /// ActOnStartOfFunctionDef - This is called at the start of a function |
| 131 | /// definition, after the FunctionDecl has already been created. |
| 132 | virtual DeclTy *ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) { |
| 133 | llvm::cout << __FUNCTION__ << "\n"; |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | virtual void ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { |
| 138 | llvm::cout << __FUNCTION__ << "\n"; |
| 139 | } |
| 140 | |
| 141 | /// ActOnFunctionDefBody - This is called when a function body has completed |
| 142 | /// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef. |
| 143 | virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body) { |
| 144 | llvm::cout << __FUNCTION__ << "\n"; |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *AsmString) { |
| 149 | llvm::cout << __FUNCTION__ << "\n"; |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 154 | /// no declarator (e.g. "struct foo;") is parsed. |
| 155 | virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { |
| 156 | llvm::cout << __FUNCTION__ << "\n"; |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace, |
| 161 | SourceLocation RBrace, const char *Lang, |
| 162 | unsigned StrSize, DeclTy *D) { |
| 163 | llvm::cout << __FUNCTION__ << "\n"; |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | //===--------------------------------------------------------------------===// |
| 168 | // Type Parsing Callbacks. |
| 169 | //===--------------------------------------------------------------------===// |
| 170 | |
| 171 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) { |
| 172 | llvm::cout << __FUNCTION__ << "\n"; |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | virtual DeclTy *ActOnTag(Scope *S, unsigned TagType, TagKind TK, |
| 177 | SourceLocation KWLoc, IdentifierInfo *Name, |
| 178 | SourceLocation NameLoc, AttributeList *Attr) { |
| 179 | // TagType is an instance of DeclSpec::TST, indicating what kind of tag this |
| 180 | // is (struct/union/enum/class). |
| 181 | llvm::cout << __FUNCTION__ << "\n"; |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | /// Act on @defs() element found when parsing a structure. ClassName is the |
| 186 | /// name of the referenced class. |
| 187 | virtual void ActOnDefs(Scope *S, SourceLocation DeclStart, |
| 188 | IdentifierInfo *ClassName, |
| 189 | llvm::SmallVectorImpl<DeclTy*> &Decls) { |
| 190 | llvm::cout << __FUNCTION__ << "\n"; |
| 191 | } |
| 192 | |
| 193 | virtual DeclTy *ActOnField(Scope *S, SourceLocation DeclStart, |
| 194 | Declarator &D, ExprTy *BitfieldWidth) { |
| 195 | llvm::cout << __FUNCTION__ << "\n"; |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart, |
| 200 | Declarator &D, ExprTy *BitfieldWidth, |
| 201 | tok::ObjCKeywordKind visibility) { |
| 202 | llvm::cout << __FUNCTION__ << "\n"; |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclTy *TagDecl, |
| 207 | DeclTy **Fields, unsigned NumFields, |
| 208 | SourceLocation LBrac, SourceLocation RBrac) { |
| 209 | llvm::cout << __FUNCTION__ << "\n"; |
| 210 | } |
| 211 | |
| 212 | virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl, |
| 213 | DeclTy *LastEnumConstant, |
| 214 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 215 | SourceLocation EqualLoc, ExprTy *Val) { |
| 216 | llvm::cout << __FUNCTION__ << "\n"; |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl, |
| 221 | DeclTy **Elements, unsigned NumElements) { |
| 222 | llvm::cout << __FUNCTION__ << "\n"; |
| 223 | } |
| 224 | |
| 225 | //===--------------------------------------------------------------------===// |
| 226 | // Statement Parsing Callbacks. |
| 227 | //===--------------------------------------------------------------------===// |
| 228 | |
| 229 | virtual StmtResult ActOnNullStmt(SourceLocation SemiLoc) { |
| 230 | llvm::cout << __FUNCTION__ << "\n"; |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | virtual StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, |
| 235 | StmtTy **Elts, unsigned NumElts, |
| 236 | bool isStmtExpr) { |
| 237 | llvm::cout << __FUNCTION__ << "\n"; |
| 238 | return 0; |
| 239 | } |
| 240 | virtual StmtResult ActOnDeclStmt(DeclTy *Decl, SourceLocation StartLoc, |
| 241 | SourceLocation EndLoc) { |
| 242 | llvm::cout << __FUNCTION__ << "\n"; |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | virtual StmtResult ActOnExprStmt(ExprTy *Expr) { |
| 247 | llvm::cout << __FUNCTION__ << "\n"; |
| 248 | return StmtResult(Expr); |
| 249 | } |
| 250 | |
| 251 | /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, |
| 252 | /// which can specify an RHS value. |
| 253 | virtual StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal, |
| 254 | SourceLocation DotDotDotLoc, ExprTy *RHSVal, |
| 255 | SourceLocation ColonLoc, StmtTy *SubStmt) { |
| 256 | llvm::cout << __FUNCTION__ << "\n"; |
| 257 | return 0; |
| 258 | } |
| 259 | virtual StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
| 260 | SourceLocation ColonLoc, StmtTy *SubStmt, |
| 261 | Scope *CurScope){ |
| 262 | llvm::cout << __FUNCTION__ << "\n"; |
| 263 | return 0; |
| 264 | } |
| 265 | |
| 266 | virtual StmtResult ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II, |
| 267 | SourceLocation ColonLoc, StmtTy *SubStmt) { |
| 268 | llvm::cout << __FUNCTION__ << "\n"; |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | virtual StmtResult ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal, |
| 273 | StmtTy *ThenVal, SourceLocation ElseLoc, |
| 274 | StmtTy *ElseVal) { |
| 275 | llvm::cout << __FUNCTION__ << "\n"; |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | virtual StmtResult ActOnStartOfSwitchStmt(ExprTy *Cond) { |
| 280 | llvm::cout << __FUNCTION__ << "\n"; |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | virtual StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, |
| 285 | StmtTy *Switch, ExprTy *Body) { |
| 286 | llvm::cout << __FUNCTION__ << "\n"; |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | virtual StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, |
| 291 | StmtTy *Body) { |
| 292 | llvm::cout << __FUNCTION__ << "\n"; |
| 293 | return 0; |
| 294 | } |
| 295 | virtual StmtResult ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body, |
| 296 | SourceLocation WhileLoc, ExprTy *Cond) { |
| 297 | llvm::cout << __FUNCTION__ << "\n"; |
| 298 | return 0; |
| 299 | } |
| 300 | virtual StmtResult ActOnForStmt(SourceLocation ForLoc, |
| 301 | SourceLocation LParenLoc, |
| 302 | StmtTy *First, ExprTy *Second, ExprTy *Third, |
| 303 | SourceLocation RParenLoc, StmtTy *Body) { |
| 304 | llvm::cout << __FUNCTION__ << "\n"; |
| 305 | return 0; |
| 306 | } |
| 307 | virtual StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, |
| 308 | SourceLocation LParenLoc, |
| 309 | StmtTy *First, ExprTy *Second, |
| 310 | SourceLocation RParenLoc, StmtTy *Body) { |
| 311 | llvm::cout << __FUNCTION__ << "\n"; |
| 312 | return 0; |
| 313 | } |
| 314 | virtual StmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
| 315 | SourceLocation LabelLoc, |
| 316 | IdentifierInfo *LabelII) { |
| 317 | llvm::cout << __FUNCTION__ << "\n"; |
| 318 | return 0; |
| 319 | } |
| 320 | virtual StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
| 321 | SourceLocation StarLoc, |
| 322 | ExprTy *DestExp) { |
| 323 | llvm::cout << __FUNCTION__ << "\n"; |
| 324 | return 0; |
| 325 | } |
| 326 | virtual StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
| 327 | Scope *CurScope) { |
| 328 | llvm::cout << __FUNCTION__ << "\n"; |
| 329 | return 0; |
| 330 | } |
| 331 | virtual StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope) { |
| 332 | llvm::cout << __FUNCTION__ << "\n"; |
| 333 | return 0; |
| 334 | } |
| 335 | virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
| 336 | ExprTy *RetValExp) { |
| 337 | llvm::cout << __FUNCTION__ << "\n"; |
| 338 | return 0; |
| 339 | } |
| 340 | virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc, |
| 341 | bool IsSimple, |
| 342 | bool IsVolatile, |
| 343 | unsigned NumOutputs, |
| 344 | unsigned NumInputs, |
| 345 | std::string *Names, |
| 346 | ExprTy **Constraints, |
| 347 | ExprTy **Exprs, |
| 348 | ExprTy *AsmString, |
| 349 | unsigned NumClobbers, |
| 350 | ExprTy **Clobbers, |
| 351 | SourceLocation RParenLoc) { |
| 352 | llvm::cout << __FUNCTION__ << "\n"; |
| 353 | return 0; |
| 354 | } |
| 355 | |
| 356 | // Objective-c statements |
| 357 | virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, |
| 358 | SourceLocation RParen, StmtTy *Parm, |
| 359 | StmtTy *Body, StmtTy *CatchList) { |
| 360 | llvm::cout << __FUNCTION__ << "\n"; |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | virtual StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, |
| 365 | StmtTy *Body) { |
| 366 | llvm::cout << __FUNCTION__ << "\n"; |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | virtual StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, |
| 371 | StmtTy *Try, |
| 372 | StmtTy *Catch, StmtTy *Finally) { |
| 373 | llvm::cout << __FUNCTION__ << "\n"; |
| 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | virtual StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, |
| 378 | StmtTy *Throw) { |
| 379 | llvm::cout << __FUNCTION__ << "\n"; |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | virtual StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| 384 | ExprTy *SynchExpr, |
| 385 | StmtTy *SynchBody) { |
| 386 | llvm::cout << __FUNCTION__ << "\n"; |
| 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | //===--------------------------------------------------------------------===// |
| 391 | // Expression Parsing Callbacks. |
| 392 | //===--------------------------------------------------------------------===// |
| 393 | |
| 394 | // Primary Expressions. |
| 395 | |
| 396 | /// ActOnIdentifierExpr - Parse an identifier in expression context. |
| 397 | /// 'HasTrailingLParen' indicates whether or not the identifier has a '(' |
| 398 | /// token immediately after it. |
| 399 | virtual ExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc, |
| 400 | IdentifierInfo &II, |
| 401 | bool HasTrailingLParen) { |
| 402 | llvm::cout << __FUNCTION__ << "\n"; |
| 403 | return 0; |
| 404 | } |
| 405 | |
Chris Lattner | d9f6910 | 2008-08-10 01:53:14 +0000 | [diff] [blame] | 406 | virtual ExprResult ActOnPredefinedExpr(SourceLocation Loc, |
Daniel Dunbar | bb8f4e6 | 2008-08-01 00:41:12 +0000 | [diff] [blame] | 407 | tok::TokenKind Kind) { |
| 408 | llvm::cout << __FUNCTION__ << "\n"; |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | virtual ExprResult ActOnCharacterConstant(const Token &) { |
| 413 | llvm::cout << __FUNCTION__ << "\n"; |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | virtual ExprResult ActOnNumericConstant(const Token &) { |
| 418 | llvm::cout << __FUNCTION__ << "\n"; |
| 419 | return 0; |
| 420 | } |
| 421 | |
| 422 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
| 423 | /// fragments (e.g. "foo" "bar" L"baz"). |
| 424 | virtual ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks) { |
| 425 | llvm::cout << __FUNCTION__ << "\n"; |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | virtual ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
| 430 | ExprTy *Val) { |
| 431 | llvm::cout << __FUNCTION__ << "\n"; |
| 432 | return Val; // Default impl returns operand. |
| 433 | } |
| 434 | |
| 435 | // Postfix Expressions. |
| 436 | virtual ExprResult ActOnPostfixUnaryOp(SourceLocation OpLoc, |
| 437 | tok::TokenKind Kind, ExprTy *Input) { |
| 438 | llvm::cout << __FUNCTION__ << "\n"; |
| 439 | return 0; |
| 440 | } |
| 441 | virtual ExprResult ActOnArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc, |
| 442 | ExprTy *Idx, SourceLocation RLoc) { |
| 443 | llvm::cout << __FUNCTION__ << "\n"; |
| 444 | return 0; |
| 445 | } |
| 446 | virtual ExprResult ActOnMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc, |
| 447 | tok::TokenKind OpKind, |
| 448 | SourceLocation MemberLoc, |
| 449 | IdentifierInfo &Member) { |
| 450 | llvm::cout << __FUNCTION__ << "\n"; |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. |
| 455 | /// This provides the location of the left/right parens and a list of comma |
| 456 | /// locations. There are guaranteed to be one fewer commas than arguments, |
| 457 | /// unless there are zero arguments. |
| 458 | virtual ExprResult ActOnCallExpr(ExprTy *Fn, SourceLocation LParenLoc, |
| 459 | ExprTy **Args, unsigned NumArgs, |
| 460 | SourceLocation *CommaLocs, |
| 461 | SourceLocation RParenLoc) { |
| 462 | llvm::cout << __FUNCTION__ << "\n"; |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | // Unary Operators. 'Tok' is the token for the operator. |
| 467 | virtual ExprResult ActOnUnaryOp(SourceLocation OpLoc, tok::TokenKind Op, |
| 468 | ExprTy *Input) { |
| 469 | llvm::cout << __FUNCTION__ << "\n"; |
| 470 | return 0; |
| 471 | } |
| 472 | virtual ExprResult |
| 473 | ActOnSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof, |
| 474 | SourceLocation LParenLoc, TypeTy *Ty, |
| 475 | SourceLocation RParenLoc) { |
| 476 | llvm::cout << __FUNCTION__ << "\n"; |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty, |
| 481 | SourceLocation RParen, ExprTy *Op) { |
| 482 | llvm::cout << __FUNCTION__ << "\n"; |
| 483 | return 0; |
| 484 | } |
| 485 | virtual ExprResult ActOnInitList(SourceLocation LParenLoc, |
| 486 | ExprTy **InitList, unsigned NumInit, |
| 487 | SourceLocation RParenLoc) { |
| 488 | llvm::cout << __FUNCTION__ << "\n"; |
| 489 | return 0; |
| 490 | } |
| 491 | virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, |
| 492 | SourceLocation RParenLoc, ExprTy *Op) { |
| 493 | llvm::cout << __FUNCTION__ << "\n"; |
| 494 | return 0; |
| 495 | } |
| 496 | |
| 497 | virtual ExprResult ActOnBinOp(SourceLocation TokLoc, tok::TokenKind Kind, |
| 498 | ExprTy *LHS, ExprTy *RHS) { |
| 499 | llvm::cout << __FUNCTION__ << "\n"; |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
| 504 | /// in the case of a the GNU conditional expr extension. |
| 505 | virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
| 506 | SourceLocation ColonLoc, |
| 507 | ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){ |
| 508 | llvm::cout << __FUNCTION__ << "\n"; |
| 509 | return 0; |
| 510 | } |
| 511 | |
| 512 | //===---------------------- GNU Extension Expressions -------------------===// |
| 513 | |
| 514 | virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, |
| 515 | IdentifierInfo *LabelII) { // "&&foo" |
| 516 | llvm::cout << __FUNCTION__ << "\n"; |
| 517 | return 0; |
| 518 | } |
| 519 | |
| 520 | virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt, |
| 521 | SourceLocation RPLoc) { // "({..})" |
| 522 | llvm::cout << __FUNCTION__ << "\n"; |
| 523 | return 0; |
| 524 | } |
| 525 | |
| 526 | virtual ExprResult ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, |
| 527 | SourceLocation TypeLoc, TypeTy *Arg1, |
| 528 | OffsetOfComponent *CompPtr, |
| 529 | unsigned NumComponents, |
| 530 | SourceLocation RParenLoc) { |
| 531 | llvm::cout << __FUNCTION__ << "\n"; |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | // __builtin_types_compatible_p(type1, type2) |
| 536 | virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
| 537 | TypeTy *arg1, TypeTy *arg2, |
| 538 | SourceLocation RPLoc) { |
| 539 | llvm::cout << __FUNCTION__ << "\n"; |
| 540 | return 0; |
| 541 | } |
| 542 | // __builtin_choose_expr(constExpr, expr1, expr2) |
| 543 | virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
| 544 | ExprTy *cond, ExprTy *expr1, ExprTy *expr2, |
| 545 | SourceLocation RPLoc) { |
| 546 | llvm::cout << __FUNCTION__ << "\n"; |
| 547 | return 0; |
| 548 | } |
| 549 | // __builtin_overload(...) |
| 550 | virtual ExprResult ActOnOverloadExpr(ExprTy **Args, unsigned NumArgs, |
| 551 | SourceLocation *CommaLocs, |
| 552 | SourceLocation BuiltinLoc, |
| 553 | SourceLocation RPLoc) { |
| 554 | llvm::cout << __FUNCTION__ << "\n"; |
| 555 | return 0; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | // __builtin_va_arg(expr, type) |
| 560 | virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc, |
| 561 | ExprTy *expr, TypeTy *type, |
| 562 | SourceLocation RPLoc) { |
| 563 | llvm::cout << __FUNCTION__ << "\n"; |
| 564 | return 0; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 565 | } |
| 566 | }; |
| 567 | } |
| 568 | |
Steve Naroff | b4292f2 | 2007-10-31 20:55:39 +0000 | [diff] [blame] | 569 | MinimalAction *clang::CreatePrintParserActionsAction(IdentifierTable &IT) { |
| 570 | return new ParserPrintActions(IT); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 571 | } |