Shih-wei Liao | f8fd82b | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 1 | //===--- PrintParserActions.cpp - Implement -parse-print-callbacks mode ---===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 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/Frontend/Utils.h" |
| 16 | #include "clang/Parse/Action.h" |
| 17 | #include "clang/Parse/DeclSpec.h" |
| 18 | #include "llvm/Support/raw_ostream.h" |
| 19 | using namespace clang; |
| 20 | |
| 21 | namespace { |
| 22 | class ParserPrintActions : public MinimalAction { |
| 23 | llvm::raw_ostream& Out; |
| 24 | |
| 25 | public: |
| 26 | ParserPrintActions(Preprocessor &PP, llvm::raw_ostream& OS) |
| 27 | : MinimalAction(PP), Out(OS) {} |
| 28 | |
| 29 | // Printing Functions which also must call MinimalAction |
| 30 | |
| 31 | /// ActOnDeclarator - This callback is invoked when a declarator is parsed |
| 32 | /// and 'Init' specifies the initializer if any. This is for things like: |
| 33 | /// "int X = 4" or "typedef int foo". |
| 34 | virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) { |
| 35 | Out << __FUNCTION__ << " "; |
| 36 | if (IdentifierInfo *II = D.getIdentifier()) { |
| 37 | Out << "'" << II->getName() << "'"; |
| 38 | } else { |
| 39 | Out << "<anon>"; |
| 40 | } |
| 41 | Out << "\n"; |
| 42 | |
| 43 | // Pass up to EmptyActions so that the symbol table is maintained right. |
| 44 | return MinimalAction::ActOnDeclarator(S, D); |
| 45 | } |
| 46 | /// ActOnPopScope - This callback is called immediately before the specified |
| 47 | /// scope is popped and deleted. |
| 48 | virtual void ActOnPopScope(SourceLocation Loc, Scope *S) { |
| 49 | Out << __FUNCTION__ << "\n"; |
| 50 | return MinimalAction::ActOnPopScope(Loc, S); |
| 51 | } |
| 52 | |
| 53 | /// ActOnTranslationUnitScope - This callback is called once, immediately |
| 54 | /// after creating the translation unit scope (in Parser::Initialize). |
| 55 | virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { |
| 56 | Out << __FUNCTION__ << "\n"; |
| 57 | MinimalAction::ActOnTranslationUnitScope(Loc, S); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | Action::DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc, |
| 62 | IdentifierInfo *ClassName, |
| 63 | SourceLocation ClassLoc, |
| 64 | IdentifierInfo *SuperName, |
| 65 | SourceLocation SuperLoc, |
| 66 | const DeclPtrTy *ProtoRefs, |
| 67 | unsigned NumProtocols, |
| 68 | const SourceLocation *ProtoLocs, |
| 69 | SourceLocation EndProtoLoc, |
| 70 | AttributeList *AttrList) { |
| 71 | Out << __FUNCTION__ << "\n"; |
| 72 | return MinimalAction::ActOnStartClassInterface(AtInterfaceLoc, |
| 73 | ClassName, ClassLoc, |
| 74 | SuperName, SuperLoc, |
| 75 | ProtoRefs, NumProtocols, |
| 76 | ProtoLocs, EndProtoLoc, |
| 77 | AttrList); |
| 78 | } |
| 79 | |
| 80 | /// ActOnForwardClassDeclaration - |
| 81 | /// Scope will always be top level file scope. |
| 82 | Action::DeclPtrTy ActOnForwardClassDeclaration(SourceLocation AtClassLoc, |
| 83 | IdentifierInfo **IdentList, |
| 84 | SourceLocation *IdentLocs, |
| 85 | unsigned NumElts) { |
| 86 | Out << __FUNCTION__ << "\n"; |
| 87 | return MinimalAction::ActOnForwardClassDeclaration(AtClassLoc, IdentList, |
| 88 | IdentLocs, NumElts); |
| 89 | } |
| 90 | |
| 91 | // Pure Printing |
| 92 | |
| 93 | /// ActOnParamDeclarator - This callback is invoked when a parameter |
| 94 | /// declarator is parsed. This callback only occurs for functions |
| 95 | /// with prototypes. S is the function prototype scope for the |
| 96 | /// parameters (C++ [basic.scope.proto]). |
| 97 | virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) { |
| 98 | Out << __FUNCTION__ << " "; |
| 99 | if (IdentifierInfo *II = D.getIdentifier()) { |
| 100 | Out << "'" << II->getName() << "'"; |
| 101 | } else { |
| 102 | Out << "<anon>"; |
| 103 | } |
| 104 | Out << "\n"; |
| 105 | return DeclPtrTy(); |
| 106 | } |
| 107 | |
| 108 | /// AddInitializerToDecl - This action is called immediately after |
| 109 | /// ParseDeclarator (when an initializer is present). The code is factored |
| 110 | /// this way to make sure we are able to handle the following: |
| 111 | /// void func() { int xx = xx; } |
| 112 | /// This allows ActOnDeclarator to register "xx" prior to parsing the |
| 113 | /// initializer. The declaration above should still result in a warning, |
| 114 | /// since the reference to "xx" is uninitialized. |
| 115 | virtual void AddInitializerToDecl(DeclPtrTy Dcl, ExprArg Init) { |
| 116 | Out << __FUNCTION__ << "\n"; |
| 117 | } |
| 118 | |
| 119 | /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, |
| 120 | /// this gives the actions implementation a chance to process the group as |
| 121 | /// a whole. |
| 122 | virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS, |
| 123 | DeclPtrTy *Group, |
| 124 | unsigned NumDecls) { |
| 125 | Out << __FUNCTION__ << "\n"; |
| 126 | return DeclGroupPtrTy(); |
| 127 | } |
| 128 | |
| 129 | /// ActOnStartOfFunctionDef - This is called at the start of a function |
| 130 | /// definition, instead of calling ActOnDeclarator. The Declarator includes |
| 131 | /// information about formal arguments that are part of this function. |
| 132 | virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, |
| 133 | Declarator &D){ |
| 134 | Out << __FUNCTION__ << "\n"; |
| 135 | return DeclPtrTy(); |
| 136 | } |
| 137 | |
| 138 | /// ActOnStartOfFunctionDef - This is called at the start of a function |
| 139 | /// definition, after the FunctionDecl has already been created. |
| 140 | virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { |
| 141 | Out << __FUNCTION__ << "\n"; |
| 142 | return DeclPtrTy(); |
| 143 | } |
| 144 | |
| 145 | virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) { |
| 146 | Out << __FUNCTION__ << "\n"; |
| 147 | } |
| 148 | |
| 149 | /// ActOnFunctionDefBody - This is called when a function body has completed |
| 150 | /// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef. |
| 151 | virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body) { |
| 152 | Out << __FUNCTION__ << "\n"; |
| 153 | return DeclPtrTy(); |
| 154 | } |
| 155 | |
| 156 | virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, |
| 157 | ExprArg AsmString) { |
| 158 | Out << __FUNCTION__ << "\n"; |
| 159 | return DeclPtrTy(); |
| 160 | } |
| 161 | |
| 162 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 163 | /// no declarator (e.g. "struct foo;") is parsed. |
| 164 | virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) { |
| 165 | Out << __FUNCTION__ << "\n"; |
| 166 | return DeclPtrTy(); |
| 167 | } |
| 168 | |
| 169 | /// ActOnLinkageSpec - Parsed a C++ linkage-specification that |
| 170 | /// contained braces. Lang/StrSize contains the language string that |
| 171 | /// was parsed at location Loc. Decls/NumDecls provides the |
| 172 | /// declarations parsed inside the linkage specification. |
| 173 | virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc, |
| 174 | SourceLocation LBrace, |
| 175 | SourceLocation RBrace, const char *Lang, |
| 176 | unsigned StrSize, |
| 177 | DeclPtrTy *Decls, unsigned NumDecls) { |
| 178 | Out << __FUNCTION__ << "\n"; |
| 179 | return DeclPtrTy(); |
| 180 | } |
| 181 | |
| 182 | /// ActOnLinkageSpec - Parsed a C++ linkage-specification without |
| 183 | /// braces. Lang/StrSize contains the language string that was |
| 184 | /// parsed at location Loc. D is the declaration parsed. |
| 185 | virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc, const char *Lang, |
| 186 | unsigned StrSize, DeclPtrTy D) { |
| 187 | return DeclPtrTy(); |
| 188 | } |
| 189 | |
| 190 | //===------------------------------------------------------------------===// |
| 191 | // Type Parsing Callbacks. |
| 192 | //===------------------------------------------------------------------===// |
| 193 | |
| 194 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) { |
| 195 | Out << __FUNCTION__ << "\n"; |
| 196 | return TypeResult(); |
| 197 | } |
| 198 | |
| 199 | virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, |
| 200 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 201 | IdentifierInfo *Name, SourceLocation NameLoc, |
| 202 | AttributeList *Attr, AccessSpecifier AS, |
| 203 | MultiTemplateParamsArg TemplateParameterLists, |
| 204 | bool &OwnedDecl, bool &IsDependent) { |
| 205 | // TagType is an instance of DeclSpec::TST, indicating what kind of tag this |
| 206 | // is (struct/union/enum/class). |
| 207 | Out << __FUNCTION__ << "\n"; |
| 208 | return DeclPtrTy(); |
| 209 | } |
| 210 | |
| 211 | /// Act on @defs() element found when parsing a structure. ClassName is the |
| 212 | /// name of the referenced class. |
| 213 | virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart, |
| 214 | IdentifierInfo *ClassName, |
| 215 | llvm::SmallVectorImpl<DeclPtrTy> &Decls) { |
| 216 | Out << __FUNCTION__ << "\n"; |
| 217 | } |
| 218 | |
| 219 | virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD, |
| 220 | SourceLocation DeclStart, |
| 221 | Declarator &D, ExprTy *BitfieldWidth) { |
| 222 | Out << __FUNCTION__ << "\n"; |
| 223 | return DeclPtrTy(); |
| 224 | } |
| 225 | |
| 226 | virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart, |
| 227 | DeclPtrTy IntfDecl, |
| 228 | Declarator &D, ExprTy *BitfieldWidth, |
| 229 | tok::ObjCKeywordKind visibility) { |
| 230 | Out << __FUNCTION__ << "\n"; |
| 231 | return DeclPtrTy(); |
| 232 | } |
| 233 | |
| 234 | virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl, |
| 235 | DeclPtrTy *Fields, unsigned NumFields, |
| 236 | SourceLocation LBrac, SourceLocation RBrac, |
| 237 | AttributeList *AttrList) { |
| 238 | Out << __FUNCTION__ << "\n"; |
| 239 | } |
| 240 | |
| 241 | virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl, |
| 242 | DeclPtrTy LastEnumConstant, |
| 243 | SourceLocation IdLoc,IdentifierInfo *Id, |
| 244 | SourceLocation EqualLoc, ExprTy *Val) { |
| 245 | Out << __FUNCTION__ << "\n"; |
| 246 | return DeclPtrTy(); |
| 247 | } |
| 248 | |
| 249 | virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, |
| 250 | SourceLocation RBraceLoc, DeclPtrTy EnumDecl, |
| 251 | DeclPtrTy *Elements, unsigned NumElements, |
| 252 | Scope *S, AttributeList *AttrList) { |
| 253 | Out << __FUNCTION__ << "\n"; |
| 254 | } |
| 255 | |
| 256 | //===------------------------------------------------------------------===// |
| 257 | // Statement Parsing Callbacks. |
| 258 | //===------------------------------------------------------------------===// |
| 259 | |
| 260 | virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc) { |
| 261 | Out << __FUNCTION__ << "\n"; |
| 262 | return StmtEmpty(); |
| 263 | } |
| 264 | |
| 265 | virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, |
| 266 | SourceLocation R, |
| 267 | MultiStmtArg Elts, |
| 268 | bool isStmtExpr) { |
| 269 | Out << __FUNCTION__ << "\n"; |
| 270 | return StmtEmpty(); |
| 271 | } |
| 272 | virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, |
| 273 | SourceLocation StartLoc, |
| 274 | SourceLocation EndLoc) { |
| 275 | Out << __FUNCTION__ << "\n"; |
| 276 | return StmtEmpty(); |
| 277 | } |
| 278 | |
| 279 | virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) { |
| 280 | Out << __FUNCTION__ << "\n"; |
| 281 | return OwningStmtResult(*this, Expr->release()); |
| 282 | } |
| 283 | |
| 284 | /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, |
| 285 | /// which can specify an RHS value. |
| 286 | virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, |
| 287 | ExprArg LHSVal, |
| 288 | SourceLocation DotDotDotLoc, |
| 289 | ExprArg RHSVal, |
| 290 | SourceLocation ColonLoc) { |
| 291 | Out << __FUNCTION__ << "\n"; |
| 292 | return StmtEmpty(); |
| 293 | } |
| 294 | virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
| 295 | SourceLocation ColonLoc, |
| 296 | StmtArg SubStmt, Scope *CurScope){ |
| 297 | Out << __FUNCTION__ << "\n"; |
| 298 | return StmtEmpty(); |
| 299 | } |
| 300 | |
| 301 | virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc, |
| 302 | IdentifierInfo *II, |
| 303 | SourceLocation ColonLoc, |
| 304 | StmtArg SubStmt) { |
| 305 | Out << __FUNCTION__ << "\n"; |
| 306 | return StmtEmpty(); |
| 307 | } |
| 308 | |
| 309 | virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, |
| 310 | FullExprArg CondVal, DeclPtrTy CondVar, |
| 311 | StmtArg ThenVal, |
| 312 | SourceLocation ElseLoc, |
| 313 | StmtArg ElseVal) { |
| 314 | Out << __FUNCTION__ << "\n"; |
| 315 | return StmtEmpty(); |
| 316 | } |
| 317 | |
| 318 | virtual OwningStmtResult ActOnStartOfSwitchStmt(FullExprArg Cond, |
| 319 | DeclPtrTy CondVar) { |
| 320 | Out << __FUNCTION__ << "\n"; |
| 321 | return StmtEmpty(); |
| 322 | } |
| 323 | |
| 324 | virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, |
| 325 | StmtArg Switch, |
| 326 | StmtArg Body) { |
| 327 | Out << __FUNCTION__ << "\n"; |
| 328 | return StmtEmpty(); |
| 329 | } |
| 330 | |
| 331 | virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, |
| 332 | FullExprArg Cond, DeclPtrTy CondVar, |
| 333 | StmtArg Body) { |
| 334 | Out << __FUNCTION__ << "\n"; |
| 335 | return StmtEmpty(); |
| 336 | } |
| 337 | virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, |
| 338 | SourceLocation WhileLoc, |
| 339 | SourceLocation LPLoc, ExprArg Cond, |
| 340 | SourceLocation RPLoc){ |
| 341 | Out << __FUNCTION__ << "\n"; |
| 342 | return StmtEmpty(); |
| 343 | } |
| 344 | virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc, |
| 345 | SourceLocation LParenLoc, |
| 346 | StmtArg First, FullExprArg Second, |
| 347 | DeclPtrTy SecondVar, |
| 348 | FullExprArg Third, |
| 349 | SourceLocation RParenLoc, |
| 350 | StmtArg Body) { |
| 351 | Out << __FUNCTION__ << "\n"; |
| 352 | return StmtEmpty(); |
| 353 | } |
| 354 | virtual OwningStmtResult ActOnObjCForCollectionStmt( |
| 355 | SourceLocation ForColLoc, |
| 356 | SourceLocation LParenLoc, |
| 357 | StmtArg First, ExprArg Second, |
| 358 | SourceLocation RParenLoc, StmtArg Body) { |
| 359 | Out << __FUNCTION__ << "\n"; |
| 360 | return StmtEmpty(); |
| 361 | } |
| 362 | virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
| 363 | SourceLocation LabelLoc, |
| 364 | IdentifierInfo *LabelII) { |
| 365 | Out << __FUNCTION__ << "\n"; |
| 366 | return StmtEmpty(); |
| 367 | } |
| 368 | virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
| 369 | SourceLocation StarLoc, |
| 370 | ExprArg DestExp) { |
| 371 | Out << __FUNCTION__ << "\n"; |
| 372 | return StmtEmpty(); |
| 373 | } |
| 374 | virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
| 375 | Scope *CurScope) { |
| 376 | Out << __FUNCTION__ << "\n"; |
| 377 | return StmtEmpty(); |
| 378 | } |
| 379 | virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc, |
| 380 | Scope *CurScope) { |
| 381 | Out << __FUNCTION__ << "\n"; |
| 382 | return StmtEmpty(); |
| 383 | } |
| 384 | virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
| 385 | ExprArg RetValExp) { |
| 386 | Out << __FUNCTION__ << "\n"; |
| 387 | return StmtEmpty(); |
| 388 | } |
| 389 | virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc, |
| 390 | bool IsSimple, |
| 391 | bool IsVolatile, |
| 392 | unsigned NumOutputs, |
| 393 | unsigned NumInputs, |
| 394 | IdentifierInfo **Names, |
| 395 | MultiExprArg Constraints, |
| 396 | MultiExprArg Exprs, |
| 397 | ExprArg AsmString, |
| 398 | MultiExprArg Clobbers, |
| 399 | SourceLocation RParenLoc, |
| 400 | bool MSAsm) { |
| 401 | Out << __FUNCTION__ << "\n"; |
| 402 | return StmtEmpty(); |
| 403 | } |
| 404 | |
| 405 | // Objective-c statements |
| 406 | virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, |
| 407 | SourceLocation RParen, |
| 408 | DeclPtrTy Parm, StmtArg Body, |
| 409 | StmtArg CatchList) { |
| 410 | Out << __FUNCTION__ << "\n"; |
| 411 | return StmtEmpty(); |
| 412 | } |
| 413 | |
| 414 | virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, |
| 415 | StmtArg Body) { |
| 416 | Out << __FUNCTION__ << "\n"; |
| 417 | return StmtEmpty(); |
| 418 | } |
| 419 | |
| 420 | virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, |
| 421 | StmtArg Try, StmtArg Catch, |
| 422 | StmtArg Finally) { |
| 423 | Out << __FUNCTION__ << "\n"; |
| 424 | return StmtEmpty(); |
| 425 | } |
| 426 | |
| 427 | virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, |
| 428 | ExprArg Throw, |
| 429 | Scope *CurScope) { |
| 430 | Out << __FUNCTION__ << "\n"; |
| 431 | return StmtEmpty(); |
| 432 | } |
| 433 | |
| 434 | virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| 435 | ExprArg SynchExpr, |
| 436 | StmtArg SynchBody) { |
| 437 | Out << __FUNCTION__ << "\n"; |
| 438 | return StmtEmpty(); |
| 439 | } |
| 440 | |
| 441 | // C++ Statements |
| 442 | virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D) { |
| 443 | Out << __FUNCTION__ << "\n"; |
| 444 | return DeclPtrTy(); |
| 445 | } |
| 446 | |
| 447 | virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, |
| 448 | DeclPtrTy ExceptionDecl, |
| 449 | StmtArg HandlerBlock) { |
| 450 | Out << __FUNCTION__ << "\n"; |
| 451 | return StmtEmpty(); |
| 452 | } |
| 453 | |
| 454 | virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc, |
| 455 | StmtArg TryBlock, |
| 456 | MultiStmtArg Handlers) { |
| 457 | Out << __FUNCTION__ << "\n"; |
| 458 | return StmtEmpty(); |
| 459 | } |
| 460 | |
| 461 | //===------------------------------------------------------------------===// |
| 462 | // Expression Parsing Callbacks. |
| 463 | //===------------------------------------------------------------------===// |
| 464 | |
| 465 | // Primary Expressions. |
| 466 | |
| 467 | /// ActOnIdentifierExpr - Parse an identifier in expression context. |
| 468 | /// 'HasTrailingLParen' indicates whether or not the identifier has a '(' |
| 469 | /// token immediately after it. |
| 470 | virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc, |
| 471 | IdentifierInfo &II, |
| 472 | bool HasTrailingLParen, |
| 473 | const CXXScopeSpec *SS, |
| 474 | bool isAddressOfOperand) { |
| 475 | Out << __FUNCTION__ << "\n"; |
| 476 | return ExprEmpty(); |
| 477 | } |
| 478 | |
| 479 | virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr( |
| 480 | Scope *S, SourceLocation OperatorLoc, |
| 481 | OverloadedOperatorKind Op, |
| 482 | bool HasTrailingLParen, const CXXScopeSpec &SS, |
| 483 | bool isAddressOfOperand) { |
| 484 | Out << __FUNCTION__ << "\n"; |
| 485 | return ExprEmpty(); |
| 486 | } |
| 487 | |
| 488 | virtual OwningExprResult ActOnCXXConversionFunctionExpr( |
| 489 | Scope *S, SourceLocation OperatorLoc, |
| 490 | TypeTy *Type, bool HasTrailingLParen, |
| 491 | const CXXScopeSpec &SS,bool isAddressOfOperand) { |
| 492 | Out << __FUNCTION__ << "\n"; |
| 493 | return ExprEmpty(); |
| 494 | } |
| 495 | |
| 496 | virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc, |
| 497 | tok::TokenKind Kind) { |
| 498 | Out << __FUNCTION__ << "\n"; |
| 499 | return ExprEmpty(); |
| 500 | } |
| 501 | |
| 502 | virtual OwningExprResult ActOnCharacterConstant(const Token &) { |
| 503 | Out << __FUNCTION__ << "\n"; |
| 504 | return ExprEmpty(); |
| 505 | } |
| 506 | |
| 507 | virtual OwningExprResult ActOnNumericConstant(const Token &) { |
| 508 | Out << __FUNCTION__ << "\n"; |
| 509 | return ExprEmpty(); |
| 510 | } |
| 511 | |
| 512 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
| 513 | /// fragments (e.g. "foo" "bar" L"baz"). |
| 514 | virtual OwningExprResult ActOnStringLiteral(const Token *Toks, |
| 515 | unsigned NumToks) { |
| 516 | Out << __FUNCTION__ << "\n"; |
| 517 | return ExprEmpty(); |
| 518 | } |
| 519 | |
| 520 | virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
| 521 | ExprArg Val) { |
| 522 | Out << __FUNCTION__ << "\n"; |
| 523 | return move(Val); // Default impl returns operand. |
| 524 | } |
| 525 | |
| 526 | // Postfix Expressions. |
| 527 | virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, |
| 528 | tok::TokenKind Kind, |
| 529 | ExprArg Input) { |
| 530 | Out << __FUNCTION__ << "\n"; |
| 531 | return ExprEmpty(); |
| 532 | } |
| 533 | virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base, |
| 534 | SourceLocation LLoc, |
| 535 | ExprArg Idx, |
| 536 | SourceLocation RLoc) { |
| 537 | Out << __FUNCTION__ << "\n"; |
| 538 | return ExprEmpty(); |
| 539 | } |
| 540 | virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base, |
| 541 | SourceLocation OpLoc, |
| 542 | tok::TokenKind OpKind, |
| 543 | SourceLocation MemberLoc, |
| 544 | IdentifierInfo &Member, |
| 545 | DeclPtrTy ImplDecl, |
| 546 | const CXXScopeSpec *SS=0) { |
| 547 | Out << __FUNCTION__ << "\n"; |
| 548 | return ExprEmpty(); |
| 549 | } |
| 550 | |
| 551 | virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn, |
| 552 | SourceLocation LParenLoc, |
| 553 | MultiExprArg Args, |
| 554 | SourceLocation *CommaLocs, |
| 555 | SourceLocation RParenLoc) { |
| 556 | Out << __FUNCTION__ << "\n"; |
| 557 | return ExprEmpty(); |
| 558 | } |
| 559 | |
| 560 | // Unary Operators. 'Tok' is the token for the operator. |
| 561 | virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, |
| 562 | tok::TokenKind Op, ExprArg Input) { |
| 563 | Out << __FUNCTION__ << "\n"; |
| 564 | return ExprEmpty(); |
| 565 | } |
| 566 | virtual OwningExprResult |
| 567 | ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, |
| 568 | void *TyOrEx, const SourceRange &ArgRange) { |
| 569 | Out << __FUNCTION__ << "\n"; |
| 570 | return ExprEmpty(); |
| 571 | } |
| 572 | |
| 573 | virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen, |
| 574 | TypeTy *Ty, |
| 575 | SourceLocation RParen, |
| 576 | ExprArg Op) { |
| 577 | Out << __FUNCTION__ << "\n"; |
| 578 | return ExprEmpty(); |
| 579 | } |
| 580 | virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc, |
| 581 | MultiExprArg InitList, |
| 582 | SourceLocation RParenLoc) { |
| 583 | Out << __FUNCTION__ << "\n"; |
| 584 | return ExprEmpty(); |
| 585 | } |
| 586 | virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, |
| 587 | TypeTy *Ty, SourceLocation RParenLoc, |
| 588 | ExprArg Op) { |
| 589 | Out << __FUNCTION__ << "\n"; |
| 590 | return ExprEmpty(); |
| 591 | } |
| 592 | |
| 593 | virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, |
| 594 | tok::TokenKind Kind, |
| 595 | ExprArg LHS, ExprArg RHS) { |
| 596 | Out << __FUNCTION__ << "\n"; |
| 597 | return ExprEmpty(); |
| 598 | } |
| 599 | |
| 600 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
| 601 | /// in the case of a the GNU conditional expr extension. |
| 602 | virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
| 603 | SourceLocation ColonLoc, |
| 604 | ExprArg Cond, ExprArg LHS, |
| 605 | ExprArg RHS) { |
| 606 | Out << __FUNCTION__ << "\n"; |
| 607 | return ExprEmpty(); |
| 608 | } |
| 609 | |
| 610 | //===--------------------- GNU Extension Expressions ------------------===// |
| 611 | |
| 612 | virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc, |
| 613 | SourceLocation LabLoc, |
| 614 | IdentifierInfo *LabelII) {// "&&foo" |
| 615 | Out << __FUNCTION__ << "\n"; |
| 616 | return ExprEmpty(); |
| 617 | } |
| 618 | |
| 619 | virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, |
| 620 | StmtArg SubStmt, |
| 621 | SourceLocation RPLoc) { // "({..})" |
| 622 | Out << __FUNCTION__ << "\n"; |
| 623 | return ExprEmpty(); |
| 624 | } |
| 625 | |
| 626 | virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S, |
| 627 | SourceLocation BuiltinLoc, |
| 628 | SourceLocation TypeLoc, |
| 629 | TypeTy *Arg1, |
| 630 | OffsetOfComponent *CompPtr, |
| 631 | unsigned NumComponents, |
| 632 | SourceLocation RParenLoc) { |
| 633 | Out << __FUNCTION__ << "\n"; |
| 634 | return ExprEmpty(); |
| 635 | } |
| 636 | |
| 637 | // __builtin_types_compatible_p(type1, type2) |
| 638 | virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
| 639 | TypeTy *arg1,TypeTy *arg2, |
| 640 | SourceLocation RPLoc) { |
| 641 | Out << __FUNCTION__ << "\n"; |
| 642 | return ExprEmpty(); |
| 643 | } |
| 644 | // __builtin_choose_expr(constExpr, expr1, expr2) |
| 645 | virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
| 646 | ExprArg cond, ExprArg expr1, |
| 647 | ExprArg expr2, |
| 648 | SourceLocation RPLoc) { |
| 649 | Out << __FUNCTION__ << "\n"; |
| 650 | return ExprEmpty(); |
| 651 | } |
| 652 | |
| 653 | // __builtin_va_arg(expr, type) |
| 654 | virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc, |
| 655 | ExprArg expr, TypeTy *type, |
| 656 | SourceLocation RPLoc) { |
| 657 | Out << __FUNCTION__ << "\n"; |
| 658 | return ExprEmpty(); |
| 659 | } |
| 660 | |
| 661 | virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc) { |
| 662 | Out << __FUNCTION__ << "\n"; |
| 663 | return ExprEmpty(); |
| 664 | } |
| 665 | |
| 666 | virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope) { |
| 667 | Out << __FUNCTION__ << "\n"; |
| 668 | } |
| 669 | |
| 670 | virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { |
| 671 | Out << __FUNCTION__ << "\n"; |
| 672 | } |
| 673 | |
| 674 | virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) { |
| 675 | Out << __FUNCTION__ << "\n"; |
| 676 | } |
| 677 | |
| 678 | virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, |
| 679 | StmtArg Body, |
| 680 | Scope *CurScope) { |
| 681 | Out << __FUNCTION__ << "\n"; |
| 682 | return ExprEmpty(); |
| 683 | } |
| 684 | |
| 685 | virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc, |
| 686 | IdentifierInfo *Ident, |
| 687 | SourceLocation LBrace, |
| 688 | AttributeList *AttrList) { |
| 689 | Out << __FUNCTION__ << "\n"; |
| 690 | return DeclPtrTy(); |
| 691 | } |
| 692 | |
| 693 | virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace) { |
| 694 | Out << __FUNCTION__ << "\n"; |
| 695 | return; |
| 696 | } |
| 697 | |
| 698 | #if 0 |
| 699 | // FIXME: AttrList should be deleted by this function, but the definition |
| 700 | // would have to be available. |
| 701 | virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope, |
| 702 | SourceLocation UsingLoc, |
| 703 | SourceLocation NamespcLoc, |
| 704 | const CXXScopeSpec &SS, |
| 705 | SourceLocation IdentLoc, |
| 706 | IdentifierInfo *NamespcName, |
| 707 | AttributeList *AttrList) { |
| 708 | Out << __FUNCTION__ << "\n"; |
| 709 | return DeclPtrTy(); |
| 710 | } |
| 711 | #endif |
| 712 | |
| 713 | virtual void ActOnParamDefaultArgument(DeclPtrTy param, |
| 714 | SourceLocation EqualLoc, |
| 715 | ExprArg defarg) { |
| 716 | Out << __FUNCTION__ << "\n"; |
| 717 | } |
| 718 | |
| 719 | virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, |
| 720 | SourceLocation EqualLoc, |
| 721 | SourceLocation ArgLoc) { |
| 722 | Out << __FUNCTION__ << "\n"; |
| 723 | } |
| 724 | |
| 725 | virtual void ActOnParamDefaultArgumentError(DeclPtrTy param) { |
| 726 | Out << __FUNCTION__ << "\n"; |
| 727 | } |
| 728 | |
| 729 | virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, |
| 730 | SourceLocation LParenLoc, |
| 731 | MultiExprArg Exprs, |
| 732 | SourceLocation *CommaLocs, |
| 733 | SourceLocation RParenLoc) { |
| 734 | Out << __FUNCTION__ << "\n"; |
| 735 | return; |
| 736 | } |
| 737 | |
| 738 | virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, |
| 739 | DeclPtrTy Method) { |
| 740 | Out << __FUNCTION__ << "\n"; |
| 741 | } |
| 742 | |
| 743 | virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param) { |
| 744 | Out << __FUNCTION__ << "\n"; |
| 745 | } |
| 746 | |
| 747 | virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, |
| 748 | DeclPtrTy Method) { |
| 749 | Out << __FUNCTION__ << "\n"; |
| 750 | } |
| 751 | |
| 752 | virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc, |
| 753 | ExprArg AssertExpr, |
| 754 | ExprArg AssertMessageExpr) { |
| 755 | Out << __FUNCTION__ << "\n"; |
| 756 | return DeclPtrTy(); |
| 757 | } |
| 758 | |
| 759 | virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc, |
| 760 | tok::TokenKind Kind, |
| 761 | SourceLocation LAngleBracketLoc, |
| 762 | TypeTy *Ty, |
| 763 | SourceLocation RAngleBracketLoc, |
| 764 | SourceLocation LParenLoc, |
| 765 | ExprArg Op, |
| 766 | SourceLocation RParenLoc) { |
| 767 | Out << __FUNCTION__ << "\n"; |
| 768 | return ExprEmpty(); |
| 769 | } |
| 770 | |
| 771 | virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc, |
| 772 | SourceLocation LParenLoc, |
| 773 | bool isType, void *TyOrExpr, |
| 774 | SourceLocation RParenLoc) { |
| 775 | Out << __FUNCTION__ << "\n"; |
| 776 | return ExprEmpty(); |
| 777 | } |
| 778 | |
| 779 | virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc) { |
| 780 | Out << __FUNCTION__ << "\n"; |
| 781 | return ExprEmpty(); |
| 782 | } |
| 783 | |
| 784 | virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, |
| 785 | tok::TokenKind Kind) { |
| 786 | Out << __FUNCTION__ << "\n"; |
| 787 | return ExprEmpty(); |
| 788 | } |
| 789 | |
| 790 | virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc, ExprArg Op) { |
| 791 | Out << __FUNCTION__ << "\n"; |
| 792 | return ExprEmpty(); |
| 793 | } |
| 794 | |
| 795 | virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange, |
| 796 | TypeTy *TypeRep, |
| 797 | SourceLocation LParenLoc, |
| 798 | MultiExprArg Exprs, |
| 799 | SourceLocation *CommaLocs, |
| 800 | SourceLocation RParenLoc) { |
| 801 | Out << __FUNCTION__ << "\n"; |
| 802 | return ExprEmpty(); |
| 803 | } |
| 804 | |
| 805 | virtual OwningExprResult ActOnCXXConditionDeclarationExpr(Scope *S, |
| 806 | SourceLocation StartLoc, |
| 807 | Declarator &D, |
| 808 | SourceLocation EqualLoc, |
| 809 | ExprArg AssignExprVal) { |
| 810 | Out << __FUNCTION__ << "\n"; |
| 811 | return ExprEmpty(); |
| 812 | } |
| 813 | |
| 814 | virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, |
| 815 | bool UseGlobal, |
| 816 | SourceLocation PlacementLParen, |
| 817 | MultiExprArg PlacementArgs, |
| 818 | SourceLocation PlacementRParen, |
| 819 | bool ParenTypeId, Declarator &D, |
| 820 | SourceLocation ConstructorLParen, |
| 821 | MultiExprArg ConstructorArgs, |
| 822 | SourceLocation ConstructorRParen) { |
| 823 | Out << __FUNCTION__ << "\n"; |
| 824 | return ExprEmpty(); |
| 825 | } |
| 826 | |
| 827 | virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc, |
| 828 | bool UseGlobal, bool ArrayForm, |
| 829 | ExprArg Operand) { |
| 830 | Out << __FUNCTION__ << "\n"; |
| 831 | return ExprEmpty(); |
| 832 | } |
| 833 | |
| 834 | virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, |
| 835 | SourceLocation KWLoc, |
| 836 | SourceLocation LParen, |
| 837 | TypeTy *Ty, |
| 838 | SourceLocation RParen) { |
| 839 | Out << __FUNCTION__ << "\n"; |
| 840 | return ExprEmpty(); |
| 841 | } |
| 842 | }; |
| 843 | } |
| 844 | |
| 845 | MinimalAction *clang::CreatePrintParserActionsAction(Preprocessor &PP, |
| 846 | llvm::raw_ostream* OS) { |
| 847 | return new ParserPrintActions(PP, *OS); |
| 848 | } |