clang API Documentation
00001 //===--- Action.h - Parser Action Interface ---------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the Action and EmptyAction interface. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_PARSE_ACTION_H 00015 #define LLVM_CLANG_PARSE_ACTION_H 00016 00017 #include "clang/Basic/IdentifierTable.h" 00018 #include "clang/Basic/SourceLocation.h" 00019 #include "clang/Basic/Specifiers.h" 00020 #include "clang/Basic/TemplateKinds.h" 00021 #include "clang/Basic/TypeTraits.h" 00022 #include "clang/Parse/DeclSpec.h" 00023 #include "clang/Parse/Ownership.h" 00024 #include "llvm/Support/PrettyStackTrace.h" 00025 #include "llvm/ADT/PointerUnion.h" 00026 00027 namespace clang { 00028 // Semantic. 00029 class DeclSpec; 00030 class ObjCDeclSpec; 00031 class CXXScopeSpec; 00032 class Declarator; 00033 class AttributeList; 00034 struct FieldDeclarator; 00035 // Parse. 00036 class Scope; 00037 class Action; 00038 class Selector; 00039 class Designation; 00040 class InitListDesignations; 00041 // Lex. 00042 class Preprocessor; 00043 class Token; 00044 00045 // We can re-use the low bit of expression, statement, base, and 00046 // member-initializer pointers for the "invalid" flag of 00047 // ActionResult. 00048 template<> struct IsResultPtrLowBitFree<0> { static const bool value = true;}; 00049 template<> struct IsResultPtrLowBitFree<1> { static const bool value = true;}; 00050 template<> struct IsResultPtrLowBitFree<3> { static const bool value = true;}; 00051 template<> struct IsResultPtrLowBitFree<4> { static const bool value = true;}; 00052 template<> struct IsResultPtrLowBitFree<5> { static const bool value = true;}; 00053 00054 /// Action - As the parser reads the input file and recognizes the productions 00055 /// of the grammar, it invokes methods on this class to turn the parsed input 00056 /// into something useful: e.g. a parse tree. 00057 /// 00058 /// The callback methods that this class provides are phrased as actions that 00059 /// the parser has just done or is about to do when the method is called. They 00060 /// are not requests that the actions module do the specified action. 00061 /// 00062 /// All of the methods here are optional except getTypeName() and 00063 /// isCurrentClassName(), which must be specified in order for the 00064 /// parse to complete accurately. 00065 class Action : public ActionBase { 00066 /// \brief The parser's current scope. 00067 /// 00068 /// The parser maintains this state here so that is accessible to \c Action 00069 /// subclasses via \c getCurScope(). 00070 Scope *CurScope; 00071 00072 protected: 00073 friend class Parser; 00074 00075 /// \brief Retrieve the parser's current scope. 00076 Scope *getCurScope() const { return CurScope; } 00077 00078 public: 00079 Action() : CurScope(0) { } 00080 00081 /// Out-of-line virtual destructor to provide home for this class. 00082 virtual ~Action(); 00083 00084 // Types - Though these don't actually enforce strong typing, they document 00085 // what types are required to be identical for the actions. 00086 typedef ActionBase::ExprTy ExprTy; 00087 typedef ActionBase::StmtTy StmtTy; 00088 00089 /// Expr/Stmt/Type/BaseResult - Provide a unique type to wrap 00090 /// ExprTy/StmtTy/TypeTy/BaseTy, providing strong typing and 00091 /// allowing for failure. 00092 typedef ActionResult<0> ExprResult; 00093 typedef ActionResult<1> StmtResult; 00094 typedef ActionResult<2> TypeResult; 00095 typedef ActionResult<3> BaseResult; 00096 typedef ActionResult<4> MemInitResult; 00097 typedef ActionResult<5, DeclPtrTy> DeclResult; 00098 00099 /// Same, but with ownership. 00100 typedef ASTOwningResult<&ActionBase::DeleteExpr> OwningExprResult; 00101 typedef ASTOwningResult<&ActionBase::DeleteStmt> OwningStmtResult; 00102 // Note that these will replace ExprResult and StmtResult when the transition 00103 // is complete. 00104 00105 /// Single expressions or statements as arguments. 00106 typedef ASTOwningPtr<&ActionBase::DeleteExpr> ExprArg; 00107 typedef ASTOwningPtr<&ActionBase::DeleteStmt> StmtArg; 00108 00109 /// Multiple expressions or statements as arguments. 00110 typedef ASTMultiPtr<&ActionBase::DeleteExpr> MultiExprArg; 00111 typedef ASTMultiPtr<&ActionBase::DeleteStmt> MultiStmtArg; 00112 typedef ASTMultiPtr<&ActionBase::DeleteTemplateParams> MultiTemplateParamsArg; 00113 00114 class FullExprArg { 00115 public: 00116 FullExprArg(ActionBase &actions) : Expr(actions) { } 00117 00118 // FIXME: The const_cast here is ugly. RValue references would make this 00119 // much nicer (or we could duplicate a bunch of the move semantics 00120 // emulation code from Ownership.h). 00121 FullExprArg(const FullExprArg& Other) 00122 : Expr(move(const_cast<FullExprArg&>(Other).Expr)) {} 00123 00124 FullExprArg &operator=(const FullExprArg& Other) { 00125 Expr.operator=(move(const_cast<FullExprArg&>(Other).Expr)); 00126 return *this; 00127 } 00128 00129 OwningExprResult release() { 00130 return move(Expr); 00131 } 00132 00133 ExprArg* operator->() { 00134 return &Expr; 00135 } 00136 00137 private: 00138 // FIXME: No need to make the entire Action class a friend when it's just 00139 // Action::FullExpr that needs access to the constructor below. 00140 friend class Action; 00141 00142 explicit FullExprArg(ExprArg expr) 00143 : Expr(move(expr)) {} 00144 00145 ExprArg Expr; 00146 }; 00147 00148 template<typename T> 00149 FullExprArg MakeFullExpr(T &Arg) { 00150 return FullExprArg(ActOnFinishFullExpr(move(Arg))); 00151 } 00152 00153 // Utilities for Action implementations to return smart results. 00154 00155 OwningExprResult ExprError() { return OwningExprResult(*this, true); } 00156 OwningStmtResult StmtError() { return OwningStmtResult(*this, true); } 00157 00158 OwningExprResult ExprError(const DiagnosticBuilder&) { return ExprError(); } 00159 OwningStmtResult StmtError(const DiagnosticBuilder&) { return StmtError(); } 00160 00161 OwningExprResult ExprEmpty() { return OwningExprResult(*this, false); } 00162 OwningStmtResult StmtEmpty() { return OwningStmtResult(*this, false); } 00163 00164 /// Statistics. 00165 virtual void PrintStats() const {} 00166 00167 /// getDeclName - Return a pretty name for the specified decl if possible, or 00168 /// an empty string if not. This is used for pretty crash reporting. 00169 virtual std::string getDeclName(DeclPtrTy D) { return ""; } 00170 00171 //===--------------------------------------------------------------------===// 00172 // Declaration Tracking Callbacks. 00173 //===--------------------------------------------------------------------===// 00174 00175 typedef uintptr_t ParsingDeclStackState; 00176 00177 /// PushParsingDeclaration - Notes that the parser has begun 00178 /// processing a declaration of some sort. Guaranteed to be matched 00179 /// by a call to PopParsingDeclaration with the value returned by 00180 /// this method. 00181 virtual ParsingDeclStackState PushParsingDeclaration() { 00182 return ParsingDeclStackState(); 00183 } 00184 00185 /// PopParsingDeclaration - Notes that the parser has completed 00186 /// processing a declaration of some sort. The decl will be empty 00187 /// if the declaration didn't correspond to a full declaration (or 00188 /// if the actions module returned an empty decl for it). 00189 virtual void PopParsingDeclaration(ParsingDeclStackState S, DeclPtrTy D) { 00190 } 00191 00192 /// ConvertDeclToDeclGroup - If the parser has one decl in a context where it 00193 /// needs a decl group, it calls this to convert between the two 00194 /// representations. 00195 virtual DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr) { 00196 return DeclGroupPtrTy(); 00197 } 00198 00199 virtual void DiagnoseUseOfUnimplementedSelectors() {} 00200 00201 /// getTypeName - Return non-null if the specified identifier is a type name 00202 /// in the current scope. 00203 /// 00204 /// \param II the identifier for which we are performing name lookup 00205 /// 00206 /// \param NameLoc the location of the identifier 00207 /// 00208 /// \param S the scope in which this name lookup occurs 00209 /// 00210 /// \param SS if non-NULL, the C++ scope specifier that precedes the 00211 /// identifier 00212 /// 00213 /// \param isClassName whether this is a C++ class-name production, in 00214 /// which we can end up referring to a member of an unknown specialization 00215 /// that we know (from the grammar) is supposed to be a type. For example, 00216 /// this occurs when deriving from "std::vector<T>::allocator_type", where T 00217 /// is a template parameter. 00218 /// 00219 /// \param ObjectType if we're checking whether an identifier is a type 00220 /// within a C++ member access expression, this will be the type of the 00221 /// 00222 /// \returns the type referred to by this identifier, or NULL if the type 00223 /// does not name an identifier. 00224 virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc, 00225 Scope *S, CXXScopeSpec *SS = 0, 00226 bool isClassName = false, 00227 TypeTy *ObjectType = 0) = 0; 00228 00229 /// isTagName() - This method is called *for error recovery purposes only* 00230 /// to determine if the specified name is a valid tag name ("struct foo"). If 00231 /// so, this returns the TST for the tag corresponding to it (TST_enum, 00232 /// TST_union, TST_struct, TST_class). This is used to diagnose cases in C 00233 /// where the user forgot to specify the tag. 00234 virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S) { 00235 return DeclSpec::TST_unspecified; 00236 } 00237 00238 /// \brief Action called as part of error recovery when the parser has 00239 /// determined that the given name must refer to a type, but 00240 /// \c getTypeName() did not return a result. 00241 /// 00242 /// This callback permits the action to give a detailed diagnostic when an 00243 /// unknown type name is encountered and, potentially, to try to recover 00244 /// by producing a new type in \p SuggestedType. 00245 /// 00246 /// \param II the name that should be a type. 00247 /// 00248 /// \param IILoc the location of the name in the source. 00249 /// 00250 /// \param S the scope in which name lookup was performed. 00251 /// 00252 /// \param SS if non-NULL, the C++ scope specifier that preceded the name. 00253 /// 00254 /// \param SuggestedType if the action sets this type to a non-NULL type, 00255 /// the parser will recovery by consuming the type name token and then 00256 /// pretending that the given type was the type it parsed. 00257 /// 00258 /// \returns true if a diagnostic was emitted, false otherwise. When false, 00259 /// the parser itself will emit a generic "unknown type name" diagnostic. 00260 virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II, 00261 SourceLocation IILoc, 00262 Scope *S, 00263 CXXScopeSpec *SS, 00264 TypeTy *&SuggestedType) { 00265 return false; 00266 } 00267 00268 /// isCurrentClassName - Return true if the specified name is the 00269 /// name of the innermost C++ class type currently being defined. 00270 virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S, 00271 const CXXScopeSpec *SS = 0) = 0; 00272 00273 /// \brief Determine whether the given name refers to a template. 00274 /// 00275 /// This callback is used by the parser after it has seen a '<' to determine 00276 /// whether the given name refers to a template and, if so, what kind of 00277 /// template. 00278 /// 00279 /// \param S the scope in which the name occurs. 00280 /// 00281 /// \param SS the C++ nested-name-specifier that precedes the template name, 00282 /// if any. 00283 /// 00284 /// \param hasTemplateKeyword true if the template keyword was specified. 00285 /// 00286 /// \param Name the name that we are querying to determine whether it is 00287 /// a template. 00288 /// 00289 /// \param ObjectType if we are determining whether the given name is a 00290 /// template name in the context of a member access expression (e.g., 00291 /// \c p->X<int>), this is the type of the object referred to by the 00292 /// member access (e.g., \c p). 00293 /// 00294 /// \param EnteringContext whether we are potentially entering the context 00295 /// referred to by the nested-name-specifier \p SS, which allows semantic 00296 /// analysis to look into uninstantiated templates. 00297 /// 00298 /// \param Template if the name does refer to a template, the declaration 00299 /// of the template that the name refers to. 00300 /// 00301 /// \param MemberOfUnknownSpecialization Will be set true if the resulting 00302 /// member would be a member of an unknown specialization, in which case this 00303 /// lookup cannot possibly pass at this time. 00304 /// 00305 /// \returns the kind of template that this name refers to. 00306 virtual TemplateNameKind isTemplateName(Scope *S, 00307 CXXScopeSpec &SS, 00308 bool hasTemplateKeyword, 00309 UnqualifiedId &Name, 00310 TypeTy *ObjectType, 00311 bool EnteringContext, 00312 TemplateTy &Template, 00313 bool &MemberOfUnknownSpecialization) = 0; 00314 00315 /// \brief Action called as part of error recovery when the parser has 00316 /// determined that the given name must refer to a template, but 00317 /// \c isTemplateName() did not return a result. 00318 /// 00319 /// This callback permits the action to give a detailed diagnostic when an 00320 /// unknown template name is encountered and, potentially, to try to recover 00321 /// by producing a new template in \p SuggestedTemplate. 00322 /// 00323 /// \param II the name that should be a template. 00324 /// 00325 /// \param IILoc the location of the name in the source. 00326 /// 00327 /// \param S the scope in which name lookup was performed. 00328 /// 00329 /// \param SS the C++ scope specifier that preceded the name. 00330 /// 00331 /// \param SuggestedTemplate if the action sets this template to a non-NULL, 00332 /// template, the parser will recover by consuming the template name token 00333 /// and the template argument list that follows. 00334 /// 00335 /// \param SuggestedTemplateKind as input, the kind of template that we 00336 /// expect (e.g., \c TNK_Type_template or \c TNK_Function_template). If the 00337 /// action provides a suggested template, this should be set to the kind of 00338 /// template. 00339 /// 00340 /// \returns true if a diagnostic was emitted, false otherwise. When false, 00341 /// the parser itself will emit a generic "unknown template name" diagnostic. 00342 virtual bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, 00343 SourceLocation IILoc, 00344 Scope *S, 00345 const CXXScopeSpec *SS, 00346 TemplateTy &SuggestedTemplate, 00347 TemplateNameKind &SuggestedKind) { 00348 return false; 00349 } 00350 00351 /// \brief Determine whether the given name refers to a non-type nested name 00352 /// specifier, e.g., the name of a namespace or namespace alias. 00353 /// 00354 /// This actual is used in the parsing of pseudo-destructor names to 00355 /// distinguish a nested-name-specifier and a "type-name ::" when we 00356 /// see the token sequence "X :: ~". 00357 virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, 00358 SourceLocation IdLoc, 00359 IdentifierInfo &II, 00360 TypeTy *ObjectType) { 00361 return false; 00362 } 00363 00364 /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the 00365 /// global scope ('::'). 00366 virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S, 00367 SourceLocation CCLoc) { 00368 return 0; 00369 } 00370 00371 /// \brief Parsed an identifier followed by '::' in a C++ 00372 /// nested-name-specifier. 00373 /// 00374 /// \param S the scope in which the nested-name-specifier was parsed. 00375 /// 00376 /// \param SS the nested-name-specifier that precedes the identifier. For 00377 /// example, if we are parsing "foo::bar::", \p SS will describe the "foo::" 00378 /// that has already been parsed. 00379 /// 00380 /// \param IdLoc the location of the identifier we have just parsed (e.g., 00381 /// the "bar" in "foo::bar::". 00382 /// 00383 /// \param CCLoc the location of the '::' at the end of the 00384 /// nested-name-specifier. 00385 /// 00386 /// \param II the identifier that represents the scope that this 00387 /// nested-name-specifier refers to, e.g., the "bar" in "foo::bar::". 00388 /// 00389 /// \param ObjectType if this nested-name-specifier occurs as part of a 00390 /// C++ member access expression such as "x->Base::f", the type of the base 00391 /// object (e.g., *x in the example, if "x" were a pointer). 00392 /// 00393 /// \param EnteringContext if true, then we intend to immediately enter the 00394 /// context of this nested-name-specifier, e.g., for an out-of-line 00395 /// definition of a class member. 00396 /// 00397 /// \returns a CXXScopeTy* object representing the C++ scope. 00398 virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, 00399 CXXScopeSpec &SS, 00400 SourceLocation IdLoc, 00401 SourceLocation CCLoc, 00402 IdentifierInfo &II, 00403 TypeTy *ObjectType, 00404 bool EnteringContext) { 00405 return 0; 00406 } 00407 00408 /// IsInvalidUnlessNestedName - This method is used for error recovery 00409 /// purposes to determine whether the specified identifier is only valid as 00410 /// a nested name specifier, for example a namespace name. It is 00411 /// conservatively correct to always return false from this method. 00412 /// 00413 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier. 00414 virtual bool IsInvalidUnlessNestedName(Scope *S, 00415 CXXScopeSpec &SS, 00416 IdentifierInfo &II, 00417 TypeTy *ObjectType, 00418 bool EnteringContext) { 00419 return false; 00420 } 00421 00422 /// ActOnCXXNestedNameSpecifier - Called during parsing of a 00423 /// nested-name-specifier that involves a template-id, e.g., 00424 /// "foo::bar<int, float>::", and now we need to build a scope 00425 /// specifier. \p SS is empty or the previously parsed nested-name 00426 /// part ("foo::"), \p Type is the already-parsed class template 00427 /// specialization (or other template-id that names a type), \p 00428 /// TypeRange is the source range where the type is located, and \p 00429 /// CCLoc is the location of the trailing '::'. 00430 virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, 00431 const CXXScopeSpec &SS, 00432 TypeTy *Type, 00433 SourceRange TypeRange, 00434 SourceLocation CCLoc) { 00435 return 0; 00436 } 00437 00438 /// ShouldEnterDeclaratorScope - Called when a C++ scope specifier 00439 /// is parsed as part of a declarator-id to determine whether a scope 00440 /// should be entered. 00441 /// 00442 /// \param S the current scope 00443 /// \param SS the scope being entered 00444 /// \param isFriendDeclaration whether this is a friend declaration 00445 virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) { 00446 return false; 00447 } 00448 00449 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global 00450 /// scope or nested-name-specifier) is parsed as part of a declarator-id. 00451 /// After this method is called, according to [C++ 3.4.3p3], names should be 00452 /// looked up in the declarator-id's scope, until the declarator is parsed and 00453 /// ActOnCXXExitDeclaratorScope is called. 00454 /// The 'SS' should be a non-empty valid CXXScopeSpec. 00455 /// \returns true if an error occurred, false otherwise. 00456 virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS) { 00457 return false; 00458 } 00459 00460 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously 00461 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same 00462 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. 00463 /// Used to indicate that names should revert to being looked up in the 00464 /// defining scope. 00465 virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS) { 00466 } 00467 00468 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an 00469 /// initializer for the declaration 'Dcl'. 00470 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a 00471 /// static data member of class X, names should be looked up in the scope of 00472 /// class X. 00473 virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl) { 00474 } 00475 00476 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an 00477 /// initializer for the declaration 'Dcl'. 00478 virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl) { 00479 } 00480 00481 /// ActOnDeclarator - This callback is invoked when a declarator is parsed and 00482 /// 'Init' specifies the initializer if any. This is for things like: 00483 /// "int X = 4" or "typedef int foo". 00484 /// 00485 virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) { 00486 return DeclPtrTy(); 00487 } 00488 00489 /// ActOnParamDeclarator - This callback is invoked when a parameter 00490 /// declarator is parsed. This callback only occurs for functions 00491 /// with prototypes. S is the function prototype scope for the 00492 /// parameters (C++ [basic.scope.proto]). 00493 virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) { 00494 return DeclPtrTy(); 00495 } 00496 00497 /// \brief Parsed an exception object declaration within an Objective-C 00498 /// @catch statement. 00499 virtual DeclPtrTy ActOnObjCExceptionDecl(Scope *S, Declarator &D) { 00500 return DeclPtrTy(); 00501 } 00502 00503 /// AddInitializerToDecl - This action is called immediately after 00504 /// ActOnDeclarator (when an initializer is present). The code is factored 00505 /// this way to make sure we are able to handle the following: 00506 /// void func() { int xx = xx; } 00507 /// This allows ActOnDeclarator to register "xx" prior to parsing the 00508 /// initializer. The declaration above should still result in a warning, 00509 /// since the reference to "xx" is uninitialized. 00510 virtual void AddInitializerToDecl(DeclPtrTy Dcl, ExprArg Init) { 00511 return; 00512 } 00513 00514 /// SetDeclDeleted - This action is called immediately after ActOnDeclarator 00515 /// if =delete is parsed. C++0x [dcl.fct.def]p10 00516 /// Note that this can be called even for variable declarations. It's the 00517 /// action's job to reject it. 00518 virtual void SetDeclDeleted(DeclPtrTy Dcl, SourceLocation DelLoc) { 00519 return; 00520 } 00521 00522 /// ActOnUninitializedDecl - This action is called immediately after 00523 /// ActOnDeclarator (when an initializer is *not* present). 00524 /// If TypeContainsUndeducedAuto is true, then the type of the declarator 00525 /// has an undeduced 'auto' type somewhere. 00526 virtual void ActOnUninitializedDecl(DeclPtrTy Dcl, 00527 bool TypeContainsUndeducedAuto) { 00528 return; 00529 } 00530 00531 /// \brief Note that the given declaration had an initializer that could not 00532 /// be parsed. 00533 virtual void ActOnInitializerError(DeclPtrTy Dcl) { 00534 return; 00535 } 00536 00537 /// FinalizeDeclaratorGroup - After a sequence of declarators are parsed, this 00538 /// gives the actions implementation a chance to process the group as a whole. 00539 virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec& DS, 00540 DeclPtrTy *Group, 00541 unsigned NumDecls) { 00542 return DeclGroupPtrTy(); 00543 } 00544 00545 00546 /// @brief Indicates that all K&R-style parameter declarations have 00547 /// been parsed prior to a function definition. 00548 /// @param S The function prototype scope. 00549 /// @param D The function declarator. 00550 virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, 00551 SourceLocation LocAfterDecls) { 00552 } 00553 00554 /// ActOnStartOfFunctionDef - This is called at the start of a function 00555 /// definition, instead of calling ActOnDeclarator. The Declarator includes 00556 /// information about formal arguments that are part of this function. 00557 virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) { 00558 // Default to ActOnDeclarator. 00559 return ActOnStartOfFunctionDef(FnBodyScope, 00560 ActOnDeclarator(FnBodyScope, D)); 00561 } 00562 00563 /// ActOnStartOfFunctionDef - This is called at the start of a function 00564 /// definition, after the FunctionDecl has already been created. 00565 virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { 00566 return D; 00567 } 00568 00569 virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) { 00570 return; 00571 } 00572 00573 /// ActOnFinishFunctionBody - This is called when a function body has 00574 /// completed parsing. Decl is returned by ParseStartOfFunctionDef. 00575 virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body) { 00576 return Decl; 00577 } 00578 00579 virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, 00580 ExprArg AsmString) { 00581 return DeclPtrTy(); 00582 } 00583 00584 /// ActOnPopScope - This callback is called immediately before the specified 00585 /// scope is popped and deleted. 00586 virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {} 00587 00588 /// ActOnTranslationUnitScope - This callback is called once, immediately 00589 /// after creating the translation unit scope (in Parser::Initialize). 00590 virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {} 00591 00592 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with 00593 /// no declarator (e.g. "struct foo;") is parsed. 00594 virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, 00595 AccessSpecifier Access, 00596 DeclSpec &DS) { 00597 return DeclPtrTy(); 00598 } 00599 00600 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++ 00601 /// linkage specification, including the language and (if present) 00602 /// the '{'. ExternLoc is the location of the 'extern', LangLoc is 00603 /// the location of the language string literal, which is provided 00604 /// by Lang/StrSize. LBraceLoc, if valid, provides the location of 00605 /// the '{' brace. Otherwise, this linkage specification does not 00606 /// have any braces. 00607 virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S, 00608 SourceLocation ExternLoc, 00609 SourceLocation LangLoc, 00610 llvm::StringRef Lang, 00611 SourceLocation LBraceLoc) { 00612 return DeclPtrTy(); 00613 } 00614 00615 /// ActOnFinishLinkageSpecification - Completely the definition of 00616 /// the C++ linkage specification LinkageSpec. If RBraceLoc is 00617 /// valid, it's the position of the closing '}' brace in a linkage 00618 /// specification that uses braces. 00619 virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S, 00620 DeclPtrTy LinkageSpec, 00621 SourceLocation RBraceLoc) { 00622 return LinkageSpec; 00623 } 00624 00625 /// ActOnEndOfTranslationUnit - This is called at the very end of the 00626 /// translation unit when EOF is reached and all but the top-level scope is 00627 /// popped. 00628 virtual void ActOnEndOfTranslationUnit() {} 00629 00630 //===--------------------------------------------------------------------===// 00631 // Type Parsing Callbacks. 00632 //===--------------------------------------------------------------------===// 00633 00634 /// ActOnTypeName - A type-name (type-id in C++) was parsed. 00635 virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) { 00636 return TypeResult(); 00637 } 00638 00639 enum TagUseKind { 00640 TUK_Reference, // Reference to a tag: 'struct foo *X;' 00641 TUK_Declaration, // Fwd decl of a tag: 'struct foo;' 00642 TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;' 00643 TUK_Friend // Friend declaration: 'friend struct foo;' 00644 }; 00645 00646 /// \brief The parser has encountered a tag (e.g., "class X") that should be 00647 /// turned into a declaration by the action module. 00648 /// 00649 /// \param S the scope in which this tag occurs. 00650 /// 00651 /// \param TagSpec an instance of DeclSpec::TST, indicating what kind of tag 00652 /// this is (struct/union/enum/class). 00653 /// 00654 /// \param TUK how the tag we have encountered is being used, which 00655 /// can be a reference to a (possibly pre-existing) tag, a 00656 /// declaration of that tag, or the beginning of a definition of 00657 /// that tag. 00658 /// 00659 /// \param KWLoc the location of the "struct", "class", "union", or "enum" 00660 /// keyword. 00661 /// 00662 /// \param SS C++ scope specifier that precedes the name of the tag, e.g., 00663 /// the "std::" in "class std::type_info". 00664 /// 00665 /// \param Name the name of the tag, e.g., "X" in "struct X". This parameter 00666 /// may be NULL, to indicate an anonymous class/struct/union/enum type. 00667 /// 00668 /// \param NameLoc the location of the name of the tag. 00669 /// 00670 /// \param Attr the set of attributes that appertain to the tag. 00671 /// 00672 /// \param AS when this tag occurs within a C++ class, provides the 00673 /// current access specifier (AS_public, AS_private, AS_protected). 00674 /// Otherwise, it will be AS_none. 00675 /// 00676 /// \param TemplateParameterLists the set of C++ template parameter lists 00677 /// that apply to this tag, if the tag is a declaration or definition (see 00678 /// the \p TK parameter). The action module is responsible for determining, 00679 /// based on the template parameter lists and the scope specifier, whether 00680 /// the declared tag is a class template or not. 00681 /// 00682 /// \param OwnedDecl the callee should set this flag true when the returned 00683 /// declaration is "owned" by this reference. Ownership is handled entirely 00684 /// by the action module. 00685 /// 00686 /// \returns the declaration to which this tag refers. 00687 virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, 00688 SourceLocation KWLoc, CXXScopeSpec &SS, 00689 IdentifierInfo *Name, SourceLocation NameLoc, 00690 AttributeList *Attr, AccessSpecifier AS, 00691 MultiTemplateParamsArg TemplateParameterLists, 00692 bool &OwnedDecl, bool &IsDependent) { 00693 return DeclPtrTy(); 00694 } 00695 00696 /// Acts on a reference to a dependent tag name. This arises in 00697 /// cases like: 00698 /// 00699 /// template <class T> class A; 00700 /// template <class T> class B { 00701 /// friend class A<T>::M; // here 00702 /// }; 00703 /// 00704 /// \param TagSpec an instance of DeclSpec::TST corresponding to the 00705 /// tag specifier. 00706 /// 00707 /// \param TUK the tag use kind (either TUK_Friend or TUK_Reference) 00708 /// 00709 /// \param SS the scope specifier (always defined) 00710 virtual TypeResult ActOnDependentTag(Scope *S, 00711 unsigned TagSpec, 00712 TagUseKind TUK, 00713 const CXXScopeSpec &SS, 00714 IdentifierInfo *Name, 00715 SourceLocation KWLoc, 00716 SourceLocation NameLoc) { 00717 return TypeResult(); 00718 } 00719 00720 /// Act on @defs() element found when parsing a structure. ClassName is the 00721 /// name of the referenced class. 00722 virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart, 00723 IdentifierInfo *ClassName, 00724 llvm::SmallVectorImpl<DeclPtrTy> &Decls) {} 00725 virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD, 00726 SourceLocation DeclStart, 00727 Declarator &D, ExprTy *BitfieldWidth) { 00728 return DeclPtrTy(); 00729 } 00730 00731 virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart, 00732 DeclPtrTy IntfDecl, 00733 Declarator &D, ExprTy *BitfieldWidth, 00734 tok::ObjCKeywordKind visibility) { 00735 return DeclPtrTy(); 00736 } 00737 00738 virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl, 00739 DeclPtrTy *Fields, unsigned NumFields, 00740 SourceLocation LBrac, SourceLocation RBrac, 00741 AttributeList *AttrList) {} 00742 00743 /// ActOnTagStartDefinition - Invoked when we have entered the 00744 /// scope of a tag's definition (e.g., for an enumeration, class, 00745 /// struct, or union). 00746 virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl) { } 00747 00748 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a 00749 /// C++ record definition's base-specifiers clause and are starting its 00750 /// member declarations. 00751 virtual void ActOnStartCXXMemberDeclarations(Scope *S, DeclPtrTy TagDecl, 00752 SourceLocation LBraceLoc) { } 00753 00754 /// ActOnTagFinishDefinition - Invoked once we have finished parsing 00755 /// the definition of a tag (enumeration, class, struct, or union). 00756 /// 00757 /// The scope is the scope of the tag definition. 00758 virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl, 00759 SourceLocation RBraceLoc) { } 00760 00761 /// ActOnTagDefinitionError - Invoked if there's an unrecoverable 00762 /// error parsing the definition of a tag. 00763 /// 00764 /// The scope is the scope of the tag definition. 00765 virtual void ActOnTagDefinitionError(Scope *S, DeclPtrTy TagDecl) { } 00766 00767 virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl, 00768 DeclPtrTy LastEnumConstant, 00769 SourceLocation IdLoc, IdentifierInfo *Id, 00770 SourceLocation EqualLoc, ExprTy *Val) { 00771 return DeclPtrTy(); 00772 } 00773 virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, 00774 SourceLocation RBraceLoc, DeclPtrTy EnumDecl, 00775 DeclPtrTy *Elements, unsigned NumElements, 00776 Scope *S, AttributeList *AttrList) {} 00777 00778 //===--------------------------------------------------------------------===// 00779 // Statement Parsing Callbacks. 00780 //===--------------------------------------------------------------------===// 00781 00782 virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc) { 00783 return StmtEmpty(); 00784 } 00785 00786 virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, 00787 MultiStmtArg Elts, 00788 bool isStmtExpr) { 00789 return StmtEmpty(); 00790 } 00791 virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, 00792 SourceLocation StartLoc, 00793 SourceLocation EndLoc) { 00794 return StmtEmpty(); 00795 } 00796 00797 virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl) { 00798 } 00799 00800 virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) { 00801 return OwningStmtResult(*this, Expr->release()); 00802 } 00803 00804 /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, 00805 /// which can specify an RHS value. The sub-statement of the case is 00806 /// specified in a separate action. 00807 virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal, 00808 SourceLocation DotDotDotLoc, 00809 ExprArg RHSVal, 00810 SourceLocation ColonLoc) { 00811 return StmtEmpty(); 00812 } 00813 00814 /// ActOnCaseStmtBody - This installs a statement as the body of a case. 00815 virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt) {} 00816 00817 virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, 00818 SourceLocation ColonLoc, 00819 StmtArg SubStmt, Scope *CurScope){ 00820 return StmtEmpty(); 00821 } 00822 00823 virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc, 00824 IdentifierInfo *II, 00825 SourceLocation ColonLoc, 00826 StmtArg SubStmt) { 00827 return StmtEmpty(); 00828 } 00829 00830 /// \brief Parsed an "if" statement. 00831 /// 00832 /// \param IfLoc the location of the "if" keyword. 00833 /// 00834 /// \param CondVal if the "if" condition was parsed as an expression, 00835 /// the expression itself. 00836 /// 00837 /// \param CondVar if the "if" condition was parsed as a condition variable, 00838 /// the condition variable itself. 00839 /// 00840 /// \param ThenVal the "then" statement. 00841 /// 00842 /// \param ElseLoc the location of the "else" keyword. 00843 /// 00844 /// \param ElseVal the "else" statement. 00845 virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, 00846 FullExprArg CondVal, 00847 DeclPtrTy CondVar, 00848 StmtArg ThenVal, 00849 SourceLocation ElseLoc, 00850 StmtArg ElseVal) { 00851 return StmtEmpty(); 00852 } 00853 00854 /// \brief Parsed the start of a "switch" statement. 00855 /// 00856 /// \param SwitchLoc The location of the "switch" keyword. 00857 /// 00858 /// \param Cond if the "switch" condition was parsed as an expression, 00859 /// the expression itself. 00860 /// 00861 /// \param CondVar if the "switch" condition was parsed as a condition 00862 /// variable, the condition variable itself. 00863 virtual OwningStmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, 00864 ExprArg Cond, 00865 DeclPtrTy CondVar) { 00866 return StmtEmpty(); 00867 } 00868 00869 virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 00870 StmtArg Switch, StmtArg Body) { 00871 return StmtEmpty(); 00872 } 00873 00874 /// \brief Parsed a "while" statement. 00875 /// 00876 /// \param Cond if the "while" condition was parsed as an expression, 00877 /// the expression itself. 00878 /// 00879 /// \param CondVar if the "while" condition was parsed as a condition 00880 /// variable, the condition variable itself. 00881 /// 00882 /// \param Body the body of the "while" loop. 00883 virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, 00884 FullExprArg Cond, DeclPtrTy CondVar, 00885 StmtArg Body) { 00886 return StmtEmpty(); 00887 } 00888 virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, 00889 SourceLocation WhileLoc, 00890 SourceLocation CondLParen, 00891 ExprArg Cond, 00892 SourceLocation CondRParen) { 00893 return StmtEmpty(); 00894 } 00895 00896 /// \brief Parsed a "for" statement. 00897 /// 00898 /// \param ForLoc the location of the "for" keyword. 00899 /// 00900 /// \param LParenLoc the location of the left parentheses. 00901 /// 00902 /// \param First the statement used to initialize the for loop. 00903 /// 00904 /// \param Second the condition to be checked during each iteration, if 00905 /// that condition was parsed as an expression. 00906 /// 00907 /// \param SecondArg the condition variable to be checked during each 00908 /// iterator, if that condition was parsed as a variable declaration. 00909 /// 00910 /// \param Third the expression that will be evaluated to "increment" any 00911 /// values prior to the next iteration. 00912 /// 00913 /// \param RParenLoc the location of the right parentheses. 00914 /// 00915 /// \param Body the body of the "body" loop. 00916 virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc, 00917 SourceLocation LParenLoc, 00918 StmtArg First, FullExprArg Second, 00919 DeclPtrTy SecondVar, FullExprArg Third, 00920 SourceLocation RParenLoc, 00921 StmtArg Body) { 00922 return StmtEmpty(); 00923 } 00924 00925 virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, 00926 SourceLocation LParenLoc, 00927 StmtArg First, ExprArg Second, 00928 SourceLocation RParenLoc, StmtArg Body) { 00929 return StmtEmpty(); 00930 } 00931 virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc, 00932 SourceLocation LabelLoc, 00933 IdentifierInfo *LabelII) { 00934 return StmtEmpty(); 00935 } 00936 virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, 00937 SourceLocation StarLoc, 00938 ExprArg DestExp) { 00939 return StmtEmpty(); 00940 } 00941 virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc, 00942 Scope *CurScope) { 00943 return StmtEmpty(); 00944 } 00945 virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc, 00946 Scope *CurScope) { 00947 return StmtEmpty(); 00948 } 00949 virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc, 00950 ExprArg RetValExp) { 00951 return StmtEmpty(); 00952 } 00953 virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc, 00954 bool IsSimple, 00955 bool IsVolatile, 00956 unsigned NumOutputs, 00957 unsigned NumInputs, 00958 IdentifierInfo **Names, 00959 MultiExprArg Constraints, 00960 MultiExprArg Exprs, 00961 ExprArg AsmString, 00962 MultiExprArg Clobbers, 00963 SourceLocation RParenLoc, 00964 bool MSAsm = false) { 00965 return StmtEmpty(); 00966 } 00967 00968 // Objective-c statements 00969 00970 /// \brief Parsed an Objective-C @catch statement. 00971 /// 00972 /// \param AtLoc The location of the '@' starting the '@catch'. 00973 /// 00974 /// \param RParen The location of the right parentheses ')' after the 00975 /// exception variable. 00976 /// 00977 /// \param Parm The variable that will catch the exception. Will be NULL if 00978 /// this is a @catch(...) block. 00979 /// 00980 /// \param Body The body of the @catch block. 00981 virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, 00982 SourceLocation RParen, 00983 DeclPtrTy Parm, StmtArg Body) { 00984 return StmtEmpty(); 00985 } 00986 00987 /// \brief Parsed an Objective-C @finally statement. 00988 /// 00989 /// \param AtLoc The location of the '@' starting the '@finally'. 00990 /// 00991 /// \param Body The body of the @finally block. 00992 virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, 00993 StmtArg Body) { 00994 return StmtEmpty(); 00995 } 00996 00997 /// \brief Parsed an Objective-C @try-@catch-@finally statement. 00998 /// 00999 /// \param AtLoc The location of the '@' starting '@try'. 01000 /// 01001 /// \param Try The body of the '@try' statement. 01002 /// 01003 /// \param CatchStmts The @catch statements. 01004 /// 01005 /// \param Finally The @finally statement. 01006 virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, 01007 StmtArg Try, 01008 MultiStmtArg CatchStmts, 01009 StmtArg Finally) { 01010 return StmtEmpty(); 01011 } 01012 01013 virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, 01014 ExprArg Throw, 01015 Scope *CurScope) { 01016 return StmtEmpty(); 01017 } 01018 01019 virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, 01020 ExprArg SynchExpr, 01021 StmtArg SynchBody) { 01022 return StmtEmpty(); 01023 } 01024 01025 // C++ Statements 01026 virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D) { 01027 return DeclPtrTy(); 01028 } 01029 01030 virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, 01031 DeclPtrTy ExceptionDecl, 01032 StmtArg HandlerBlock) { 01033 return StmtEmpty(); 01034 } 01035 01036 virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc, 01037 StmtArg TryBlock, 01038 MultiStmtArg Handlers) { 01039 return StmtEmpty(); 01040 } 01041 01042 //===--------------------------------------------------------------------===// 01043 // Expression Parsing Callbacks. 01044 //===--------------------------------------------------------------------===// 01045 01046 /// \brief Describes how the expressions currently being parsed are 01047 /// evaluated at run-time, if at all. 01048 enum ExpressionEvaluationContext { 01049 /// \brief The current expression and its subexpressions occur within an 01050 /// unevaluated operand (C++0x [expr]p8), such as a constant expression 01051 /// or the subexpression of \c sizeof, where the type or the value of the 01052 /// expression may be significant but no code will be generated to evaluate 01053 /// the value of the expression at run time. 01054 Unevaluated, 01055 01056 /// \brief The current expression is potentially evaluated at run time, 01057 /// which means that code may be generated to evaluate the value of the 01058 /// expression at run time. 01059 PotentiallyEvaluated, 01060 01061 /// \brief The current expression may be potentially evaluated or it may 01062 /// be unevaluated, but it is impossible to tell from the lexical context. 01063 /// This evaluation context is used primary for the operand of the C++ 01064 /// \c typeid expression, whose argument is potentially evaluated only when 01065 /// it is an lvalue of polymorphic class type (C++ [basic.def.odr]p2). 01066 PotentiallyPotentiallyEvaluated 01067 }; 01068 01069 /// \brief The parser is entering a new expression evaluation context. 01070 /// 01071 /// \param NewContext is the new expression evaluation context. 01072 virtual void 01073 PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext) { } 01074 01075 /// \brief The parser is exiting an expression evaluation context. 01076 virtual void 01077 PopExpressionEvaluationContext() { } 01078 01079 // Primary Expressions. 01080 01081 /// \brief Retrieve the source range that corresponds to the given 01082 /// expression. 01083 virtual SourceRange getExprRange(ExprTy *E) const { 01084 return SourceRange(); 01085 } 01086 01087 /// \brief Parsed an id-expression (C++) or identifier (C) in expression 01088 /// context, e.g., the expression "x" that refers to a variable named "x". 01089 /// 01090 /// \param S the scope in which this id-expression or identifier occurs. 01091 /// 01092 /// \param SS the C++ nested-name-specifier that qualifies the name of the 01093 /// value, e.g., "std::" in "std::sort". 01094 /// 01095 /// \param Name the name to which the id-expression refers. In C, this will 01096 /// always be an identifier. In C++, it may also be an overloaded operator, 01097 /// destructor name (if there is a nested-name-specifier), or template-id. 01098 /// 01099 /// \param HasTrailingLParen whether the next token following the 01100 /// id-expression or identifier is a left parentheses ('('). 01101 /// 01102 /// \param IsAddressOfOperand whether the token that precedes this 01103 /// id-expression or identifier was an ampersand ('&'), indicating that 01104 /// we will be taking the address of this expression. 01105 virtual OwningExprResult ActOnIdExpression(Scope *S, 01106 CXXScopeSpec &SS, 01107 UnqualifiedId &Name, 01108 bool HasTrailingLParen, 01109 bool IsAddressOfOperand) { 01110 return ExprEmpty(); 01111 } 01112 01113 virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc, 01114 tok::TokenKind Kind) { 01115 return ExprEmpty(); 01116 } 01117 virtual OwningExprResult ActOnCharacterConstant(const Token &) { 01118 return ExprEmpty(); 01119 } 01120 virtual OwningExprResult ActOnNumericConstant(const Token &) { 01121 return ExprEmpty(); 01122 } 01123 01124 /// ActOnStringLiteral - The specified tokens were lexed as pasted string 01125 /// fragments (e.g. "foo" "bar" L"baz"). 01126 virtual OwningExprResult ActOnStringLiteral(const Token *Toks, 01127 unsigned NumToks) { 01128 return ExprEmpty(); 01129 } 01130 01131 virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, 01132 ExprArg Val) { 01133 return move(Val); // Default impl returns operand. 01134 } 01135 01136 virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L, 01137 SourceLocation R, 01138 MultiExprArg Val, 01139 TypeTy *TypeOfCast=0) { 01140 return ExprEmpty(); 01141 } 01142 01143 // Postfix Expressions. 01144 virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, 01145 tok::TokenKind Kind, 01146 ExprArg Input) { 01147 return ExprEmpty(); 01148 } 01149 virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base, 01150 SourceLocation LLoc, 01151 ExprArg Idx, 01152 SourceLocation RLoc) { 01153 return ExprEmpty(); 01154 } 01155 01156 /// \brief Parsed a member access expresion (C99 6.5.2.3, C++ [expr.ref]) 01157 /// of the form \c x.m or \c p->m. 01158 /// 01159 /// \param S the scope in which the member access expression occurs. 01160 /// 01161 /// \param Base the class or pointer to class into which this member 01162 /// access expression refers, e.g., \c x in \c x.m. 01163 /// 01164 /// \param OpLoc the location of the "." or "->" operator. 01165 /// 01166 /// \param OpKind the kind of member access operator, which will be either 01167 /// tok::arrow ("->") or tok::period ("."). 01168 /// 01169 /// \param SS in C++, the nested-name-specifier that precedes the member 01170 /// name, if any. 01171 /// 01172 /// \param Member the name of the member that we are referring to. In C, 01173 /// this will always store an identifier; in C++, we may also have operator 01174 /// names, conversion function names, destructors, and template names. 01175 /// 01176 /// \param ObjCImpDecl the Objective-C implementation declaration. 01177 /// FIXME: Do we really need this? 01178 /// 01179 /// \param HasTrailingLParen whether this member name is immediately followed 01180 /// by a left parentheses ('('). 01181 virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base, 01182 SourceLocation OpLoc, 01183 tok::TokenKind OpKind, 01184 CXXScopeSpec &SS, 01185 UnqualifiedId &Member, 01186 DeclPtrTy ObjCImpDecl, 01187 bool HasTrailingLParen) { 01188 return ExprEmpty(); 01189 } 01190 01191 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. 01192 /// This provides the location of the left/right parens and a list of comma 01193 /// locations. There are guaranteed to be one fewer commas than arguments, 01194 /// unless there are zero arguments. 01195 virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn, 01196 SourceLocation LParenLoc, 01197 MultiExprArg Args, 01198 SourceLocation *CommaLocs, 01199 SourceLocation RParenLoc) { 01200 return ExprEmpty(); 01201 } 01202 01203 // Unary Operators. 'Tok' is the token for the operator. 01204 virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, 01205 tok::TokenKind Op, ExprArg Input) { 01206 return ExprEmpty(); 01207 } 01208 virtual OwningExprResult 01209 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, 01210 void *TyOrEx, const SourceRange &ArgRange) { 01211 return ExprEmpty(); 01212 } 01213 01214 virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen, 01215 TypeTy *Ty, 01216 SourceLocation RParen, 01217 ExprArg Op) { 01218 return ExprEmpty(); 01219 } 01220 virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc, 01221 MultiExprArg InitList, 01222 SourceLocation RParenLoc) { 01223 return ExprEmpty(); 01224 } 01225 /// @brief Parsed a C99 designated initializer. 01226 /// 01227 /// @param Desig Contains the designation with one or more designators. 01228 /// 01229 /// @param Loc The location of the '=' or ':' prior to the 01230 /// initialization expression. 01231 /// 01232 /// @param GNUSyntax If true, then this designated initializer used 01233 /// the deprecated GNU syntax @c fieldname:foo or @c [expr]foo rather 01234 /// than the C99 syntax @c .fieldname=foo or @c [expr]=foo. 01235 /// 01236 /// @param Init The value that the entity (or entities) described by 01237 /// the designation will be initialized with. 01238 virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig, 01239 SourceLocation Loc, 01240 bool GNUSyntax, 01241 OwningExprResult Init) { 01242 return ExprEmpty(); 01243 } 01244 01245 virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, 01246 TypeTy *Ty, SourceLocation RParenLoc, 01247 ExprArg Op) { 01248 return ExprEmpty(); 01249 } 01250 01251 virtual bool TypeIsVectorType(TypeTy *Ty) { 01252 return false; 01253 } 01254 01255 virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, 01256 tok::TokenKind Kind, 01257 ExprArg LHS, ExprArg RHS) { 01258 return ExprEmpty(); 01259 } 01260 01261 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null 01262 /// in the case of a the GNU conditional expr extension. 01263 virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc, 01264 SourceLocation ColonLoc, 01265 ExprArg Cond, ExprArg LHS, 01266 ExprArg RHS) { 01267 return ExprEmpty(); 01268 } 01269 01270 //===---------------------- GNU Extension Expressions -------------------===// 01271 01272 virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc, 01273 SourceLocation LabLoc, 01274 IdentifierInfo *LabelII) { // "&&foo" 01275 return ExprEmpty(); 01276 } 01277 01278 virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt, 01279 SourceLocation RPLoc) { // "({..})" 01280 return ExprEmpty(); 01281 } 01282 01283 // __builtin_offsetof(type, identifier(.identifier|[expr])*) 01284 struct OffsetOfComponent { 01285 SourceLocation LocStart, LocEnd; 01286 bool isBrackets; // true if [expr], false if .ident 01287 union { 01288 IdentifierInfo *IdentInfo; 01289 ExprTy *E; 01290 } U; 01291 }; 01292 01293 virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S, 01294 SourceLocation BuiltinLoc, 01295 SourceLocation TypeLoc, 01296 TypeTy *Arg1, 01297 OffsetOfComponent *CompPtr, 01298 unsigned NumComponents, 01299 SourceLocation RParenLoc) { 01300 return ExprEmpty(); 01301 } 01302 01303 // __builtin_types_compatible_p(type1, type2) 01304 virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, 01305 TypeTy *arg1, TypeTy *arg2, 01306 SourceLocation RPLoc) { 01307 return ExprEmpty(); 01308 } 01309 // __builtin_choose_expr(constExpr, expr1, expr2) 01310 virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, 01311 ExprArg cond, ExprArg expr1, 01312 ExprArg expr2, SourceLocation RPLoc){ 01313 return ExprEmpty(); 01314 } 01315 01316 // __builtin_va_arg(expr, type) 01317 virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc, 01318 ExprArg expr, TypeTy *type, 01319 SourceLocation RPLoc) { 01320 return ExprEmpty(); 01321 } 01322 01323 /// ActOnGNUNullExpr - Parsed the GNU __null expression, the token 01324 /// for which is at position TokenLoc. 01325 virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc) { 01326 return ExprEmpty(); 01327 } 01328 01329 //===------------------------- "Block" Extension ------------------------===// 01330 01331 /// ActOnBlockStart - This callback is invoked when a block literal is 01332 /// started. The result pointer is passed into the block finalizers. 01333 virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope) {} 01334 01335 /// ActOnBlockArguments - This callback allows processing of block arguments. 01336 /// If there are no arguments, this is still invoked. 01337 virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {} 01338 01339 /// ActOnBlockError - If there is an error parsing a block, this callback 01340 /// is invoked to pop the information about the block from the action impl. 01341 virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) {} 01342 01343 /// ActOnBlockStmtExpr - This is called when the body of a block statement 01344 /// literal was successfully completed. ^(int x){...} 01345 virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, 01346 StmtArg Body, 01347 Scope *CurScope) { 01348 return ExprEmpty(); 01349 } 01350 01351 //===------------------------- C++ Declarations -------------------------===// 01352 01353 /// ActOnStartNamespaceDef - This is called at the start of a namespace 01354 /// definition. 01355 virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc, 01356 IdentifierInfo *Ident, 01357 SourceLocation LBrace, 01358 AttributeList *AttrList) { 01359 return DeclPtrTy(); 01360 } 01361 01362 /// ActOnFinishNamespaceDef - This callback is called after a namespace is 01363 /// exited. Decl is returned by ActOnStartNamespaceDef. 01364 virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace) { 01365 return; 01366 } 01367 01368 /// ActOnUsingDirective - This is called when using-directive is parsed. 01369 virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope, 01370 SourceLocation UsingLoc, 01371 SourceLocation NamespcLoc, 01372 CXXScopeSpec &SS, 01373 SourceLocation IdentLoc, 01374 IdentifierInfo *NamespcName, 01375 AttributeList *AttrList); 01376 01377 /// ActOnNamespaceAliasDef - This is called when a namespace alias definition 01378 /// is parsed. 01379 virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope, 01380 SourceLocation NamespaceLoc, 01381 SourceLocation AliasLoc, 01382 IdentifierInfo *Alias, 01383 CXXScopeSpec &SS, 01384 SourceLocation IdentLoc, 01385 IdentifierInfo *Ident) { 01386 return DeclPtrTy(); 01387 } 01388 01389 /// \brief Parsed a C++ using-declaration. 01390 /// 01391 /// This callback will be invoked when the parser has parsed a C++ 01392 /// using-declaration, e.g., 01393 /// 01394 /// \code 01395 /// namespace std { 01396 /// template<typename T, typename Alloc> class vector; 01397 /// } 01398 /// 01399 /// using std::vector; // using-declaration here 01400 /// \endcode 01401 /// 01402 /// \param CurScope the scope in which this using declaration was parsed. 01403 /// 01404 /// \param AS the currently-active access specifier. 01405 /// 01406 /// \param HasUsingKeyword true if this was declared with an 01407 /// explicit 'using' keyword (i.e. if this is technically a using 01408 /// declaration, not an access declaration) 01409 /// 01410 /// \param UsingLoc the location of the 'using' keyword. 01411 /// 01412 /// \param SS the nested-name-specifier that precedes the name. 01413 /// 01414 /// \param Name the name to which the using declaration refers. 01415 /// 01416 /// \param AttrList attributes applied to this using declaration, if any. 01417 /// 01418 /// \param IsTypeName whether this using declaration started with the 01419 /// 'typename' keyword. FIXME: This will eventually be split into a 01420 /// separate action. 01421 /// 01422 /// \param TypenameLoc the location of the 'typename' keyword, if present 01423 /// 01424 /// \returns a representation of the using declaration. 01425 virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope, 01426 AccessSpecifier AS, 01427 bool HasUsingKeyword, 01428 SourceLocation UsingLoc, 01429 CXXScopeSpec &SS, 01430 UnqualifiedId &Name, 01431 AttributeList *AttrList, 01432 bool IsTypeName, 01433 SourceLocation TypenameLoc); 01434 01435 /// ActOnParamDefaultArgument - Parse default argument for function parameter 01436 virtual void ActOnParamDefaultArgument(DeclPtrTy param, 01437 SourceLocation EqualLoc, 01438 ExprArg defarg) { 01439 } 01440 01441 /// ActOnParamUnparsedDefaultArgument - We've seen a default 01442 /// argument for a function parameter, but we can't parse it yet 01443 /// because we're inside a class definition. Note that this default 01444 /// argument will be parsed later. 01445 virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, 01446 SourceLocation EqualLoc, 01447 SourceLocation ArgLoc) { } 01448 01449 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of 01450 /// the default argument for the parameter param failed. 01451 virtual void ActOnParamDefaultArgumentError(DeclPtrTy param) { } 01452 01453 /// AddCXXDirectInitializerToDecl - This action is called immediately after 01454 /// ActOnDeclarator, when a C++ direct initializer is present. 01455 /// e.g: "int x(1);" 01456 virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, 01457 SourceLocation LParenLoc, 01458 MultiExprArg Exprs, 01459 SourceLocation *CommaLocs, 01460 SourceLocation RParenLoc) { 01461 return; 01462 } 01463 01464 /// \brief Called when we re-enter a template parameter scope. 01465 /// 01466 /// This action occurs when we are going to parse an member 01467 /// function's default arguments or inline definition after the 01468 /// outermost class definition has been completed, and when one or 01469 /// more of the class definitions enclosing the member function is a 01470 /// template. The "entity" in the given scope will be set as it was 01471 /// when we entered the scope of the template initially, and should 01472 /// be used to, e.g., reintroduce the names of template parameters 01473 /// into the current scope so that they can be found by name lookup. 01474 /// 01475 /// \param S The (new) template parameter scope. 01476 /// 01477 /// \param Template the class template declaration whose template 01478 /// parameters should be reintroduced into the current scope. 01479 virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template) { 01480 } 01481 01482 /// ActOnStartDelayedMemberDeclarations - We have completed parsing 01483 /// a C++ class, and we are about to start parsing any parts of 01484 /// member declarations that could not be parsed earlier. Enter 01485 /// the appropriate record scope. 01486 virtual void ActOnStartDelayedMemberDeclarations(Scope *S, 01487 DeclPtrTy Record) { 01488 } 01489 01490 /// ActOnStartDelayedCXXMethodDeclaration - We have completed 01491 /// parsing a top-level (non-nested) C++ class, and we are now 01492 /// parsing those parts of the given Method declaration that could 01493 /// not be parsed earlier (C++ [class.mem]p2), such as default 01494 /// arguments. This action should enter the scope of the given 01495 /// Method declaration as if we had just parsed the qualified method 01496 /// name. However, it should not bring the parameters into scope; 01497 /// that will be performed by ActOnDelayedCXXMethodParameter. 01498 virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, 01499 DeclPtrTy Method) { 01500 } 01501 01502 /// ActOnDelayedCXXMethodParameter - We've already started a delayed 01503 /// C++ method declaration. We're (re-)introducing the given 01504 /// function parameter into scope for use in parsing later parts of 01505 /// the method declaration. For example, we could see an 01506 /// ActOnParamDefaultArgument event for this parameter. 01507 virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param) { 01508 } 01509 01510 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished 01511 /// processing the delayed method declaration for Method. The method 01512 /// declaration is now considered finished. There may be a separate 01513 /// ActOnStartOfFunctionDef action later (not necessarily 01514 /// immediately!) for this method, if it was also defined inside the 01515 /// class body. 01516 virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, 01517 DeclPtrTy Method) { 01518 } 01519 01520 /// ActOnFinishDelayedMemberDeclarations - We have finished parsing 01521 /// a C++ class, and we are about to start parsing any parts of 01522 /// member declarations that could not be parsed earlier. Enter the 01523 /// appropriate record scope. 01524 virtual void ActOnFinishDelayedMemberDeclarations(Scope *S, 01525 DeclPtrTy Record) { 01526 } 01527 01528 /// ActOnStaticAssertDeclaration - Parse a C++0x static_assert declaration. 01529 virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc, 01530 ExprArg AssertExpr, 01531 ExprArg AssertMessageExpr) { 01532 return DeclPtrTy(); 01533 } 01534 01535 /// ActOnFriendFunctionDecl - Parsed a friend function declarator. 01536 /// The name is actually a slight misnomer, because the declarator 01537 /// is not necessarily a function declarator. 01538 virtual DeclPtrTy ActOnFriendFunctionDecl(Scope *S, 01539 Declarator &D, 01540 bool IsDefinition, 01541 MultiTemplateParamsArg TParams) { 01542 return DeclPtrTy(); 01543 } 01544 01545 /// ActOnFriendTypeDecl - Parsed a friend type declaration. 01546 virtual DeclPtrTy ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, 01547 MultiTemplateParamsArg TParams) { 01548 return DeclPtrTy(); 01549 } 01550 01551 //===------------------------- C++ Expressions --------------------------===// 01552 01553 /// \brief Parsed a destructor name or pseudo-destructor name. 01554 /// 01555 /// \returns the type being destructed. 01556 virtual TypeTy *getDestructorName(SourceLocation TildeLoc, 01557 IdentifierInfo &II, SourceLocation NameLoc, 01558 Scope *S, CXXScopeSpec &SS, 01559 TypeTy *ObjectType, 01560 bool EnteringContext) { 01561 return getTypeName(II, NameLoc, S, &SS, false, ObjectType); 01562 } 01563 01564 01565 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's. 01566 virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc, 01567 tok::TokenKind Kind, 01568 SourceLocation LAngleBracketLoc, 01569 TypeTy *Ty, 01570 SourceLocation RAngleBracketLoc, 01571 SourceLocation LParenLoc, 01572 ExprArg Op, 01573 SourceLocation RParenLoc) { 01574 return ExprEmpty(); 01575 } 01576 01577 /// ActOnCXXTypeidOfType - Parse typeid( type-id ). 01578 virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc, 01579 SourceLocation LParenLoc, bool isType, 01580 void *TyOrExpr, 01581 SourceLocation RParenLoc) { 01582 return ExprEmpty(); 01583 } 01584 01585 /// ActOnCXXThis - Parse the C++ 'this' pointer. 01586 virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc) { 01587 return ExprEmpty(); 01588 } 01589 01590 /// ActOnCXXBoolLiteral - Parse {true,false} literals. 01591 virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, 01592 tok::TokenKind Kind) { 01593 return ExprEmpty(); 01594 } 01595 01596 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'. 01597 virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc) { 01598 return ExprEmpty(); 01599 } 01600 01601 /// ActOnCXXThrow - Parse throw expressions. 01602 virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc, ExprArg Op) { 01603 return ExprEmpty(); 01604 } 01605 01606 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type. 01607 /// Can be interpreted either as function-style casting ("int(x)") 01608 /// or class type construction ("ClassType(x,y,z)") 01609 /// or creation of a value-initialized type ("int()"). 01610 virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange, 01611 TypeTy *TypeRep, 01612 SourceLocation LParenLoc, 01613 MultiExprArg Exprs, 01614 SourceLocation *CommaLocs, 01615 SourceLocation RParenLoc) { 01616 return ExprEmpty(); 01617 } 01618 01619 /// \brief Parsed a condition declaration in a C++ if, switch, or while 01620 /// statement. 01621 /// 01622 /// This callback will be invoked after parsing the declaration of "x" in 01623 /// 01624 /// \code 01625 /// if (int x = f()) { 01626 /// // ... 01627 /// } 01628 /// \endcode 01629 /// 01630 /// \param S the scope of the if, switch, or while statement. 01631 /// 01632 /// \param D the declarator that that describes the variable being declared. 01633 virtual DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D) { 01634 return DeclResult(); 01635 } 01636 01637 /// \brief Parsed an expression that will be handled as the condition in 01638 /// an if/while/for statement. 01639 /// 01640 /// This routine handles the conversion of the expression to 'bool'. 01641 /// 01642 /// \param S The scope in which the expression occurs. 01643 /// 01644 /// \param Loc The location of the construct that requires the conversion to 01645 /// a boolean value. 01646 /// 01647 /// \param SubExpr The expression that is being converted to bool. 01648 virtual OwningExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc, 01649 ExprArg SubExpr) { 01650 return move(SubExpr); 01651 } 01652 01653 /// \brief Parsed a C++ 'new' expression. 01654 /// 01655 /// \param StartLoc The start of the new expression, which is either the 01656 /// "new" keyword or the "::" preceding it, depending on \p UseGlobal. 01657 /// 01658 /// \param UseGlobal True if the "new" was qualified with "::". 01659 /// 01660 /// \param PlacementLParen The location of the opening parenthesis ('(') for 01661 /// the placement arguments, if any. 01662 /// 01663 /// \param PlacementArgs The placement arguments, if any. 01664 /// 01665 /// \param PlacementRParen The location of the closing parenthesis (')') for 01666 /// the placement arguments, if any. 01667 /// 01668 /// \param TypeIdParens If the type was expressed as a type-id in parentheses, 01669 /// the source range covering the parenthesized type-id. 01670 /// 01671 /// \param D The parsed declarator, which may include an array size (for 01672 /// array new) as the first declarator. 01673 /// 01674 /// \param ConstructorLParen The location of the opening parenthesis ('(') for 01675 /// the constructor arguments, if any. 01676 /// 01677 /// \param ConstructorArgs The constructor arguments, if any. 01678 /// 01679 /// \param ConstructorRParen The location of the closing parenthesis (')') for 01680 /// the constructor arguments, if any. 01681 virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, 01682 SourceLocation PlacementLParen, 01683 MultiExprArg PlacementArgs, 01684 SourceLocation PlacementRParen, 01685 SourceRange TypeIdParens, Declarator &D, 01686 SourceLocation ConstructorLParen, 01687 MultiExprArg ConstructorArgs, 01688 SourceLocation ConstructorRParen) { 01689 return ExprEmpty(); 01690 } 01691 01692 /// ActOnCXXDelete - Parsed a C++ 'delete' expression. UseGlobal is true if 01693 /// the delete was qualified (::delete). ArrayForm is true if the array form 01694 /// was used (delete[]). 01695 virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc, 01696 bool UseGlobal, bool ArrayForm, 01697 ExprArg Operand) { 01698 return ExprEmpty(); 01699 } 01700 01701 virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, 01702 SourceLocation KWLoc, 01703 SourceLocation LParen, 01704 TypeTy *Ty, 01705 SourceLocation RParen) { 01706 return ExprEmpty(); 01707 } 01708 01709 /// \brief Invoked when the parser is starting to parse a C++ member access 01710 /// expression such as x.f or x->f. 01711 /// 01712 /// \param S the scope in which the member access expression occurs. 01713 /// 01714 /// \param Base the expression in which a member is being accessed, e.g., the 01715 /// "x" in "x.f". 01716 /// 01717 /// \param OpLoc the location of the member access operator ("." or "->") 01718 /// 01719 /// \param OpKind the kind of member access operator ("." or "->") 01720 /// 01721 /// \param ObjectType originally NULL. The action should fill in this type 01722 /// with the type into which name lookup should look to find the member in 01723 /// the member access expression. 01724 /// 01725 /// \param MayBePseudoDestructor Originally false. The action should 01726 /// set this true if the expression may end up being a 01727 /// pseudo-destructor expression, indicating to the parser that it 01728 /// shoudl be parsed as a pseudo-destructor rather than as a member 01729 /// access expression. Note that this should apply both when the 01730 /// object type is a scalar and when the object type is dependent. 01731 /// 01732 /// \returns the (possibly modified) \p Base expression 01733 virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S, 01734 ExprArg Base, 01735 SourceLocation OpLoc, 01736 tok::TokenKind OpKind, 01737 TypeTy *&ObjectType, 01738 bool &MayBePseudoDestructor) { 01739 return ExprEmpty(); 01740 } 01741 01742 /// \brief Parsed a C++ pseudo-destructor expression or a dependent 01743 /// member access expression that has the same syntactic form as a 01744 /// pseudo-destructor expression. 01745 /// 01746 /// \param S The scope in which the member access expression occurs. 01747 /// 01748 /// \param Base The expression in which a member is being accessed, e.g., the 01749 /// "x" in "x.f". 01750 /// 01751 /// \param OpLoc The location of the member access operator ("." or "->") 01752 /// 01753 /// \param OpKind The kind of member access operator ("." or "->") 01754 /// 01755 /// \param SS The nested-name-specifier that precedes the type names 01756 /// in the grammar. Note that this nested-name-specifier will not 01757 /// cover the last "type-name ::" in the grammar, because it isn't 01758 /// necessarily a nested-name-specifier. 01759 /// 01760 /// \param FirstTypeName The type name that follows the optional 01761 /// nested-name-specifier but precedes the '::', e.g., the first 01762 /// type-name in "type-name :: type-name". This type name may be 01763 /// empty. This will be either an identifier or a template-id. 01764 /// 01765 /// \param CCLoc The location of the '::' in "type-name :: 01766 /// typename". May be invalid, if there is no \p FirstTypeName. 01767 /// 01768 /// \param TildeLoc The location of the '~'. 01769 /// 01770 /// \param SecondTypeName The type-name following the '~', which is 01771 /// the name of the type being destroyed. This will be either an 01772 /// identifier or a template-id. 01773 /// 01774 /// \param HasTrailingLParen Whether the next token in the stream is 01775 /// a left parentheses. 01776 virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base, 01777 SourceLocation OpLoc, 01778 tok::TokenKind OpKind, 01779 CXXScopeSpec &SS, 01780 UnqualifiedId &FirstTypeName, 01781 SourceLocation CCLoc, 01782 SourceLocation TildeLoc, 01783 UnqualifiedId &SecondTypeName, 01784 bool HasTrailingLParen) { 01785 return ExprEmpty(); 01786 } 01787 01788 /// ActOnFinishFullExpr - Called whenever a full expression has been parsed. 01789 /// (C++ [intro.execution]p12). 01790 virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr) { 01791 return move(Expr); 01792 } 01793 01794 //===---------------------------- C++ Classes ---------------------------===// 01795 /// ActOnBaseSpecifier - Parsed a base specifier 01796 virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl, 01797 SourceRange SpecifierRange, 01798 bool Virtual, AccessSpecifier Access, 01799 TypeTy *basetype, 01800 SourceLocation BaseLoc) { 01801 return BaseResult(); 01802 } 01803 01804 virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases, 01805 unsigned NumBases) { 01806 } 01807 01808 /// ActOnAccessSpecifier - This is invoked when an access specifier 01809 /// (and the colon following it) is found during the parsing of a 01810 /// C++ class member declarator. 01811 virtual DeclPtrTy ActOnAccessSpecifier(AccessSpecifier AS, 01812 SourceLocation ASLoc, 01813 SourceLocation ColonLoc) { 01814 return DeclPtrTy(); 01815 } 01816 01817 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member 01818 /// declarator is parsed. 'AS' is the access specifier, 'BitfieldWidth' 01819 /// specifies the bitfield width if there is one and 'Init' specifies the 01820 /// initializer if any. 'Deleted' is true if there's a =delete 01821 /// specifier on the function. 01822 virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, 01823 Declarator &D, 01824 MultiTemplateParamsArg TemplateParameterLists, 01825 ExprTy *BitfieldWidth, 01826 ExprTy *Init, 01827 bool IsDefinition, 01828 bool Deleted = false) { 01829 return DeclPtrTy(); 01830 } 01831 01832 virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorDecl, 01833 Scope *S, 01834 CXXScopeSpec &SS, 01835 IdentifierInfo *MemberOrBase, 01836 TypeTy *TemplateTypeTy, 01837 SourceLocation IdLoc, 01838 SourceLocation LParenLoc, 01839 ExprTy **Args, unsigned NumArgs, 01840 SourceLocation *CommaLocs, 01841 SourceLocation RParenLoc) { 01842 return true; 01843 } 01844 01845 /// ActOnMemInitializers - This is invoked when all of the member 01846 /// initializers of a constructor have been parsed. ConstructorDecl 01847 /// is the function declaration (which will be a C++ constructor in 01848 /// a well-formed program), ColonLoc is the location of the ':' that 01849 /// starts the constructor initializer, and MemInit/NumMemInits 01850 /// contains the individual member (and base) initializers. 01851 /// AnyErrors will be true if there were any invalid member initializers 01852 /// that are not represented in the list. 01853 virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl, 01854 SourceLocation ColonLoc, 01855 MemInitTy **MemInits, unsigned NumMemInits, 01856 bool AnyErrors){ 01857 } 01858 01859 virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl) {} 01860 01861 /// ActOnFinishCXXMemberSpecification - Invoked after all member declarators 01862 /// are parsed but *before* parsing of inline method definitions. 01863 virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, 01864 DeclPtrTy TagDecl, 01865 SourceLocation LBrac, 01866 SourceLocation RBrac, 01867 AttributeList *AttrList) { 01868 } 01869 01870 //===---------------------------C++ Templates----------------------------===// 01871 01872 /// \brief Called when a C++ template type parameter(e.g., "typename T") has 01873 /// been parsed. 01874 /// 01875 /// Given 01876 /// 01877 /// \code 01878 /// template<typename T, typename U = T> struct pair; 01879 /// \endcode 01880 /// 01881 /// this callback will be invoked twice: once for the type parameter \c T 01882 /// with \p Depth=0 and \p Position=0, and once for the type parameter \c U 01883 /// with \p Depth=0 and \p Position=1. 01884 /// 01885 /// \param Typename Specifies whether the keyword "typename" was used to 01886 /// declare the type parameter (otherwise, "class" was used). 01887 /// 01888 /// \param Ellipsis Specifies whether this is a C++0x parameter pack. 01889 /// 01890 /// \param EllipsisLoc Specifies the start of the ellipsis. 01891 /// 01892 /// \param KeyLoc The location of the "class" or "typename" keyword. 01893 /// 01894 /// \param ParamName The name of the parameter, where NULL indicates an 01895 /// unnamed template parameter. 01896 /// 01897 /// \param ParamNameLoc The location of the parameter name (if any). 01898 /// 01899 /// \param Depth The depth of this template parameter, e.g., the number of 01900 /// template parameter lists that occurred outside the template parameter 01901 /// list in which this template type parameter occurs. 01902 /// 01903 /// \param Position The zero-based position of this template parameter within 01904 /// its template parameter list, which is also the number of template 01905 /// parameters that precede this parameter in the template parameter list. 01906 /// 01907 /// \param EqualLoc The location of the '=' sign for the default template 01908 /// argument, if any. 01909 /// 01910 /// \param DefaultArg The default argument, if provided. 01911 virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, 01912 SourceLocation EllipsisLoc, 01913 SourceLocation KeyLoc, 01914 IdentifierInfo *ParamName, 01915 SourceLocation ParamNameLoc, 01916 unsigned Depth, unsigned Position, 01917 SourceLocation EqualLoc, 01918 TypeTy *DefaultArg) { 01919 return DeclPtrTy(); 01920 } 01921 01922 /// \brief Called when a C++ non-type template parameter has been parsed. 01923 /// 01924 /// Given 01925 /// 01926 /// \code 01927 /// template<int Size> class Array; 01928 /// \endcode 01929 /// 01930 /// This callback will be invoked for the 'Size' non-type template parameter. 01931 /// 01932 /// \param S The current scope. 01933 /// 01934 /// \param D The parsed declarator. 01935 /// 01936 /// \param Depth The depth of this template parameter, e.g., the number of 01937 /// template parameter lists that occurred outside the template parameter 01938 /// list in which this template type parameter occurs. 01939 /// 01940 /// \param Position The zero-based position of this template parameter within 01941 /// its template parameter list, which is also the number of template 01942 /// parameters that precede this parameter in the template parameter list. 01943 /// 01944 /// \param EqualLoc The location of the '=' sign for the default template 01945 /// argument, if any. 01946 /// 01947 /// \param DefaultArg The default argument, if provided. 01948 virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, 01949 unsigned Depth, 01950 unsigned Position, 01951 SourceLocation EqualLoc, 01952 ExprArg DefaultArg) { 01953 return DeclPtrTy(); 01954 } 01955 01956 /// \brief Adds a default argument to the given non-type template 01957 /// parameter. 01958 virtual void ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParam, 01959 SourceLocation EqualLoc, 01960 ExprArg Default) { 01961 } 01962 01963 /// \brief Called when a C++ template template parameter has been parsed. 01964 /// 01965 /// Given 01966 /// 01967 /// \code 01968 /// template<template <typename> class T> class X; 01969 /// \endcode 01970 /// 01971 /// this callback will be invoked for the template template parameter \c T. 01972 /// 01973 /// \param S The scope in which this template template parameter occurs. 01974 /// 01975 /// \param TmpLoc The location of the "template" keyword. 01976 /// 01977 /// \param TemplateParams The template parameters required by the template. 01978 /// 01979 /// \param ParamName The name of the parameter, or NULL if unnamed. 01980 /// 01981 /// \param ParamNameLoc The source location of the parameter name (if given). 01982 /// 01983 /// \param Depth The depth of this template parameter, e.g., the number of 01984 /// template parameter lists that occurred outside the template parameter 01985 /// list in which this template parameter occurs. 01986 /// 01987 /// \param Position The zero-based position of this template parameter within 01988 /// its template parameter list, which is also the number of template 01989 /// parameters that precede this parameter in the template parameter list. 01990 /// 01991 /// \param EqualLoc The location of the '=' sign for the default template 01992 /// argument, if any. 01993 /// 01994 /// \param DefaultArg The default argument, if provided. 01995 virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S, 01996 SourceLocation TmpLoc, 01997 TemplateParamsTy *Params, 01998 IdentifierInfo *ParamName, 01999 SourceLocation ParamNameLoc, 02000 unsigned Depth, 02001 unsigned Position, 02002 SourceLocation EqualLoc, 02003 const ParsedTemplateArgument &DefaultArg) { 02004 return DeclPtrTy(); 02005 } 02006 02007 /// ActOnTemplateParameterList - Called when a complete template 02008 /// parameter list has been parsed, e.g., 02009 /// 02010 /// @code 02011 /// export template<typename T, T Size> 02012 /// @endcode 02013 /// 02014 /// Depth is the number of enclosing template parameter lists. This 02015 /// value does not include templates from outer scopes. For example: 02016 /// 02017 /// @code 02018 /// template<typename T> // depth = 0 02019 /// class A { 02020 /// template<typename U> // depth = 0 02021 /// class B; 02022 /// }; 02023 /// 02024 /// template<typename T> // depth = 0 02025 /// template<typename U> // depth = 1 02026 /// class A<T>::B { ... }; 02027 /// @endcode 02028 /// 02029 /// ExportLoc, if valid, is the position of the "export" 02030 /// keyword. Otherwise, "export" was not specified. 02031 /// TemplateLoc is the position of the template keyword, LAngleLoc 02032 /// is the position of the left angle bracket, and RAngleLoc is the 02033 /// position of the corresponding right angle bracket. 02034 /// Params/NumParams provides the template parameters that were 02035 /// parsed as part of the template-parameter-list. 02036 virtual TemplateParamsTy * 02037 ActOnTemplateParameterList(unsigned Depth, 02038 SourceLocation ExportLoc, 02039 SourceLocation TemplateLoc, 02040 SourceLocation LAngleLoc, 02041 DeclPtrTy *Params, unsigned NumParams, 02042 SourceLocation RAngleLoc) { 02043 return 0; 02044 } 02045 02046 /// \brief Form a type from a template and a list of template 02047 /// arguments. 02048 /// 02049 /// This action merely forms the type for the template-id, possibly 02050 /// checking well-formedness of the template arguments. It does not 02051 /// imply the declaration of any entity. 02052 /// 02053 /// \param Template A template whose specialization results in a 02054 /// type, e.g., a class template or template template parameter. 02055 virtual TypeResult ActOnTemplateIdType(TemplateTy Template, 02056 SourceLocation TemplateLoc, 02057 SourceLocation LAngleLoc, 02058 ASTTemplateArgsPtr TemplateArgs, 02059 SourceLocation RAngleLoc) { 02060 return TypeResult(); 02061 } 02062 02063 /// \brief Note that a template ID was used with a tag. 02064 /// 02065 /// \param Type The result of ActOnTemplateIdType. 02066 /// 02067 /// \param TUK Either TUK_Reference or TUK_Friend. Declarations and 02068 /// definitions are interpreted as explicit instantiations or 02069 /// specializations. 02070 /// 02071 /// \param TagSpec The tag keyword that was provided as part of the 02072 /// elaborated-type-specifier; either class, struct, union, or enum. 02073 /// 02074 /// \param TagLoc The location of the tag keyword. 02075 virtual TypeResult ActOnTagTemplateIdType(TypeResult Type, 02076 TagUseKind TUK, 02077 DeclSpec::TST TagSpec, 02078 SourceLocation TagLoc) { 02079 return TypeResult(); 02080 } 02081 02082 /// \brief Form a dependent template name. 02083 /// 02084 /// This action forms a dependent template name given the template 02085 /// name and its (presumably dependent) scope specifier. For 02086 /// example, given "MetaFun::template apply", the scope specifier \p 02087 /// SS will be "MetaFun::", \p TemplateKWLoc contains the location 02088 /// of the "template" keyword, and "apply" is the \p Name. 02089 /// 02090 /// \param S The scope in which the dependent template name was parsed. 02091 /// 02092 /// \param TemplateKWLoc the location of the "template" keyword (if any). 02093 /// 02094 /// \param SS the nested-name-specifier that precedes the "template" keyword 02095 /// or the template name. If the dependent template name occurs in 02096 /// a member access expression, e.g., "x.template f<T>", this 02097 /// nested-name-specifier will be empty. 02098 /// 02099 /// \param Name the name of the template. 02100 /// 02101 /// \param ObjectType if this dependent template name occurs in the 02102 /// context of a member access expression, the type of the object being 02103 /// accessed. 02104 /// 02105 /// \param EnteringContext whether we are entering the context of this 02106 /// template. 02107 /// 02108 /// \param Template Will be set to the dependent template name, on success. 02109 /// 02110 /// \returns The kind of template name that was produced. Generally, this will 02111 /// be \c TNK_Dependent_template_name. However, if the nested-name-specifier 02112 /// is not dependent, or refers to the current instantiation, then we may 02113 /// be able to resolve the template kind more specifically. 02114 virtual TemplateNameKind ActOnDependentTemplateName(Scope *S, 02115 SourceLocation TemplateKWLoc, 02116 CXXScopeSpec &SS, 02117 UnqualifiedId &Name, 02118 TypeTy *ObjectType, 02119 bool EnteringContext, 02120 TemplateTy &Template) { 02121 return TNK_Non_template; 02122 } 02123 02124 /// \brief Process the declaration or definition of an explicit 02125 /// class template specialization or a class template partial 02126 /// specialization. 02127 /// 02128 /// This routine is invoked when an explicit class template 02129 /// specialization or a class template partial specialization is 02130 /// declared or defined, to introduce the (partial) specialization 02131 /// and produce a declaration for it. In the following example, 02132 /// ActOnClassTemplateSpecialization will be invoked for the 02133 /// declarations at both A and B: 02134 /// 02135 /// \code 02136 /// template<typename T> class X; 02137 /// template<> class X<int> { }; // A: explicit specialization 02138 /// template<typename T> class X<T*> { }; // B: partial specialization 02139 /// \endcode 02140 /// 02141 /// Note that it is the job of semantic analysis to determine which 02142 /// of the two cases actually occurred in the source code, since 02143 /// they are parsed through the same path. The formulation of the 02144 /// template parameter lists describes which case we are in. 02145 /// 02146 /// \param S the current scope 02147 /// 02148 /// \param TagSpec whether this declares a class, struct, or union 02149 /// (template) 02150 /// 02151 /// \param TUK whether this is a declaration or a definition 02152 /// 02153 /// \param KWLoc the location of the 'class', 'struct', or 'union' 02154 /// keyword. 02155 /// 02156 /// \param SS the scope specifier preceding the template-id 02157 /// 02158 /// \param Template the declaration of the class template that we 02159 /// are specializing. 02160 /// 02161 /// \param Attr attributes on the specialization 02162 /// 02163 /// \param TemplateParameterLists the set of template parameter 02164 /// lists that apply to this declaration. In a well-formed program, 02165 /// the number of template parameter lists will be one more than the 02166 /// number of template-ids in the scope specifier. However, it is 02167 /// common for users to provide the wrong number of template 02168 /// parameter lists (such as a missing \c template<> prior to a 02169 /// specialization); the parser does not check this condition. 02170 virtual DeclResult 02171 ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, 02172 SourceLocation KWLoc, 02173 CXXScopeSpec &SS, 02174 TemplateTy Template, 02175 SourceLocation TemplateNameLoc, 02176 SourceLocation LAngleLoc, 02177 ASTTemplateArgsPtr TemplateArgs, 02178 SourceLocation RAngleLoc, 02179 AttributeList *Attr, 02180 MultiTemplateParamsArg TemplateParameterLists) { 02181 return DeclResult(); 02182 } 02183 02184 /// \brief Invoked when a declarator that has one or more template parameter 02185 /// lists has been parsed. 02186 /// 02187 /// This action is similar to ActOnDeclarator(), except that the declaration 02188 /// being created somehow involves a template, e.g., it is a template 02189 /// declaration or specialization. 02190 virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S, 02191 MultiTemplateParamsArg TemplateParameterLists, 02192 Declarator &D) { 02193 return DeclPtrTy(); 02194 } 02195 02196 /// \brief Invoked when the parser is beginning to parse a function template 02197 /// or function template specialization definition. 02198 virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope, 02199 MultiTemplateParamsArg TemplateParameterLists, 02200 Declarator &D) { 02201 return DeclPtrTy(); 02202 } 02203 02204 /// \brief Process the explicit instantiation of a class template 02205 /// specialization. 02206 /// 02207 /// This routine is invoked when an explicit instantiation of a 02208 /// class template specialization is encountered. In the following 02209 /// example, ActOnExplicitInstantiation will be invoked to force the 02210 /// instantiation of X<int>: 02211 /// 02212 /// \code 02213 /// template<typename T> class X { /* ... */ }; 02214 /// template class X<int>; // explicit instantiation 02215 /// \endcode 02216 /// 02217 /// \param S the current scope 02218 /// 02219 /// \param ExternLoc the location of the 'extern' keyword that specifies that 02220 /// this is an extern template (if any). 02221 /// 02222 /// \param TemplateLoc the location of the 'template' keyword that 02223 /// specifies that this is an explicit instantiation. 02224 /// 02225 /// \param TagSpec whether this declares a class, struct, or union 02226 /// (template). 02227 /// 02228 /// \param KWLoc the location of the 'class', 'struct', or 'union' 02229 /// keyword. 02230 /// 02231 /// \param SS the scope specifier preceding the template-id. 02232 /// 02233 /// \param Template the declaration of the class template that we 02234 /// are instantiation. 02235 /// 02236 /// \param LAngleLoc the location of the '<' token in the template-id. 02237 /// 02238 /// \param TemplateArgs the template arguments used to form the 02239 /// template-id. 02240 /// 02241 /// \param TemplateArgLocs the locations of the template arguments. 02242 /// 02243 /// \param RAngleLoc the location of the '>' token in the template-id. 02244 /// 02245 /// \param Attr attributes that apply to this instantiation. 02246 virtual DeclResult 02247 ActOnExplicitInstantiation(Scope *S, 02248 SourceLocation ExternLoc, 02249 SourceLocation TemplateLoc, 02250 unsigned TagSpec, 02251 SourceLocation KWLoc, 02252 const CXXScopeSpec &SS, 02253 TemplateTy Template, 02254 SourceLocation TemplateNameLoc, 02255 SourceLocation LAngleLoc, 02256 ASTTemplateArgsPtr TemplateArgs, 02257 SourceLocation RAngleLoc, 02258 AttributeList *Attr) { 02259 return DeclResult(); 02260 } 02261 02262 /// \brief Process the explicit instantiation of a member class of a 02263 /// class template specialization. 02264 /// 02265 /// This routine is invoked when an explicit instantiation of a 02266 /// member class of a class template specialization is 02267 /// encountered. In the following example, 02268 /// ActOnExplicitInstantiation will be invoked to force the 02269 /// instantiation of X<int>::Inner: 02270 /// 02271 /// \code 02272 /// template<typename T> class X { class Inner { /* ... */}; }; 02273 /// template class X<int>::Inner; // explicit instantiation 02274 /// \endcode 02275 /// 02276 /// \param S the current scope 02277 /// 02278 /// \param ExternLoc the location of the 'extern' keyword that specifies that 02279 /// this is an extern template (if any). 02280 /// 02281 /// \param TemplateLoc the location of the 'template' keyword that 02282 /// specifies that this is an explicit instantiation. 02283 /// 02284 /// \param TagSpec whether this declares a class, struct, or union 02285 /// (template). 02286 /// 02287 /// \param KWLoc the location of the 'class', 'struct', or 'union' 02288 /// keyword. 02289 /// 02290 /// \param SS the scope specifier preceding the template-id. 02291 /// 02292 /// \param Template the declaration of the class template that we 02293 /// are instantiation. 02294 /// 02295 /// \param LAngleLoc the location of the '<' token in the template-id. 02296 /// 02297 /// \param TemplateArgs the template arguments used to form the 02298 /// template-id. 02299 /// 02300 /// \param TemplateArgLocs the locations of the template arguments. 02301 /// 02302 /// \param RAngleLoc the location of the '>' token in the template-id. 02303 /// 02304 /// \param Attr attributes that apply to this instantiation. 02305 virtual DeclResult 02306 ActOnExplicitInstantiation(Scope *S, 02307 SourceLocation ExternLoc, 02308 SourceLocation TemplateLoc, 02309 unsigned TagSpec, 02310 SourceLocation KWLoc, 02311 CXXScopeSpec &SS, 02312 IdentifierInfo *Name, 02313 SourceLocation NameLoc, 02314 AttributeList *Attr) { 02315 return DeclResult(); 02316 } 02317 02318 /// \brief Process the explicit instantiation of a function template or a 02319 /// member of a class template. 02320 /// 02321 /// This routine is invoked when an explicit instantiation of a 02322 /// function template or member function of a class template specialization 02323 /// is encountered. In the following example, 02324 /// ActOnExplicitInstantiation will be invoked to force the 02325 /// instantiation of X<int>: 02326 /// 02327 /// \code 02328 /// template<typename T> void f(T); 02329 /// template void f(int); // explicit instantiation 02330 /// \endcode 02331 /// 02332 /// \param S the current scope 02333 /// 02334 /// \param ExternLoc the location of the 'extern' keyword that specifies that 02335 /// this is an extern template (if any). 02336 /// 02337 /// \param TemplateLoc the location of the 'template' keyword that 02338 /// specifies that this is an explicit instantiation. 02339 /// 02340 /// \param D the declarator describing the declaration to be implicitly 02341 /// instantiated. 02342 virtual DeclResult ActOnExplicitInstantiation(Scope *S, 02343 SourceLocation ExternLoc, 02344 SourceLocation TemplateLoc, 02345 Declarator &D) { 02346 return DeclResult(); 02347 } 02348 02349 02350 /// \brief Called when the parser has parsed a C++ typename 02351 /// specifier that ends in an identifier, e.g., "typename T::type". 02352 /// 02353 /// \param TypenameLoc the location of the 'typename' keyword 02354 /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). 02355 /// \param II the identifier we're retrieving (e.g., 'type' in the example). 02356 /// \param IdLoc the location of the identifier. 02357 virtual TypeResult 02358 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 02359 const CXXScopeSpec &SS, const IdentifierInfo &II, 02360 SourceLocation IdLoc) { 02361 return TypeResult(); 02362 } 02363 02364 /// \brief Called when the parser has parsed a C++ typename 02365 /// specifier that ends in a template-id, e.g., 02366 /// "typename MetaFun::template apply<T1, T2>". 02367 /// 02368 /// \param TypenameLoc the location of the 'typename' keyword 02369 /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). 02370 /// \param TemplateLoc the location of the 'template' keyword, if any. 02371 /// \param Ty the type that the typename specifier refers to. 02372 virtual TypeResult 02373 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 02374 const CXXScopeSpec &SS, SourceLocation TemplateLoc, 02375 TypeTy *Ty) { 02376 return TypeResult(); 02377 } 02378 02379 /// \brief Called when the parser begins parsing a construct which should not 02380 /// have access control applied to it. 02381 virtual void ActOnStartSuppressingAccessChecks() { 02382 } 02383 02384 /// \brief Called when the parser finishes parsing a construct which should 02385 /// not have access control applied to it. 02386 virtual void ActOnStopSuppressingAccessChecks() { 02387 } 02388 02389 //===----------------------- Obj-C Declarations -------------------------===// 02390 02391 // ActOnStartClassInterface - this action is called immediately after parsing 02392 // the prologue for a class interface (before parsing the instance 02393 // variables). Instance variables are processed by ActOnFields(). 02394 virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc, 02395 IdentifierInfo *ClassName, 02396 SourceLocation ClassLoc, 02397 IdentifierInfo *SuperName, 02398 SourceLocation SuperLoc, 02399 const DeclPtrTy *ProtoRefs, 02400 unsigned NumProtoRefs, 02401 const SourceLocation *ProtoLocs, 02402 SourceLocation EndProtoLoc, 02403 AttributeList *AttrList) { 02404 return DeclPtrTy(); 02405 } 02406 02407 /// ActOnCompatiblityAlias - this action is called after complete parsing of 02408 /// @compaatibility_alias declaration. It sets up the alias relationships. 02409 virtual DeclPtrTy ActOnCompatiblityAlias( 02410 SourceLocation AtCompatibilityAliasLoc, 02411 IdentifierInfo *AliasName, SourceLocation AliasLocation, 02412 IdentifierInfo *ClassName, SourceLocation ClassLocation) { 02413 return DeclPtrTy(); 02414 } 02415 02416 // ActOnStartProtocolInterface - this action is called immdiately after 02417 // parsing the prologue for a protocol interface. 02418 virtual DeclPtrTy ActOnStartProtocolInterface(SourceLocation AtProtoLoc, 02419 IdentifierInfo *ProtocolName, 02420 SourceLocation ProtocolLoc, 02421 const DeclPtrTy *ProtoRefs, 02422 unsigned NumProtoRefs, 02423 const SourceLocation *ProtoLocs, 02424 SourceLocation EndProtoLoc, 02425 AttributeList *AttrList) { 02426 return DeclPtrTy(); 02427 } 02428 // ActOnStartCategoryInterface - this action is called immdiately after 02429 // parsing the prologue for a category interface. 02430 virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, 02431 IdentifierInfo *ClassName, 02432 SourceLocation ClassLoc, 02433 IdentifierInfo *CategoryName, 02434 SourceLocation CategoryLoc, 02435 const DeclPtrTy *ProtoRefs, 02436 unsigned NumProtoRefs, 02437 const SourceLocation *ProtoLocs, 02438 SourceLocation EndProtoLoc) { 02439 return DeclPtrTy(); 02440 } 02441 // ActOnStartClassImplementation - this action is called immdiately after 02442 // parsing the prologue for a class implementation. Instance variables are 02443 // processed by ActOnFields(). 02444 virtual DeclPtrTy ActOnStartClassImplementation( 02445 SourceLocation AtClassImplLoc, 02446 IdentifierInfo *ClassName, 02447 SourceLocation ClassLoc, 02448 IdentifierInfo *SuperClassname, 02449 SourceLocation SuperClassLoc) { 02450 return DeclPtrTy(); 02451 } 02452 // ActOnStartCategoryImplementation - this action is called immdiately after 02453 // parsing the prologue for a category implementation. 02454 virtual DeclPtrTy ActOnStartCategoryImplementation( 02455 SourceLocation AtCatImplLoc, 02456 IdentifierInfo *ClassName, 02457 SourceLocation ClassLoc, 02458 IdentifierInfo *CatName, 02459 SourceLocation CatLoc) { 02460 return DeclPtrTy(); 02461 } 02462 // ActOnPropertyImplDecl - called for every property implementation 02463 virtual DeclPtrTy ActOnPropertyImplDecl( 02464 Scope *S, 02465 SourceLocation AtLoc, // location of the @synthesize/@dynamic 02466 SourceLocation PropertyNameLoc, // location for the property name 02467 bool ImplKind, // true for @synthesize, false for 02468 // @dynamic 02469 DeclPtrTy ClassImplDecl, // class or category implementation 02470 IdentifierInfo *propertyId, // name of property 02471 IdentifierInfo *propertyIvar) { // name of the ivar 02472 return DeclPtrTy(); 02473 } 02474 02475 struct ObjCArgInfo { 02476 IdentifierInfo *Name; 02477 SourceLocation NameLoc; 02478 // The Type is null if no type was specified, and the DeclSpec is invalid 02479 // in this case. 02480 TypeTy *Type; 02481 ObjCDeclSpec DeclSpec; 02482 02483 /// ArgAttrs - Attribute list for this argument. 02484 AttributeList *ArgAttrs; 02485 }; 02486 02487 // ActOnMethodDeclaration - called for all method declarations. 02488 virtual DeclPtrTy ActOnMethodDeclaration( 02489 SourceLocation BeginLoc, // location of the + or -. 02490 SourceLocation EndLoc, // location of the ; or {. 02491 tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class. 02492 DeclPtrTy ClassDecl, // class this methods belongs to. 02493 ObjCDeclSpec &ReturnQT, // for return type's in inout etc. 02494 TypeTy *ReturnType, // the method return type. 02495 Selector Sel, // a unique name for the method. 02496 ObjCArgInfo *ArgInfo, // ArgInfo: Has 'Sel.getNumArgs()' entries. 02497 DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args 02498 AttributeList *MethodAttrList, // optional 02499 // tok::objc_not_keyword, tok::objc_optional, tok::objc_required 02500 tok::ObjCKeywordKind impKind, 02501 bool isVariadic = false) { 02502 return DeclPtrTy(); 02503 } 02504 // ActOnAtEnd - called to mark the @end. For declarations (interfaces, 02505 // protocols, categories), the parser passes all methods/properties. 02506 // For class implementations, these values default to 0. For implementations, 02507 // methods are processed incrementally (by ActOnMethodDeclaration above). 02508 virtual void ActOnAtEnd(Scope *S, SourceRange AtEnd, 02509 DeclPtrTy classDecl, 02510 DeclPtrTy *allMethods = 0, 02511 unsigned allNum = 0, 02512 DeclPtrTy *allProperties = 0, 02513 unsigned pNum = 0, 02514 DeclGroupPtrTy *allTUVars = 0, 02515 unsigned tuvNum = 0) { 02516 } 02517 // ActOnProperty - called to build one property AST 02518 virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc, 02519 FieldDeclarator &FD, ObjCDeclSpec &ODS, 02520 Selector GetterSel, Selector SetterSel, 02521 DeclPtrTy ClassCategory, 02522 bool *OverridingProperty, 02523 tok::ObjCKeywordKind MethodImplKind) { 02524 return DeclPtrTy(); 02525 } 02526 02527 virtual OwningExprResult 02528 ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, 02529 IdentifierInfo &propertyName, 02530 SourceLocation receiverNameLoc, 02531 SourceLocation propertyNameLoc) { 02532 return ExprEmpty(); 02533 } 02534 02535 /// \brief Describes the kind of message expression indicated by a message 02536 /// send that starts with an identifier. 02537 enum ObjCMessageKind { 02538 /// \brief The message is sent to 'super'. 02539 ObjCSuperMessage, 02540 /// \brief The message is an instance message. 02541 ObjCInstanceMessage, 02542 /// \brief The message is a class message, and the identifier is a type 02543 /// name. 02544 ObjCClassMessage 02545 }; 02546 02547 /// \brief Determine the kind of Objective-C message send that we will be 02548 /// performing based on the identifier given. 02549 /// 02550 /// This action determines how a message send that starts with [ 02551 /// identifier (followed by another identifier) will be parsed, 02552 /// e.g., as a class message, instance message, super message. The 02553 /// result depends on the meaning of the given identifier. If the 02554 /// identifier is unknown, the action should indicate that the 02555 /// message is an instance message. 02556 /// 02557 /// By default, this routine applies syntactic disambiguation and uses 02558 /// \c getTypeName() to determine whether the identifier refers to a type. 02559 /// However, \c Action subclasses may override this routine to improve 02560 /// error recovery. 02561 /// 02562 /// \param S The scope in which the message send occurs. 02563 /// 02564 /// \param Name The identifier following the '['. 02565 /// 02566 /// \param NameLoc The location of the identifier. 02567 /// 02568 /// \param IsSuper Whether the name is the pseudo-keyword "super". 02569 /// 02570 /// \param HasTrailingDot Whether the name is followed by a period. 02571 /// 02572 /// \param ReceiverType If this routine returns \c ObjCClassMessage, 02573 /// this argument will be set to the receiver type. 02574 /// 02575 /// \returns The kind of message send. 02576 virtual ObjCMessageKind getObjCMessageKind(Scope *S, 02577 IdentifierInfo *Name, 02578 SourceLocation NameLoc, 02579 bool IsSuper, 02580 bool HasTrailingDot, 02581 TypeTy *&ReceiverType); 02582 02583 /// \brief Parsed a message send to 'super'. 02584 /// 02585 /// \param S The scope in which the message send occurs. 02586 /// \param SuperLoc The location of the 'super' keyword. 02587 /// \param Sel The selector to which the message is being sent. 02588 /// \param LBracLoc The location of the opening square bracket ']'. 02589 /// \param SelectorLoc The location of the first identifier in the selector. 02590 /// \param RBrac The location of the closing square bracket ']'. 02591 /// \param Args The message arguments. 02592 virtual OwningExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, 02593 Selector Sel, 02594 SourceLocation LBracLoc, 02595 SourceLocation SelectorLoc, 02596 SourceLocation RBracLoc, 02597 MultiExprArg Args) { 02598 return OwningExprResult(*this); 02599 } 02600 02601 /// \brief Parsed a message send to a class. 02602 /// 02603 /// \param S The scope in which the message send occurs. 02604 /// \param Receiver The type of the class receiving the message. 02605 /// \param Sel The selector to which the message is being sent. 02606 /// \param LBracLoc The location of the opening square bracket ']'. 02607 /// \param SelectorLoc The location of the first identifier in the selector. 02608 /// \param RBrac The location of the closing square bracket ']'. 02609 /// \param Args The message arguments. 02610 virtual OwningExprResult ActOnClassMessage(Scope *S, 02611 TypeTy *Receiver, 02612 Selector Sel, 02613 SourceLocation LBracLoc, 02614 SourceLocation SelectorLoc, 02615 SourceLocation RBracLoc, 02616 MultiExprArg Args) { 02617 return OwningExprResult(*this); 02618 } 02619 02620 /// \brief Parsed a message send to an object instance. 02621 /// 02622 /// \param S The scope in which the message send occurs. 02623 /// \param Receiver The expression that computes the receiver object. 02624 /// \param Sel The selector to which the message is being sent. 02625 /// \param LBracLoc The location of the opening square bracket ']'. 02626 /// \param SelectorLoc The location of the first identifier in the selector. 02627 /// \param RBrac The location of the closing square bracket ']'. 02628 /// \param Args The message arguments. 02629 virtual OwningExprResult ActOnInstanceMessage(Scope *S, 02630 ExprArg Receiver, 02631 Selector Sel, 02632 SourceLocation LBracLoc, 02633 SourceLocation SelectorLoc, 02634 SourceLocation RBracLoc, 02635 MultiExprArg Args) { 02636 return OwningExprResult(*this); 02637 } 02638 02639 virtual DeclPtrTy ActOnForwardClassDeclaration( 02640 SourceLocation AtClassLoc, 02641 IdentifierInfo **IdentList, 02642 SourceLocation *IdentLocs, 02643 unsigned NumElts) { 02644 return DeclPtrTy(); 02645 } 02646 virtual DeclPtrTy ActOnForwardProtocolDeclaration( 02647 SourceLocation AtProtocolLoc, 02648 const IdentifierLocPair*IdentList, 02649 unsigned NumElts, 02650 AttributeList *AttrList) { 02651 return DeclPtrTy(); 02652 } 02653 02654 /// FindProtocolDeclaration - This routine looks up protocols and 02655 /// issues error if they are not declared. It returns list of valid 02656 /// protocols found. 02657 virtual void FindProtocolDeclaration(bool WarnOnDeclarations, 02658 const IdentifierLocPair *ProtocolId, 02659 unsigned NumProtocols, 02660 llvm::SmallVectorImpl<DeclPtrTy> &ResProtos) { 02661 } 02662 02663 //===----------------------- Obj-C Expressions --------------------------===// 02664 02665 virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, 02666 ExprTy **Strings, 02667 unsigned NumStrings) { 02668 return ExprResult(); 02669 } 02670 02671 virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, 02672 SourceLocation EncLoc, 02673 SourceLocation LParenLoc, 02674 TypeTy *Ty, 02675 SourceLocation RParenLoc) { 02676 return ExprResult(); 02677 } 02678 02679 virtual ExprResult ParseObjCSelectorExpression(Selector Sel, 02680 SourceLocation AtLoc, 02681 SourceLocation SelLoc, 02682 SourceLocation LParenLoc, 02683 SourceLocation RParenLoc) { 02684 return ExprResult(); 02685 } 02686 02687 virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolId, 02688 SourceLocation AtLoc, 02689 SourceLocation ProtoLoc, 02690 SourceLocation LParenLoc, 02691 SourceLocation RParenLoc) { 02692 return ExprResult(); 02693 } 02694 02695 //===---------------------------- Pragmas -------------------------------===// 02696 02697 enum PragmaOptionsAlignKind { 02698 POAK_Native, // #pragma options align=native 02699 POAK_Natural, // #pragma options align=natural 02700 POAK_Packed, // #pragma options align=packed 02701 POAK_Power, // #pragma options align=power 02702 POAK_Mac68k, // #pragma options align=mac68k 02703 POAK_Reset // #pragma options align=reset 02704 }; 02705 02706 /// ActOnPragmaOptionsAlign - Called on well formed #pragma options 02707 /// align={...}. 02708 virtual void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, 02709 SourceLocation PragmaLoc, 02710 SourceLocation KindLoc) { 02711 return; 02712 } 02713 02714 enum PragmaPackKind { 02715 PPK_Default, // #pragma pack([n]) 02716 PPK_Show, // #pragma pack(show), only supported by MSVC. 02717 PPK_Push, // #pragma pack(push, [identifier], [n]) 02718 PPK_Pop // #pragma pack(pop, [identifier], [n]) 02719 }; 02720 02721 /// ActOnPragmaPack - Called on well formed #pragma pack(...). 02722 virtual void ActOnPragmaPack(PragmaPackKind Kind, 02723 IdentifierInfo *Name, 02724 ExprTy *Alignment, 02725 SourceLocation PragmaLoc, 02726 SourceLocation LParenLoc, 02727 SourceLocation RParenLoc) { 02728 return; 02729 } 02730 02731 /// ActOnPragmaUnused - Called on well formed #pragma unused(...). 02732 virtual void ActOnPragmaUnused(const Token *Identifiers, 02733 unsigned NumIdentifiers, Scope *CurScope, 02734 SourceLocation PragmaLoc, 02735 SourceLocation LParenLoc, 02736 SourceLocation RParenLoc) { 02737 return; 02738 } 02739 02740 02741 /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... . 02742 virtual void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType, 02743 SourceLocation PragmaLoc) { 02744 return; 02745 } 02746 02747 02748 /// ActOnPragmaWeakID - Called on well formed #pragma weak ident. 02749 virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName, 02750 SourceLocation PragmaLoc, 02751 SourceLocation WeakNameLoc) { 02752 return; 02753 } 02754 02755 /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident. 02756 virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName, 02757 IdentifierInfo* AliasName, 02758 SourceLocation PragmaLoc, 02759 SourceLocation WeakNameLoc, 02760 SourceLocation AliasNameLoc) { 02761 return; 02762 } 02763 02764 /// \name Code completion actions 02765 /// 02766 /// These actions are used to signal that a code-completion token has been 02767 /// found at a point in the grammar where the Action implementation is 02768 /// likely to be able to provide a list of possible completions, e.g., 02769 /// after the "." or "->" of a member access expression. 02770 /// 02771 /// \todo Code completion for designated field initializers 02772 /// \todo Code completion for call arguments after a function template-id 02773 /// \todo Code completion within a call expression, object construction, etc. 02774 /// \todo Code completion within a template argument list. 02775 /// \todo Code completion for attributes. 02776 //@{ 02777 02778 /// \brief Describes the context in which code completion occurs. 02779 enum ParserCompletionContext { 02780 /// \brief Code completion occurs at top-level or namespace context. 02781 PCC_Namespace, 02782 /// \brief Code completion occurs within a class, struct, or union. 02783 PCC_Class, 02784 /// \brief Code completion occurs within an Objective-C interface, protocol, 02785 /// or category. 02786 PCC_ObjCInterface, 02787 /// \brief Code completion occurs within an Objective-C implementation or 02788 /// category implementation 02789 PCC_ObjCImplementation, 02790 /// \brief Code completion occurs within the list of instance variables 02791 /// in an Objective-C interface, protocol, category, or implementation. 02792 PCC_ObjCInstanceVariableList, 02793 /// \brief Code completion occurs following one or more template 02794 /// headers. 02795 PCC_Template, 02796 /// \brief Code completion occurs following one or more template 02797 /// headers within a class. 02798 PCC_MemberTemplate, 02799 /// \brief Code completion occurs within an expression. 02800 PCC_Expression, 02801 /// \brief Code completion occurs within a statement, which may 02802 /// also be an expression or a declaration. 02803 PCC_Statement, 02804 /// \brief Code completion occurs at the beginning of the 02805 /// initialization statement (or expression) in a for loop. 02806 PCC_ForInit, 02807 /// \brief Code completion occurs within the condition of an if, 02808 /// while, switch, or for statement. 02809 PCC_Condition, 02810 /// \brief Code completion occurs within the body of a function on a 02811 /// recovery path, where we do not have a specific handle on our position 02812 /// in the grammar. 02813 PCC_RecoveryInFunction 02814 }; 02815 02816 /// \brief Code completion for an ordinary name that occurs within the given 02817 /// scope. 02818 /// 02819 /// \param S the scope in which the name occurs. 02820 /// 02821 /// \param CompletionContext the context in which code completion 02822 /// occurs. 02823 virtual void CodeCompleteOrdinaryName(Scope *S, 02824 ParserCompletionContext CompletionContext) { } 02825 02826 /// \brief Code completion for a member access expression. 02827 /// 02828 /// This code completion action is invoked when the code-completion token 02829 /// is found after the "." or "->" of a member access expression. 02830 /// 02831 /// \param S the scope in which the member access expression occurs. 02832 /// 02833 /// \param Base the base expression (e.g., the x in "x.foo") of the member 02834 /// access. 02835 /// 02836 /// \param OpLoc the location of the "." or "->" operator. 02837 /// 02838 /// \param IsArrow true when the operator is "->", false when it is ".". 02839 virtual void CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *Base, 02840 SourceLocation OpLoc, 02841 bool IsArrow) { } 02842 02843 /// \brief Code completion for a reference to a tag. 02844 /// 02845 /// This code completion action is invoked when the code-completion 02846 /// token is found after a tag keyword (struct, union, enum, or class). 02847 /// 02848 /// \param S the scope in which the tag reference occurs. 02849 /// 02850 /// \param TagSpec an instance of DeclSpec::TST, indicating what kind of tag 02851 /// this is (struct/union/enum/class). 02852 virtual void CodeCompleteTag(Scope *S, unsigned TagSpec) { } 02853 02854 /// \brief Code completion for a case statement. 02855 /// 02856 /// \brief S the scope in which the case statement occurs. 02857 virtual void CodeCompleteCase(Scope *S) { } 02858 02859 /// \brief Code completion for a call. 02860 /// 02861 /// \brief S the scope in which the call occurs. 02862 /// 02863 /// \param Fn the expression describing the function being called. 02864 /// 02865 /// \param Args the arguments to the function call (so far). 02866 /// 02867 /// \param NumArgs the number of arguments in \p Args. 02868 virtual void CodeCompleteCall(Scope *S, ExprTy *Fn, 02869 ExprTy **Args, unsigned NumArgs) { } 02870 02871 /// \brief Code completion for the initializer of a variable declaration. 02872 /// 02873 /// \param S The scope in which the initializer occurs. 02874 /// 02875 /// \param D The declaration being initialized. 02876 virtual void CodeCompleteInitializer(Scope *S, DeclPtrTy D) { } 02877 02878 /// \brief Code completion after the "return" keyword within a function. 02879 /// 02880 /// \param S The scope in which the return statement occurs. 02881 virtual void CodeCompleteReturn(Scope *S) { } 02882 02883 /// \brief Code completion for the right-hand side of an assignment or 02884 /// compound assignment operator. 02885 /// 02886 /// \param S The scope in which the assignment occurs. 02887 /// 02888 /// \param LHS The left-hand side of the assignment expression. 02889 virtual void CodeCompleteAssignmentRHS(Scope *S, ExprTy *LHS) { } 02890 02891 /// \brief Code completion for a C++ nested-name-specifier that precedes a 02892 /// qualified-id of some form. 02893 /// 02894 /// This code completion action is invoked when the code-completion token 02895 /// is found after the "::" of a nested-name-specifier. 02896 /// 02897 /// \param S the scope in which the nested-name-specifier occurs. 02898 /// 02899 /// \param SS the scope specifier ending with "::". 02900 /// 02901 /// \parame EnteringContext whether we're entering the context of this 02902 /// scope specifier. 02903 virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, 02904 bool EnteringContext) { } 02905 02906 /// \brief Code completion for a C++ "using" declaration or directive. 02907 /// 02908 /// This code completion action is invoked when the code-completion token is 02909 /// found after the "using" keyword. 02910 /// 02911 /// \param S the scope in which the "using" occurs. 02912 virtual void CodeCompleteUsing(Scope *S) { } 02913 02914 /// \brief Code completion for a C++ using directive. 02915 /// 02916 /// This code completion action is invoked when the code-completion token is 02917 /// found after "using namespace". 02918 /// 02919 /// \param S the scope in which the "using namespace" occurs. 02920 virtual void CodeCompleteUsingDirective(Scope *S) { } 02921 02922 /// \brief Code completion for a C++ namespace declaration or namespace 02923 /// alias declaration. 02924 /// 02925 /// This code completion action is invoked when the code-completion token is 02926 /// found after "namespace". 02927 /// 02928 /// \param S the scope in which the "namespace" token occurs. 02929 virtual void CodeCompleteNamespaceDecl(Scope *S) { } 02930 02931 /// \brief Code completion for a C++ namespace alias declaration. 02932 /// 02933 /// This code completion action is invoked when the code-completion token is 02934 /// found after "namespace identifier = ". 02935 /// 02936 /// \param S the scope in which the namespace alias declaration occurs. 02937 virtual void CodeCompleteNamespaceAliasDecl(Scope *S) { } 02938 02939 /// \brief Code completion for an operator name. 02940 /// 02941 /// This code completion action is invoked when the code-completion token is 02942 /// found after the keyword "operator". 02943 /// 02944 /// \param S the scope in which the operator keyword occurs. 02945 virtual void CodeCompleteOperatorName(Scope *S) { } 02946 02947 /// \brief Code completion after the '@' at the top level. 02948 /// 02949 /// \param S the scope in which the '@' occurs. 02950 /// 02951 /// \param ObjCImpDecl the Objective-C implementation or category 02952 /// implementation. 02953 /// 02954 /// \param InInterface whether we are in an Objective-C interface or 02955 /// protocol. 02956 virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl, 02957 bool InInterface) { } 02958 02959 /// \brief Code completion after the '@' in the list of instance variables. 02960 virtual void CodeCompleteObjCAtVisibility(Scope *S) { } 02961 02962 /// \brief Code completion after the '@' in a statement. 02963 virtual void CodeCompleteObjCAtStatement(Scope *S) { } 02964 02965 /// \brief Code completion after the '@' in an expression. 02966 virtual void CodeCompleteObjCAtExpression(Scope *S) { } 02967 02968 /// \brief Code completion for an ObjC property decl. 02969 /// 02970 /// This code completion action is invoked when the code-completion token is 02971 /// found after the left paren. 02972 /// 02973 /// \param S the scope in which the operator keyword occurs. 02974 virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) { } 02975 02976 /// \brief Code completion for the getter of an Objective-C property 02977 /// declaration. 02978 /// 02979 /// This code completion action is invoked when the code-completion 02980 /// token is found after the "getter = " in a property declaration. 02981 /// 02982 /// \param S the scope in which the property is being declared. 02983 /// 02984 /// \param ClassDecl the Objective-C class or category in which the property 02985 /// is being defined. 02986 /// 02987 /// \param Methods the set of methods declared thus far within \p ClassDecl. 02988 /// 02989 /// \param NumMethods the number of methods in \p Methods 02990 virtual void CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl, 02991 DeclPtrTy *Methods, 02992 unsigned NumMethods) { 02993 } 02994 02995 /// \brief Code completion for the setter of an Objective-C property 02996 /// declaration. 02997 /// 02998 /// This code completion action is invoked when the code-completion 02999 /// token is found after the "setter = " in a property declaration. 03000 /// 03001 /// \param S the scope in which the property is being declared. 03002 /// 03003 /// \param ClassDecl the Objective-C class or category in which the property 03004 /// is being defined. 03005 /// 03006 /// \param Methods the set of methods declared thus far within \p ClassDecl. 03007 /// 03008 /// \param NumMethods the number of methods in \p Methods 03009 virtual void CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ClassDecl, 03010 DeclPtrTy *Methods, 03011 unsigned NumMethods) { 03012 } 03013 03014 /// \brief Code completion for the receiver in an Objective-C message send. 03015 /// 03016 /// This code completion action is invoked when we see a '[' that indicates 03017 /// the start of an Objective-C message send. 03018 /// 03019 /// \param S The scope in which the Objective-C message send occurs. 03020 virtual void CodeCompleteObjCMessageReceiver(Scope *S) { } 03021 03022 /// \brief Code completion for an ObjC message expression that sends 03023 /// a message to the superclass. 03024 /// 03025 /// This code completion action is invoked when the code-completion token is 03026 /// found after the class name and after each argument. 03027 /// 03028 /// \param S The scope in which the message expression occurs. 03029 /// \param SuperLoc The location of the 'super' keyword. 03030 /// \param SelIdents The identifiers that describe the selector (thus far). 03031 /// \param NumSelIdents The number of identifiers in \p SelIdents. 03032 virtual void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, 03033 IdentifierInfo **SelIdents, 03034 unsigned NumSelIdents) { } 03035 03036 /// \brief Code completion for an ObjC message expression that refers to 03037 /// a class method. 03038 /// 03039 /// This code completion action is invoked when the code-completion token is 03040 /// found after the class name and after each argument. 03041 /// 03042 /// \param S The scope in which the message expression occurs. 03043 /// \param Receiver The type of the class that is receiving a message. 03044 /// \param SelIdents The identifiers that describe the selector (thus far). 03045 /// \param NumSelIdents The number of identifiers in \p SelIdents. 03046 virtual void CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver, 03047 IdentifierInfo **SelIdents, 03048 unsigned NumSelIdents) { } 03049 03050 /// \brief Code completion for an ObjC message expression that refers to 03051 /// an instance method. 03052 /// 03053 /// This code completion action is invoked when the code-completion token is 03054 /// found after the receiver expression and after each argument. 03055 /// 03056 /// \param S the scope in which the operator keyword occurs. 03057 /// \param Receiver an expression for the receiver of the message. 03058 /// \param SelIdents the identifiers that describe the selector (thus far). 03059 /// \param NumSelIdents the number of identifiers in \p SelIdents. 03060 virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver, 03061 IdentifierInfo **SelIdents, 03062 unsigned NumSelIdents) { } 03063 03064 /// \brief Code completion for a list of protocol references in Objective-C, 03065 /// such as P1 and P2 in \c id<P1,P2>. 03066 /// 03067 /// This code completion action is invoked prior to each identifier 03068 /// in the protocol list. 03069 /// 03070 /// \param Protocols the set of protocols that have already been parsed. 03071 /// 03072 /// \param NumProtocols the number of protocols that have already been 03073 /// parsed. 03074 virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols, 03075 unsigned NumProtocols) { } 03076 03077 /// \brief Code completion for a protocol declaration or definition, after 03078 /// the @protocol but before any identifier. 03079 /// 03080 /// \param S the scope in which the protocol declaration occurs. 03081 virtual void CodeCompleteObjCProtocolDecl(Scope *S) { } 03082 03083 /// \brief Code completion for an Objective-C interface, after the 03084 /// @interface but before any identifier. 03085 virtual void CodeCompleteObjCInterfaceDecl(Scope *S) { } 03086 03087 /// \brief Code completion for the superclass of an Objective-C 03088 /// interface, after the ':'. 03089 /// 03090 /// \param S the scope in which the interface declaration occurs. 03091 /// 03092 /// \param ClassName the name of the class being defined. 03093 virtual void CodeCompleteObjCSuperclass(Scope *S, 03094 IdentifierInfo *ClassName, 03095 SourceLocation ClassNameLoc) { 03096 } 03097 03098 /// \brief Code completion for an Objective-C implementation, after the 03099 /// @implementation but before any identifier. 03100 virtual void CodeCompleteObjCImplementationDecl(Scope *S) { } 03101 03102 /// \brief Code completion for the category name in an Objective-C interface 03103 /// declaration. 03104 /// 03105 /// This code completion action is invoked after the '(' that indicates 03106 /// a category name within an Objective-C interface declaration. 03107 virtual void CodeCompleteObjCInterfaceCategory(Scope *S, 03108 IdentifierInfo *ClassName, 03109 SourceLocation ClassNameLoc) { 03110 } 03111 03112 /// \brief Code completion for the category name in an Objective-C category 03113 /// implementation. 03114 /// 03115 /// This code completion action is invoked after the '(' that indicates 03116 /// the category name within an Objective-C category implementation. 03117 virtual void CodeCompleteObjCImplementationCategory(Scope *S, 03118 IdentifierInfo *ClassName, 03119 SourceLocation ClassNameLoc) { 03120 } 03121 03122 /// \brief Code completion for the property names when defining an 03123 /// Objective-C property. 03124 /// 03125 /// This code completion action is invoked after @synthesize or @dynamic and 03126 /// after each "," within one of those definitions. 03127 virtual void CodeCompleteObjCPropertyDefinition(Scope *S, 03128 DeclPtrTy ObjCImpDecl) { 03129 } 03130 03131 /// \brief Code completion for the instance variable name that should 03132 /// follow an '=' when synthesizing an Objective-C property. 03133 /// 03134 /// This code completion action is invoked after each '=' that occurs within 03135 /// an @synthesized definition. 03136 virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, 03137 IdentifierInfo *PropertyName, 03138 DeclPtrTy ObjCImpDecl) { 03139 } 03140 03141 /// \brief Code completion for an Objective-C method declaration or 03142 /// definition, which may occur within an interface, category, 03143 /// extension, protocol, or implementation thereof (where applicable). 03144 /// 03145 /// This code completion action is invoked after the "-" or "+" that 03146 /// starts a method declaration or definition, and after the return 03147 /// type such a declaration (e.g., "- (id)"). 03148 /// 03149 /// \param S The scope in which the completion occurs. 03150 /// 03151 /// \param IsInstanceMethod Whether this is an instance method 03152 /// (introduced with '-'); otherwise, it's a class method 03153 /// (introduced with '+'). 03154 /// 03155 /// \param ReturnType If non-NULL, the specified return type of the method 03156 /// being declared or defined. 03157 /// 03158 /// \param IDecl The interface, category, protocol, or 03159 /// implementation, or category implementation in which this method 03160 /// declaration or definition occurs. 03161 virtual void CodeCompleteObjCMethodDecl(Scope *S, 03162 bool IsInstanceMethod, 03163 TypeTy *ReturnType, 03164 DeclPtrTy IDecl) { 03165 } 03166 03167 /// \brief Code completion for a selector identifier or argument name within 03168 /// an Objective-C method declaration. 03169 /// 03170 /// \param S The scope in which this code completion occurs. 03171 /// 03172 /// \param IsInstanceMethod Whether we are parsing an instance method (or, 03173 /// if false, a class method). 03174 /// 03175 /// \param AtParameterName Whether the actual code completion point is at the 03176 /// argument name. 03177 /// 03178 /// \param ReturnType If non-NULL, the specified return type of the method 03179 /// being declared or defined. 03180 /// 03181 /// \param SelIdents The identifiers that occurred in the selector for the 03182 /// method declaration prior to the code completion point. 03183 /// 03184 /// \param NumSelIdents The number of identifiers provided by SelIdents. 03185 virtual void CodeCompleteObjCMethodDeclSelector(Scope *S, 03186 bool IsInstanceMethod, 03187 bool AtParameterName, 03188 TypeTy *ReturnType, 03189 IdentifierInfo **SelIdents, 03190 unsigned NumSelIdents) { } 03191 03192 //@} 03193 }; 03194 03195 /// PrettyStackTraceActionsDecl - If a crash occurs in the parser while parsing 03196 /// something related to a virtualized decl, include that virtualized decl in 03197 /// the stack trace. 03198 class PrettyStackTraceActionsDecl : public llvm::PrettyStackTraceEntry { 03199 Action::DeclPtrTy TheDecl; 03200 SourceLocation Loc; 03201 Action &Actions; 03202 SourceManager &SM; 03203 const char *Message; 03204 03205 public: 03206 PrettyStackTraceActionsDecl(Action::DeclPtrTy Decl, SourceLocation L, 03207 Action &actions, SourceManager &sm, 03208 const char *Msg) 03209 : TheDecl(Decl), Loc(L), Actions(actions), SM(sm), Message(Msg) {} 03210 03211 virtual void print(llvm::raw_ostream &OS) const; 03212 }; 03213 03214 /// \brief RAII object that enters a new expression evaluation context. 03215 class EnterExpressionEvaluationContext { 03216 /// \brief The action object. 03217 Action &Actions; 03218 03219 public: 03220 EnterExpressionEvaluationContext(Action &Actions, 03221 Action::ExpressionEvaluationContext NewContext) 03222 : Actions(Actions) { 03223 Actions.PushExpressionEvaluationContext(NewContext); 03224 } 03225 03226 ~EnterExpressionEvaluationContext() { 03227 Actions.PopExpressionEvaluationContext(); 03228 } 03229 }; 03230 03231 03232 } // end namespace clang 03233 03234 #endif