diff options
Diffstat (limited to 'lib/Parse/MinimalAction.cpp')
-rw-r--r-- | lib/Parse/MinimalAction.cpp | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/lib/Parse/MinimalAction.cpp b/lib/Parse/MinimalAction.cpp index 648e2da54bfe..71b22cad6f62 100644 --- a/lib/Parse/MinimalAction.cpp +++ b/lib/Parse/MinimalAction.cpp @@ -34,7 +34,7 @@ Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope, SourceLocation IdentLoc, IdentifierInfo *NamespcName, AttributeList *AttrList) { - + // FIXME: Parser seems to assume that Action::ActOn* takes ownership over // passed AttributeList, however other actions don't free it, is it // temporary state or bug? @@ -44,14 +44,15 @@ Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope, // Defined out-of-line here because of dependecy on AttributeList Action::DeclPtrTy Action::ActOnUsingDeclaration(Scope *CurScope, - SourceLocation UsingLoc, - const CXXScopeSpec &SS, - SourceLocation IdentLoc, - IdentifierInfo *TargetName, - OverloadedOperatorKind Op, - AttributeList *AttrList, - bool IsTypeName) { - + AccessSpecifier AS, + SourceLocation UsingLoc, + const CXXScopeSpec &SS, + SourceLocation IdentLoc, + IdentifierInfo *TargetName, + OverloadedOperatorKind Op, + AttributeList *AttrList, + bool IsTypeName) { + // FIXME: Parser seems to assume that Action::ActOn* takes ownership over // passed AttributeList, however other actions don't free it, is it // temporary state or bug? @@ -66,11 +67,11 @@ void PrettyStackTraceActionsDecl::print(llvm::raw_ostream &OS) const { OS << ": "; } OS << Message; - + std::string Name = Actions.getDeclName(TheDecl); if (!Name.empty()) OS << " '" << Name << '\''; - + OS << '\n'; } @@ -80,7 +81,7 @@ namespace { struct TypeNameInfo { TypeNameInfo *Prev; bool isTypeName; - + TypeNameInfo(bool istypename, TypeNameInfo *prev) { isTypeName = istypename; Prev = prev; @@ -89,13 +90,13 @@ namespace { struct TypeNameInfoTable { llvm::RecyclingAllocator<llvm::BumpPtrAllocator, TypeNameInfo> Allocator; - + void AddEntry(bool isTypename, IdentifierInfo *II) { TypeNameInfo *TI = Allocator.Allocate<TypeNameInfo>(); new (TI) TypeNameInfo(isTypename, II->getFETokenInfo<TypeNameInfo>()); II->setFETokenInfo(TI); } - + void DeleteEntry(TypeNameInfo *Entry) { Entry->~TypeNameInfo(); Allocator.Deallocate(Entry); @@ -107,7 +108,7 @@ static TypeNameInfoTable *getTable(void *TP) { return static_cast<TypeNameInfoTable*>(TP); } -MinimalAction::MinimalAction(Preprocessor &pp) +MinimalAction::MinimalAction(Preprocessor &pp) : Idents(pp.getIdentifierTable()), PP(pp) { TypeNameInfoTablePtr = new TypeNameInfoTable(); } @@ -126,9 +127,9 @@ void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { TNIT.AddEntry(true, &Idents.get("__int128_t")); TNIT.AddEntry(true, &Idents.get("__uint128_t")); } - + if (PP.getLangOptions().ObjC1) { - // Recognize the ObjC built-in type identifiers as types. + // Recognize the ObjC built-in type identifiers as types. TNIT.AddEntry(true, &Idents.get("id")); TNIT.AddEntry(true, &Idents.get("SEL")); TNIT.AddEntry(true, &Idents.get("Class")); @@ -143,7 +144,8 @@ void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { /// FIXME: Use the passed CXXScopeSpec for accurate C++ type checking. Action::TypeTy * MinimalAction::getTypeName(IdentifierInfo &II, SourceLocation Loc, - Scope *S, const CXXScopeSpec *SS) { + Scope *S, const CXXScopeSpec *SS, + bool isClassName) { if (TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>()) if (TI->isTypeName) return TI; @@ -157,10 +159,14 @@ bool MinimalAction::isCurrentClassName(const IdentifierInfo &, Scope *, return false; } -TemplateNameKind -MinimalAction::isTemplateName(const IdentifierInfo &II, Scope *S, - TemplateTy &TemplateDecl, - const CXXScopeSpec *SS) { +TemplateNameKind +MinimalAction::isTemplateName(Scope *S, + const IdentifierInfo &II, + SourceLocation IdLoc, + const CXXScopeSpec *SS, + TypeTy *ObjectType, + bool EnteringScope, + TemplateTy &TemplateDecl) { return TNK_Non_template; } @@ -170,10 +176,10 @@ MinimalAction::isTemplateName(const IdentifierInfo &II, Scope *S, Action::DeclPtrTy MinimalAction::ActOnDeclarator(Scope *S, Declarator &D) { IdentifierInfo *II = D.getIdentifier(); - + // If there is no identifier associated with this declarator, bail out. if (II == 0) return DeclPtrTy(); - + TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>(); bool isTypeName = D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef; @@ -184,10 +190,10 @@ MinimalAction::ActOnDeclarator(Scope *S, Declarator &D) { if (weCurrentlyHaveTypeInfo || isTypeName) { // Allocate and add the 'TypeNameInfo' "decl". getTable(TypeNameInfoTablePtr)->AddEntry(isTypeName, II); - + // Remember that this needs to be removed when the scope is popped. S->AddDecl(DeclPtrTy::make(II)); - } + } return DeclPtrTy(); } @@ -206,15 +212,15 @@ MinimalAction::ActOnStartClassInterface(SourceLocation AtInterfaceLoc, return DeclPtrTy(); } -/// ActOnForwardClassDeclaration - -/// Scope will always be top level file scope. +/// ActOnForwardClassDeclaration - +/// Scope will always be top level file scope. Action::DeclPtrTy MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, IdentifierInfo **IdentList, unsigned NumElts) { for (unsigned i = 0; i != NumElts; ++i) { // Allocate and add the 'TypeNameInfo' "decl". getTable(TypeNameInfoTablePtr)->AddEntry(true, IdentList[i]); - + // Remember that this needs to be removed when the scope is popped. TUScope->AddDecl(DeclPtrTy::make(IdentList[i])); } @@ -225,17 +231,17 @@ MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, /// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field. void MinimalAction::ActOnPopScope(SourceLocation Loc, Scope *S) { TypeNameInfoTable &Table = *getTable(TypeNameInfoTablePtr); - + for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end(); I != E; ++I) { IdentifierInfo &II = *(*I).getAs<IdentifierInfo>(); TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>(); assert(TI && "This decl didn't get pushed??"); - + if (TI) { TypeNameInfo *Next = TI->Prev; Table.DeleteEntry(TI); - + II.setFETokenInfo(Next); } } |