Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- MinimalAction.cpp - Implement the MinimalAction class ------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the MinimalAction interface. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/Parse/Parser.h" |
| 15 | #include "clang/Parse/DeclSpec.h" |
| 16 | #include "clang/Parse/Scope.h" |
Chris Lattner | ace6507 | 2009-05-01 16:33:20 +0000 | [diff] [blame] | 17 | #include "clang/Basic/TargetInfo.h" |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Allocator.h" |
| 19 | #include "llvm/Support/RecyclingAllocator.h" |
Chris Lattner | 21ff9c9 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 20 | #include "llvm/Support/raw_ostream.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 21 | using namespace clang; |
| 22 | |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 23 | /// Out-of-line virtual destructor to provide home for ActionBase class. |
Chris Lattner | 0102c30 | 2009-03-05 07:24:28 +0000 | [diff] [blame] | 24 | ActionBase::~ActionBase() {} |
| 25 | |
| 26 | /// Out-of-line virtual destructor to provide home for Action class. |
| 27 | Action::~Action() {} |
| 28 | |
Douglas Gregor | 1dbca6e | 2010-04-14 02:22:16 +0000 | [diff] [blame] | 29 | Action::ObjCMessageKind Action::getObjCMessageKind(Scope *S, |
Douglas Gregor | 1569f95 | 2010-04-21 20:38:13 +0000 | [diff] [blame] | 30 | IdentifierInfo *Name, |
Douglas Gregor | 1dbca6e | 2010-04-14 02:22:16 +0000 | [diff] [blame] | 31 | SourceLocation NameLoc, |
| 32 | bool IsSuper, |
Douglas Gregor | 1569f95 | 2010-04-21 20:38:13 +0000 | [diff] [blame] | 33 | bool HasTrailingDot, |
| 34 | TypeTy *&ReceiverType) { |
| 35 | ReceiverType = 0; |
| 36 | |
Douglas Gregor | 1dbca6e | 2010-04-14 02:22:16 +0000 | [diff] [blame] | 37 | if (IsSuper && !HasTrailingDot && S->isInObjcMethodScope()) |
| 38 | return ObjCSuperMessage; |
| 39 | |
Douglas Gregor | 1569f95 | 2010-04-21 20:38:13 +0000 | [diff] [blame] | 40 | if (TypeTy *TyName = getTypeName(*Name, NameLoc, S)) { |
| 41 | DeclSpec DS; |
| 42 | const char *PrevSpec = 0; |
| 43 | unsigned DiagID = 0; |
| 44 | if (!DS.SetTypeSpecType(DeclSpec::TST_typename, NameLoc, PrevSpec, |
| 45 | DiagID, TyName)) { |
| 46 | DS.SetRangeEnd(NameLoc); |
| 47 | Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); |
| 48 | TypeResult Ty = ActOnTypeName(S, DeclaratorInfo); |
| 49 | if (!Ty.isInvalid()) |
| 50 | ReceiverType = Ty.get(); |
| 51 | } |
Douglas Gregor | 1dbca6e | 2010-04-14 02:22:16 +0000 | [diff] [blame] | 52 | return ObjCClassMessage; |
Douglas Gregor | 1569f95 | 2010-04-21 20:38:13 +0000 | [diff] [blame] | 53 | } |
Douglas Gregor | 1dbca6e | 2010-04-14 02:22:16 +0000 | [diff] [blame] | 54 | |
| 55 | return ObjCInstanceMessage; |
| 56 | } |
| 57 | |
Chris Lattner | 0102c30 | 2009-03-05 07:24:28 +0000 | [diff] [blame] | 58 | // Defined out-of-line here because of dependecy on AttributeList |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 59 | Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope, |
| 60 | SourceLocation UsingLoc, |
| 61 | SourceLocation NamespcLoc, |
Jeffrey Yasskin | 9ab1454 | 2010-04-08 16:38:48 +0000 | [diff] [blame] | 62 | CXXScopeSpec &SS, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 63 | SourceLocation IdentLoc, |
| 64 | IdentifierInfo *NamespcName, |
| 65 | AttributeList *AttrList) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 66 | |
Chris Lattner | 0102c30 | 2009-03-05 07:24:28 +0000 | [diff] [blame] | 67 | // FIXME: Parser seems to assume that Action::ActOn* takes ownership over |
| 68 | // passed AttributeList, however other actions don't free it, is it |
| 69 | // temporary state or bug? |
| 70 | delete AttrList; |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 71 | return DeclPtrTy(); |
Chris Lattner | 0102c30 | 2009-03-05 07:24:28 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Douglas Gregor | 12c118a | 2009-11-04 16:30:06 +0000 | [diff] [blame] | 74 | // Defined out-of-line here because of dependency on AttributeList |
Douglas Gregor | 9cfbe48 | 2009-06-20 00:51:54 +0000 | [diff] [blame] | 75 | Action::DeclPtrTy Action::ActOnUsingDeclaration(Scope *CurScope, |
Anders Carlsson | 595adc1 | 2009-08-29 19:54:19 +0000 | [diff] [blame] | 76 | AccessSpecifier AS, |
John McCall | 60fa3cf | 2009-12-11 02:10:03 +0000 | [diff] [blame] | 77 | bool HasUsingKeyword, |
Anders Carlsson | 595adc1 | 2009-08-29 19:54:19 +0000 | [diff] [blame] | 78 | SourceLocation UsingLoc, |
Jeffrey Yasskin | 9ab1454 | 2010-04-08 16:38:48 +0000 | [diff] [blame] | 79 | CXXScopeSpec &SS, |
Douglas Gregor | 12c118a | 2009-11-04 16:30:06 +0000 | [diff] [blame] | 80 | UnqualifiedId &Name, |
Anders Carlsson | 595adc1 | 2009-08-29 19:54:19 +0000 | [diff] [blame] | 81 | AttributeList *AttrList, |
John McCall | 7ba107a | 2009-11-18 02:36:19 +0000 | [diff] [blame] | 82 | bool IsTypeName, |
| 83 | SourceLocation TypenameLoc) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 84 | |
Douglas Gregor | 9cfbe48 | 2009-06-20 00:51:54 +0000 | [diff] [blame] | 85 | // FIXME: Parser seems to assume that Action::ActOn* takes ownership over |
| 86 | // passed AttributeList, however other actions don't free it, is it |
| 87 | // temporary state or bug? |
| 88 | delete AttrList; |
| 89 | return DeclPtrTy(); |
| 90 | } |
| 91 | |
Chris Lattner | 0102c30 | 2009-03-05 07:24:28 +0000 | [diff] [blame] | 92 | |
Chris Lattner | 49f28ca | 2009-03-05 08:00:35 +0000 | [diff] [blame] | 93 | void PrettyStackTraceActionsDecl::print(llvm::raw_ostream &OS) const { |
Chris Lattner | 21ff9c9 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 94 | if (Loc.isValid()) { |
| 95 | Loc.print(OS, SM); |
| 96 | OS << ": "; |
| 97 | } |
| 98 | OS << Message; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 99 | |
Chris Lattner | 21ff9c9 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 100 | std::string Name = Actions.getDeclName(TheDecl); |
| 101 | if (!Name.empty()) |
| 102 | OS << " '" << Name << '\''; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 103 | |
Chris Lattner | 21ff9c9 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 104 | OS << '\n'; |
| 105 | } |
| 106 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 107 | /// TypeNameInfo - A link exists here for each scope that an identifier is |
| 108 | /// defined. |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 109 | namespace { |
| 110 | struct TypeNameInfo { |
| 111 | TypeNameInfo *Prev; |
| 112 | bool isTypeName; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 113 | |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 114 | TypeNameInfo(bool istypename, TypeNameInfo *prev) { |
| 115 | isTypeName = istypename; |
| 116 | Prev = prev; |
| 117 | } |
| 118 | }; |
| 119 | |
| 120 | struct TypeNameInfoTable { |
| 121 | llvm::RecyclingAllocator<llvm::BumpPtrAllocator, TypeNameInfo> Allocator; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 122 | |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 123 | void AddEntry(bool isTypename, IdentifierInfo *II) { |
| 124 | TypeNameInfo *TI = Allocator.Allocate<TypeNameInfo>(); |
Chris Lattner | f26d510 | 2009-03-24 17:05:27 +0000 | [diff] [blame] | 125 | new (TI) TypeNameInfo(isTypename, II->getFETokenInfo<TypeNameInfo>()); |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 126 | II->setFETokenInfo(TI); |
| 127 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 128 | |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 129 | void DeleteEntry(TypeNameInfo *Entry) { |
| 130 | Entry->~TypeNameInfo(); |
| 131 | Allocator.Deallocate(Entry); |
| 132 | } |
| 133 | }; |
| 134 | } |
| 135 | |
| 136 | static TypeNameInfoTable *getTable(void *TP) { |
| 137 | return static_cast<TypeNameInfoTable*>(TP); |
| 138 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 139 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 140 | MinimalAction::MinimalAction(Preprocessor &pp) |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 141 | : Idents(pp.getIdentifierTable()), PP(pp) { |
| 142 | TypeNameInfoTablePtr = new TypeNameInfoTable(); |
| 143 | } |
| 144 | |
| 145 | MinimalAction::~MinimalAction() { |
| 146 | delete getTable(TypeNameInfoTablePtr); |
| 147 | } |
Daniel Dunbar | e10b0f2 | 2008-10-31 08:56:51 +0000 | [diff] [blame] | 148 | |
| 149 | void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { |
Steve Naroff | 8ee529b | 2007-10-31 18:42:27 +0000 | [diff] [blame] | 150 | TUScope = S; |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 151 | |
| 152 | TypeNameInfoTable &TNIT = *getTable(TypeNameInfoTablePtr); |
Chris Lattner | ace6507 | 2009-05-01 16:33:20 +0000 | [diff] [blame] | 153 | |
| 154 | if (PP.getTargetInfo().getPointerWidth(0) >= 64) { |
| 155 | // Install [u]int128_t for 64-bit targets. |
| 156 | TNIT.AddEntry(true, &Idents.get("__int128_t")); |
| 157 | TNIT.AddEntry(true, &Idents.get("__uint128_t")); |
| 158 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 159 | |
Chris Lattner | ace6507 | 2009-05-01 16:33:20 +0000 | [diff] [blame] | 160 | if (PP.getLangOptions().ObjC1) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 161 | // Recognize the ObjC built-in type identifiers as types. |
Chris Lattner | ace6507 | 2009-05-01 16:33:20 +0000 | [diff] [blame] | 162 | TNIT.AddEntry(true, &Idents.get("id")); |
| 163 | TNIT.AddEntry(true, &Idents.get("SEL")); |
| 164 | TNIT.AddEntry(true, &Idents.get("Class")); |
| 165 | TNIT.AddEntry(true, &Idents.get("Protocol")); |
| 166 | } |
Steve Naroff | 8ee529b | 2007-10-31 18:42:27 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 169 | /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to |
| 170 | /// determine whether the name is a type name (objc class name or typedef) or |
| 171 | /// not in this scope. |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 172 | /// |
| 173 | /// FIXME: Use the passed CXXScopeSpec for accurate C++ type checking. |
Argyrios Kyrtzidis | 39caa08 | 2008-08-01 10:35:27 +0000 | [diff] [blame] | 174 | Action::TypeTy * |
Douglas Gregor | b696ea3 | 2009-02-04 17:00:24 +0000 | [diff] [blame] | 175 | MinimalAction::getTypeName(IdentifierInfo &II, SourceLocation Loc, |
Jeffrey Yasskin | 9ab1454 | 2010-04-08 16:38:48 +0000 | [diff] [blame] | 176 | Scope *S, CXXScopeSpec *SS, |
Douglas Gregor | f6e6fc8 | 2009-11-20 22:03:38 +0000 | [diff] [blame] | 177 | bool isClassName, TypeTy *ObjectType) { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 178 | if (TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>()) |
| 179 | if (TI->isTypeName) |
| 180 | return TI; |
| 181 | return 0; |
| 182 | } |
| 183 | |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 184 | /// isCurrentClassName - Always returns false, because MinimalAction |
| 185 | /// does not support C++ classes with constructors. |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 186 | bool MinimalAction::isCurrentClassName(const IdentifierInfo &, Scope *, |
| 187 | const CXXScopeSpec *) { |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 188 | return false; |
| 189 | } |
| 190 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 191 | TemplateNameKind |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 192 | MinimalAction::isTemplateName(Scope *S, |
Jeffrey Yasskin | 9ab1454 | 2010-04-08 16:38:48 +0000 | [diff] [blame] | 193 | CXXScopeSpec &SS, |
Douglas Gregor | 014e88d | 2009-11-03 23:16:33 +0000 | [diff] [blame] | 194 | UnqualifiedId &Name, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 195 | TypeTy *ObjectType, |
Douglas Gregor | 495c35d | 2009-08-25 22:51:20 +0000 | [diff] [blame] | 196 | bool EnteringScope, |
Douglas Gregor | 1fd6d44 | 2010-05-21 23:18:07 +0000 | [diff] [blame] | 197 | TemplateTy &TemplateDecl, |
| 198 | bool &MemberOfUnknownSpecialization) { |
| 199 | MemberOfUnknownSpecialization = false; |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 200 | return TNK_Non_template; |
Douglas Gregor | d6fb7ef | 2008-12-18 19:37:40 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Steve Naroff | 08d92e4 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 203 | /// ActOnDeclarator - If this is a typedef declarator, we modify the |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 204 | /// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is |
| 205 | /// popped. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 206 | Action::DeclPtrTy |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 207 | MinimalAction::ActOnDeclarator(Scope *S, Declarator &D) { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 208 | IdentifierInfo *II = D.getIdentifier(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 209 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 210 | // If there is no identifier associated with this declarator, bail out. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 211 | if (II == 0) return DeclPtrTy(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 212 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 213 | TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>(); |
| 214 | bool isTypeName = |
| 215 | D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef; |
| 216 | |
| 217 | // this check avoids creating TypeNameInfo objects for the common case. |
Ted Kremenek | a34ea07 | 2008-08-04 22:51:42 +0000 | [diff] [blame] | 218 | // It does need to handle the uncommon case of shadowing a typedef name with a |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 219 | // non-typedef name. e.g. { typedef int a; a xx; { int a; } } |
| 220 | if (weCurrentlyHaveTypeInfo || isTypeName) { |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 221 | // Allocate and add the 'TypeNameInfo' "decl". |
| 222 | getTable(TypeNameInfoTablePtr)->AddEntry(isTypeName, II); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 223 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 224 | // Remember that this needs to be removed when the scope is popped. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 225 | S->AddDecl(DeclPtrTy::make(II)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 226 | } |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 227 | return DeclPtrTy(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 230 | Action::DeclPtrTy |
Chris Lattner | cfb0ef5 | 2008-07-21 07:13:18 +0000 | [diff] [blame] | 231 | MinimalAction::ActOnStartClassInterface(SourceLocation AtInterfaceLoc, |
Chris Lattner | 06036d3 | 2008-07-26 04:13:19 +0000 | [diff] [blame] | 232 | IdentifierInfo *ClassName, |
| 233 | SourceLocation ClassLoc, |
| 234 | IdentifierInfo *SuperName, |
| 235 | SourceLocation SuperLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 236 | const DeclPtrTy *ProtoRefs, |
Chris Lattner | 06036d3 | 2008-07-26 04:13:19 +0000 | [diff] [blame] | 237 | unsigned NumProtocols, |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 238 | const SourceLocation *ProtoLocs, |
Chris Lattner | 06036d3 | 2008-07-26 04:13:19 +0000 | [diff] [blame] | 239 | SourceLocation EndProtoLoc, |
| 240 | AttributeList *AttrList) { |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 241 | // Allocate and add the 'TypeNameInfo' "decl". |
| 242 | getTable(TypeNameInfoTablePtr)->AddEntry(true, ClassName); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 243 | return DeclPtrTy(); |
Steve Naroff | 3536b44 | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 244 | } |
| 245 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 246 | /// ActOnForwardClassDeclaration - |
| 247 | /// Scope will always be top level file scope. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 248 | Action::DeclPtrTy |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 249 | MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, |
Ted Kremenek | c09cba6 | 2009-11-17 23:12:20 +0000 | [diff] [blame] | 250 | IdentifierInfo **IdentList, |
| 251 | SourceLocation *IdentLocs, |
| 252 | unsigned NumElts) { |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 253 | for (unsigned i = 0; i != NumElts; ++i) { |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 254 | // Allocate and add the 'TypeNameInfo' "decl". |
| 255 | getTable(TypeNameInfoTablePtr)->AddEntry(true, IdentList[i]); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 256 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 257 | // Remember that this needs to be removed when the scope is popped. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 258 | TUScope->AddDecl(DeclPtrTy::make(IdentList[i])); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 259 | } |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 260 | return DeclPtrTy(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Ted Kremenek | a34ea07 | 2008-08-04 22:51:42 +0000 | [diff] [blame] | 263 | /// ActOnPopScope - When a scope is popped, if any typedefs are now |
| 264 | /// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field. |
Steve Naroff | 640db42 | 2007-10-10 17:45:44 +0000 | [diff] [blame] | 265 | void MinimalAction::ActOnPopScope(SourceLocation Loc, Scope *S) { |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 266 | TypeNameInfoTable &Table = *getTable(TypeNameInfoTablePtr); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 267 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 268 | for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end(); |
| 269 | I != E; ++I) { |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 270 | IdentifierInfo &II = *(*I).getAs<IdentifierInfo>(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 271 | TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>(); |
| 272 | assert(TI && "This decl didn't get pushed??"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 273 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 274 | if (TI) { |
| 275 | TypeNameInfo *Next = TI->Prev; |
Chris Lattner | e1ae1e9 | 2009-01-18 09:39:41 +0000 | [diff] [blame] | 276 | Table.DeleteEntry(TI); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 277 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 278 | II.setFETokenInfo(Next); |
| 279 | } |
| 280 | } |
| 281 | } |