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