blob: b41fae86b92fb4893cc40aaf6bf1436b63b74743 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- Decl.cpp - Declaration AST Node Implementation -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
Argyrios Kyrtzidise184bae2008-06-04 13:04:04 +000010// This file implements the Decl subclasses.
Reid Spencer5f016e22007-07-11 17:01:13 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/Decl.h"
Douglas Gregor2a3009a2009-02-03 19:21:40 +000015#include "clang/AST/DeclCXX.h"
Steve Naroff0de21fd2009-02-22 19:35:57 +000016#include "clang/AST/DeclObjC.h"
Douglas Gregor7da97d02009-05-10 22:57:19 +000017#include "clang/AST/DeclTemplate.h"
Chris Lattner6c2b6eb2008-03-15 06:12:44 +000018#include "clang/AST/ASTContext.h"
Argyrios Kyrtzidisb17166c2009-08-19 01:27:32 +000019#include "clang/AST/TypeLoc.h"
Daniel Dunbare91593e2008-08-11 04:54:23 +000020#include "clang/AST/Stmt.h"
Nuno Lopes99f06ba2008-12-17 23:39:55 +000021#include "clang/AST/Expr.h"
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000022#include "clang/AST/PrettyPrinter.h"
Chris Lattner1b63e4f2009-06-14 01:54:56 +000023#include "clang/Basic/Builtins.h"
Daniel Dunbare91593e2008-08-11 04:54:23 +000024#include "clang/Basic/IdentifierTable.h"
Douglas Gregor47b9a1c2009-02-04 17:27:36 +000025#include <vector>
Ted Kremenek27f8a282008-05-20 00:43:19 +000026
Reid Spencer5f016e22007-07-11 17:01:13 +000027using namespace clang;
28
Chris Lattner0b2b6e12009-03-04 06:34:08 +000029void Attr::Destroy(ASTContext &C) {
30 if (Next) {
31 Next->Destroy(C);
32 Next = 0;
33 }
34 this->~Attr();
35 C.Deallocate((void*)this);
36}
37
Argyrios Kyrtzidisb17166c2009-08-19 01:27:32 +000038/// \brief Return the TypeLoc wrapper for the type source info.
39TypeLoc DeclaratorInfo::getTypeLoc() const {
40 return TypeLoc::Create(Ty, (void*)(this + 1));
41}
Chris Lattner0b2b6e12009-03-04 06:34:08 +000042
Chris Lattnerd3b90652008-03-15 05:43:15 +000043//===----------------------------------------------------------------------===//
Chris Lattner6c2b6eb2008-03-15 06:12:44 +000044// Decl Allocation/Deallocation Method Implementations
45//===----------------------------------------------------------------------===//
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +000046
Chris Lattner0b2b6e12009-03-04 06:34:08 +000047
Argyrios Kyrtzidisef177822008-04-17 14:40:12 +000048TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) {
Argyrios Kyrtzidis3708b3d2009-06-29 17:38:40 +000049 return new (C) TranslationUnitDecl(C);
Argyrios Kyrtzidisef177822008-04-17 14:40:12 +000050}
51
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +000052NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC,
53 SourceLocation L, IdentifierInfo *Id) {
Steve Naroff3e970492009-01-27 21:25:57 +000054 return new (C) NamespaceDecl(DC, L, Id);
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +000055}
56
Ted Kremenekd1ac17a2008-05-20 04:49:55 +000057void NamespaceDecl::Destroy(ASTContext& C) {
58 // NamespaceDecl uses "NextDeclarator" to chain namespace declarations
59 // together. They are all top-level Decls.
60
Ted Kremenekebf27b12008-05-24 15:09:56 +000061 this->~NamespaceDecl();
Steve Naroff3e970492009-01-27 21:25:57 +000062 C.Deallocate((void *)this);
Ted Kremenekd1ac17a2008-05-20 04:49:55 +000063}
64
65
Chris Lattner41110242008-06-17 18:05:57 +000066ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
Douglas Gregor4afa39d2009-01-20 01:17:11 +000067 SourceLocation L, IdentifierInfo *Id, QualType T) {
Steve Naroff3e970492009-01-27 21:25:57 +000068 return new (C) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
Chris Lattner41110242008-06-17 18:05:57 +000069}
70
Daniel Dunbarb286a782009-04-14 02:08:49 +000071const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) {
72 switch (SC) {
73 case VarDecl::None: break;
74 case VarDecl::Auto: return "auto"; break;
75 case VarDecl::Extern: return "extern"; break;
76 case VarDecl::PrivateExtern: return "__private_extern__"; break;
77 case VarDecl::Register: return "register"; break;
78 case VarDecl::Static: return "static"; break;
79 }
80
81 assert(0 && "Invalid storage class");
82 return 0;
83}
84
Chris Lattner9fdf9c62008-04-22 18:39:57 +000085ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
Chris Lattner0ed844b2008-04-04 06:12:32 +000086 SourceLocation L, IdentifierInfo *Id,
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +000087 QualType T, DeclaratorInfo *DInfo,
88 StorageClass S, Expr *DefArg) {
89 return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, DInfo, S, DefArg);
Fariborz Jahanian4306d3c2008-12-20 23:29:59 +000090}
91
92QualType ParmVarDecl::getOriginalType() const {
Douglas Gregor64650af2009-02-02 23:39:07 +000093 if (const OriginalParmVarDecl *PVD =
94 dyn_cast<OriginalParmVarDecl>(this))
Fariborz Jahanian4306d3c2008-12-20 23:29:59 +000095 return PVD->OriginalType;
96 return getType();
Chris Lattner9e151e12008-03-15 21:10:16 +000097}
98
Douglas Gregor78d15832009-05-26 18:54:04 +000099void VarDecl::setInit(ASTContext &C, Expr *I) {
100 if (EvaluatedStmt *Eval = Init.dyn_cast<EvaluatedStmt *>()) {
101 Eval->~EvaluatedStmt();
102 C.Deallocate(Eval);
103 }
104
105 Init = I;
106 }
107
Douglas Gregor63935192009-03-02 00:19:53 +0000108bool VarDecl::isExternC(ASTContext &Context) const {
109 if (!Context.getLangOptions().CPlusPlus)
110 return (getDeclContext()->isTranslationUnit() &&
111 getStorageClass() != Static) ||
112 (getDeclContext()->isFunctionOrMethod() && hasExternalStorage());
113
114 for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit();
115 DC = DC->getParent()) {
116 if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC)) {
117 if (Linkage->getLanguage() == LinkageSpecDecl::lang_c)
118 return getStorageClass() != Static;
119
120 break;
121 }
122
123 if (DC->isFunctionOrMethod())
124 return false;
125 }
126
127 return false;
128}
129
Douglas Gregor64650af2009-02-02 23:39:07 +0000130OriginalParmVarDecl *OriginalParmVarDecl::Create(
Fariborz Jahanian73da9e42008-12-20 20:56:12 +0000131 ASTContext &C, DeclContext *DC,
132 SourceLocation L, IdentifierInfo *Id,
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000133 QualType T, DeclaratorInfo *DInfo,
134 QualType OT, StorageClass S, Expr *DefArg) {
135 return new (C) OriginalParmVarDecl(DC, L, Id, T, DInfo, OT, S, DefArg);
Fariborz Jahanian73da9e42008-12-20 20:56:12 +0000136}
137
Chris Lattner9fdf9c62008-04-22 18:39:57 +0000138FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
Chris Lattner0ed844b2008-04-04 06:12:32 +0000139 SourceLocation L,
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000140 DeclarationName N, QualType T,
141 DeclaratorInfo *DInfo,
Chris Lattnera98e58d2008-03-15 21:24:04 +0000142 StorageClass S, bool isInline,
Anders Carlssona75e8532009-05-14 21:46:00 +0000143 bool hasWrittenPrototype,
Steve Naroff0eb07bf2008-10-03 00:02:03 +0000144 SourceLocation TypeSpecStartLoc) {
Douglas Gregor2224f842009-02-25 16:33:18 +0000145 FunctionDecl *New
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000146 = new (C) FunctionDecl(Function, DC, L, N, T, DInfo, S, isInline,
Douglas Gregor2224f842009-02-25 16:33:18 +0000147 TypeSpecStartLoc);
Anders Carlssona75e8532009-05-14 21:46:00 +0000148 New->HasWrittenPrototype = hasWrittenPrototype;
Douglas Gregor2224f842009-02-25 16:33:18 +0000149 return New;
Chris Lattnera98e58d2008-03-15 21:24:04 +0000150}
151
Steve Naroff090276f2008-10-10 01:28:17 +0000152BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) {
Steve Naroff3e970492009-01-27 21:25:57 +0000153 return new (C) BlockDecl(DC, L);
Steve Naroff56ee6892008-10-08 17:01:13 +0000154}
155
Douglas Gregor44b43212008-12-11 16:49:14 +0000156FieldDecl *FieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000157 IdentifierInfo *Id, QualType T,
158 DeclaratorInfo *DInfo, Expr *BW,
Steve Naroffea218b82009-07-14 14:58:18 +0000159 bool Mutable, SourceLocation TSSL) {
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000160 return new (C) FieldDecl(Decl::Field, DC, L, Id, T, DInfo, BW, Mutable, TSSL);
Chris Lattner8e25d862008-03-16 00:16:02 +0000161}
162
Douglas Gregor6b3945f2009-01-07 19:46:03 +0000163bool FieldDecl::isAnonymousStructOrUnion() const {
164 if (!isImplicit() || getDeclName())
165 return false;
166
Ted Kremenek6217b802009-07-29 21:53:49 +0000167 if (const RecordType *Record = getType()->getAs<RecordType>())
Douglas Gregor6b3945f2009-01-07 19:46:03 +0000168 return Record->getDecl()->isAnonymousStructOrUnion();
169
170 return false;
171}
Chris Lattnera98e58d2008-03-15 21:24:04 +0000172
Chris Lattner0ed844b2008-04-04 06:12:32 +0000173EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD,
174 SourceLocation L,
Chris Lattnerc63e6602008-03-15 21:32:50 +0000175 IdentifierInfo *Id, QualType T,
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000176 Expr *E, const llvm::APSInt &V) {
Steve Naroff3e970492009-01-27 21:25:57 +0000177 return new (C) EnumConstantDecl(CD, L, Id, T, E, V);
Chris Lattner6c2b6eb2008-03-15 06:12:44 +0000178}
179
Ted Kremenekd1ac17a2008-05-20 04:49:55 +0000180void EnumConstantDecl::Destroy(ASTContext& C) {
181 if (Init) Init->Destroy(C);
182 Decl::Destroy(C);
183}
184
Chris Lattner9fdf9c62008-04-22 18:39:57 +0000185TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC,
Chris Lattner0ed844b2008-04-04 06:12:32 +0000186 SourceLocation L,
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000187 IdentifierInfo *Id, QualType T) {
Steve Naroff3e970492009-01-27 21:25:57 +0000188 return new (C) TypedefDecl(DC, L, Id, T);
Chris Lattner6c2b6eb2008-03-15 06:12:44 +0000189}
190
Chris Lattner9fdf9c62008-04-22 18:39:57 +0000191EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
Douglas Gregor741dd9a2009-07-21 14:46:17 +0000192 IdentifierInfo *Id, SourceLocation TKL,
Douglas Gregor7df7b6b2008-12-15 16:32:14 +0000193 EnumDecl *PrevDecl) {
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000194 EnumDecl *Enum = new (C) EnumDecl(DC, L, Id, PrevDecl, TKL);
Douglas Gregor7df7b6b2008-12-15 16:32:14 +0000195 C.getTypeDeclType(Enum, PrevDecl);
196 return Enum;
Chris Lattner6c2b6eb2008-03-15 06:12:44 +0000197}
198
Ted Kremenekdf91eca2008-09-02 20:13:32 +0000199void EnumDecl::Destroy(ASTContext& C) {
Ted Kremenekdf91eca2008-09-02 20:13:32 +0000200 Decl::Destroy(C);
201}
202
Douglas Gregor44b43212008-12-11 16:49:14 +0000203void EnumDecl::completeDefinition(ASTContext &C, QualType NewType) {
204 assert(!isDefinition() && "Cannot redefine enums!");
Douglas Gregor44b43212008-12-11 16:49:14 +0000205 IntegerType = NewType;
Douglas Gregor0b7a1582009-01-17 00:42:38 +0000206 TagDecl::completeDefinition();
Douglas Gregor44b43212008-12-11 16:49:14 +0000207}
208
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000209FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC,
Chris Lattner0ed844b2008-04-04 06:12:32 +0000210 SourceLocation L,
Chris Lattner8e25d862008-03-16 00:16:02 +0000211 StringLiteral *Str) {
Steve Naroff3e970492009-01-27 21:25:57 +0000212 return new (C) FileScopeAsmDecl(DC, L, Str);
Chris Lattner8e25d862008-03-16 00:16:02 +0000213}
214
Chris Lattner6c2b6eb2008-03-15 06:12:44 +0000215//===----------------------------------------------------------------------===//
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000216// NamedDecl Implementation
Argyrios Kyrtzidis52393042008-11-09 23:41:00 +0000217//===----------------------------------------------------------------------===//
218
Douglas Gregor47b9a1c2009-02-04 17:27:36 +0000219std::string NamedDecl::getQualifiedNameAsString() const {
220 std::vector<std::string> Names;
221 std::string QualName;
222 const DeclContext *Ctx = getDeclContext();
223
224 if (Ctx->isFunctionOrMethod())
225 return getNameAsString();
226
227 while (Ctx) {
228 if (Ctx->isFunctionOrMethod())
229 // FIXME: That probably will happen, when D was member of local
230 // scope class/struct/union. How do we handle this case?
231 break;
232
Douglas Gregorf3e7ce42009-05-18 17:01:57 +0000233 if (const ClassTemplateSpecializationDecl *Spec
234 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) {
235 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
Chris Lattnere4f21422009-06-30 01:26:17 +0000236 PrintingPolicy Policy(getASTContext().getLangOptions());
Douglas Gregorf3e7ce42009-05-18 17:01:57 +0000237 std::string TemplateArgsStr
238 = TemplateSpecializationType::PrintTemplateArgumentList(
239 TemplateArgs.getFlatArgumentList(),
Douglas Gregord249e1d1f2009-05-29 20:38:28 +0000240 TemplateArgs.flat_size(),
241 Policy);
Douglas Gregorf3e7ce42009-05-18 17:01:57 +0000242 Names.push_back(Spec->getIdentifier()->getName() + TemplateArgsStr);
243 } else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx))
Douglas Gregor47b9a1c2009-02-04 17:27:36 +0000244 Names.push_back(ND->getNameAsString());
245 else
246 break;
247
248 Ctx = Ctx->getParent();
249 }
250
251 std::vector<std::string>::reverse_iterator
252 I = Names.rbegin(),
253 End = Names.rend();
254
255 for (; I!=End; ++I)
256 QualName += *I + "::";
257
258 QualName += getNameAsString();
259
260 return QualName;
261}
262
263
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000264bool NamedDecl::declarationReplaces(NamedDecl *OldD) const {
Douglas Gregor6ed40e32008-12-23 21:05:05 +0000265 assert(getDeclName() == OldD->getDeclName() && "Declaration name mismatch");
266
Douglas Gregor2a3009a2009-02-03 19:21:40 +0000267 // UsingDirectiveDecl's are not really NamedDecl's, and all have same name.
268 // We want to keep it, unless it nominates same namespace.
269 if (getKind() == Decl::UsingDirective) {
270 return cast<UsingDirectiveDecl>(this)->getNominatedNamespace() ==
271 cast<UsingDirectiveDecl>(OldD)->getNominatedNamespace();
272 }
273
Douglas Gregor6ed40e32008-12-23 21:05:05 +0000274 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
275 // For function declarations, we keep track of redeclarations.
276 return FD->getPreviousDeclaration() == OldD;
277
Douglas Gregore53060f2009-06-25 22:08:12 +0000278 // For function templates, the underlying function declarations are linked.
279 if (const FunctionTemplateDecl *FunctionTemplate
280 = dyn_cast<FunctionTemplateDecl>(this))
281 if (const FunctionTemplateDecl *OldFunctionTemplate
282 = dyn_cast<FunctionTemplateDecl>(OldD))
283 return FunctionTemplate->getTemplatedDecl()
284 ->declarationReplaces(OldFunctionTemplate->getTemplatedDecl());
285
Steve Naroff0de21fd2009-02-22 19:35:57 +0000286 // For method declarations, we keep track of redeclarations.
287 if (isa<ObjCMethodDecl>(this))
288 return false;
289
Douglas Gregor6ed40e32008-12-23 21:05:05 +0000290 // For non-function declarations, if the declarations are of the
291 // same kind then this must be a redeclaration, or semantic analysis
292 // would not have given us the new declaration.
293 return this->getKind() == OldD->getKind();
294}
295
Douglas Gregord6f7e9d2009-02-24 20:03:32 +0000296bool NamedDecl::hasLinkage() const {
297 if (const VarDecl *VD = dyn_cast<VarDecl>(this))
298 return VD->hasExternalStorage() || VD->isFileVarDecl();
299
300 if (isa<FunctionDecl>(this) && !isa<CXXMethodDecl>(this))
301 return true;
302
303 return false;
304}
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000305
Anders Carlssone136e0e2009-06-26 06:29:23 +0000306NamedDecl *NamedDecl::getUnderlyingDecl() {
307 NamedDecl *ND = this;
308 while (true) {
309 if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
310 ND = UD->getTargetDecl();
311 else if (ObjCCompatibleAliasDecl *AD
312 = dyn_cast<ObjCCompatibleAliasDecl>(ND))
313 return AD->getClassInterface();
314 else
315 return ND;
316 }
317}
318
Argyrios Kyrtzidis52393042008-11-09 23:41:00 +0000319//===----------------------------------------------------------------------===//
Nuno Lopes99f06ba2008-12-17 23:39:55 +0000320// VarDecl Implementation
321//===----------------------------------------------------------------------===//
322
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000323VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000324 IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo,
325 StorageClass S, SourceLocation TypeSpecStartLoc) {
326 return new (C) VarDecl(Var, DC, L, Id, T, DInfo, S, TypeSpecStartLoc);
Nuno Lopes99f06ba2008-12-17 23:39:55 +0000327}
328
329void VarDecl::Destroy(ASTContext& C) {
Sebastian Redldf2d3cf2009-02-05 15:12:41 +0000330 Expr *Init = getInit();
Douglas Gregor78d15832009-05-26 18:54:04 +0000331 if (Init) {
Sebastian Redldf2d3cf2009-02-05 15:12:41 +0000332 Init->Destroy(C);
Douglas Gregor78d15832009-05-26 18:54:04 +0000333 if (EvaluatedStmt *Eval = this->Init.dyn_cast<EvaluatedStmt *>()) {
334 Eval->~EvaluatedStmt();
335 C.Deallocate(Eval);
336 }
337 }
Nuno Lopes99f06ba2008-12-17 23:39:55 +0000338 this->~VarDecl();
Steve Naroff3e970492009-01-27 21:25:57 +0000339 C.Deallocate((void *)this);
Nuno Lopes99f06ba2008-12-17 23:39:55 +0000340}
341
342VarDecl::~VarDecl() {
Nuno Lopes99f06ba2008-12-17 23:39:55 +0000343}
344
Argyrios Kyrtzidis55d608c2009-06-20 08:09:14 +0000345SourceRange VarDecl::getSourceRange() const {
346 if (getInit())
347 return SourceRange(getLocation(), getInit()->getLocEnd());
348 return SourceRange(getLocation(), getLocation());
349}
350
Douglas Gregor7caa6822009-07-24 20:34:43 +0000351VarDecl *VarDecl::getInstantiatedFromStaticDataMember() {
352 return getASTContext().getInstantiatedFromStaticDataMember(this);
353}
354
Douglas Gregor275a3692009-03-10 23:43:53 +0000355bool VarDecl::isTentativeDefinition(ASTContext &Context) const {
356 if (!isFileVarDecl() || Context.getLangOptions().CPlusPlus)
357 return false;
358
Douglas Gregorb6c8c8b2009-04-21 17:11:58 +0000359 const VarDecl *Def = 0;
360 return (!getDefinition(Def) &&
Douglas Gregor275a3692009-03-10 23:43:53 +0000361 (getStorageClass() == None || getStorageClass() == Static));
362}
363
Ted Kremenek082d9362009-03-20 21:35:28 +0000364const Expr *VarDecl::getDefinition(const VarDecl *&Def) const {
Argyrios Kyrtzidisc37929c2009-07-14 03:20:21 +0000365 redecl_iterator I = redecls_begin(), E = redecls_end();
366 while (I != E && !I->getInit())
367 ++I;
Douglas Gregor275a3692009-03-10 23:43:53 +0000368
Argyrios Kyrtzidisc37929c2009-07-14 03:20:21 +0000369 if (I != E) {
370 Def = *I;
371 return I->getInit();
372 }
373 return 0;
Douglas Gregor275a3692009-03-10 23:43:53 +0000374}
375
Argyrios Kyrtzidisb57a4fe2009-07-18 00:34:07 +0000376VarDecl *VarDecl::getCanonicalDecl() {
Argyrios Kyrtzidisf23e8392009-07-18 08:50:13 +0000377 return getFirstDeclaration();
Argyrios Kyrtzidisfc7e2a82009-07-05 22:21:56 +0000378}
379
Nuno Lopes99f06ba2008-12-17 23:39:55 +0000380//===----------------------------------------------------------------------===//
Chris Lattner8a934232008-03-31 00:36:02 +0000381// FunctionDecl Implementation
382//===----------------------------------------------------------------------===//
383
Ted Kremenek27f8a282008-05-20 00:43:19 +0000384void FunctionDecl::Destroy(ASTContext& C) {
Douglas Gregor250fc9c2009-04-18 00:07:54 +0000385 if (Body && Body.isOffset())
386 Body.get(C.getExternalSource())->Destroy(C);
Ted Kremenekb65cf412008-05-20 03:56:00 +0000387
388 for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
389 (*I)->Destroy(C);
Nuno Lopes460b0ac2009-01-18 19:57:27 +0000390
Steve Naroff3e970492009-01-27 21:25:57 +0000391 C.Deallocate(ParamInfo);
Nuno Lopes460b0ac2009-01-18 19:57:27 +0000392
Ted Kremenek27f8a282008-05-20 00:43:19 +0000393 Decl::Destroy(C);
394}
395
396
Argyrios Kyrtzidis6fb0aee2009-06-30 02:35:26 +0000397Stmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const {
Argyrios Kyrtzidisc37929c2009-07-14 03:20:21 +0000398 for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
399 if (I->Body) {
400 Definition = *I;
401 return I->Body.get(getASTContext().getExternalSource());
Douglas Gregorf0097952008-04-21 02:02:58 +0000402 }
403 }
404
405 return 0;
Reid Spencer5f016e22007-07-11 17:01:13 +0000406}
407
Sebastian Redld3a413d2009-04-26 20:35:05 +0000408Stmt *FunctionDecl::getBodyIfAvailable() const {
Argyrios Kyrtzidisc37929c2009-07-14 03:20:21 +0000409 for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
410 if (I->Body && !I->Body.isOffset()) {
411 return I->Body.get(0);
Douglas Gregor250fc9c2009-04-18 00:07:54 +0000412 }
Douglas Gregor72971342009-04-18 00:02:19 +0000413 }
414
415 return 0;
416}
417
Argyrios Kyrtzidis55d608c2009-06-20 08:09:14 +0000418void FunctionDecl::setBody(Stmt *B) {
419 Body = B;
Argyrios Kyrtzidis1a5364e2009-06-22 17:13:31 +0000420 if (B)
Argyrios Kyrtzidis55d608c2009-06-20 08:09:14 +0000421 EndRangeLoc = B->getLocEnd();
422}
423
John McCall07a5c222009-08-15 02:09:25 +0000424bool FunctionDecl::isMain(ASTContext &Context) const {
425 return !Context.getLangOptions().Freestanding &&
426 getDeclContext()->getLookupContext()->isTranslationUnit() &&
Douglas Gregor04495c82009-02-24 01:23:02 +0000427 getIdentifier() && getIdentifier()->isStr("main");
428}
429
Douglas Gregor63935192009-03-02 00:19:53 +0000430bool FunctionDecl::isExternC(ASTContext &Context) const {
431 // In C, any non-static, non-overloadable function has external
432 // linkage.
433 if (!Context.getLangOptions().CPlusPlus)
Argyrios Kyrtzidis40b598e2009-06-30 02:34:44 +0000434 return getStorageClass() != Static && !getAttr<OverloadableAttr>();
Douglas Gregor63935192009-03-02 00:19:53 +0000435
436 for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit();
437 DC = DC->getParent()) {
438 if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC)) {
439 if (Linkage->getLanguage() == LinkageSpecDecl::lang_c)
Douglas Gregor68584ed2009-06-18 16:11:24 +0000440 return getStorageClass() != Static &&
Argyrios Kyrtzidis40b598e2009-06-30 02:34:44 +0000441 !getAttr<OverloadableAttr>();
Douglas Gregor63935192009-03-02 00:19:53 +0000442
443 break;
444 }
445 }
446
447 return false;
448}
449
Douglas Gregor8499f3f2009-03-31 16:35:03 +0000450bool FunctionDecl::isGlobal() const {
451 if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(this))
452 return Method->isStatic();
453
454 if (getStorageClass() == Static)
455 return false;
456
457 for (const DeclContext *DC = getDeclContext();
458 DC->isNamespace();
459 DC = DC->getParent()) {
460 if (const NamespaceDecl *Namespace = cast<NamespaceDecl>(DC)) {
461 if (!Namespace->getDeclName())
462 return false;
463 break;
464 }
465 }
466
467 return true;
468}
469
Douglas Gregor3e41d602009-02-13 23:20:09 +0000470/// \brief Returns a value indicating whether this function
471/// corresponds to a builtin function.
472///
473/// The function corresponds to a built-in function if it is
474/// declared at translation scope or within an extern "C" block and
475/// its name matches with the name of a builtin. The returned value
476/// will be 0 for functions that do not correspond to a builtin, a
477/// value of type \c Builtin::ID if in the target-independent range
478/// \c [1,Builtin::First), or a target-specific builtin value.
Douglas Gregor3c385e52009-02-14 18:57:46 +0000479unsigned FunctionDecl::getBuiltinID(ASTContext &Context) const {
480 if (!getIdentifier() || !getIdentifier()->getBuiltinID())
481 return 0;
482
483 unsigned BuiltinID = getIdentifier()->getBuiltinID();
484 if (!Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
485 return BuiltinID;
486
487 // This function has the name of a known C library
488 // function. Determine whether it actually refers to the C library
489 // function or whether it just has the same name.
490
Douglas Gregor9add3172009-02-17 03:23:10 +0000491 // If this is a static function, it's not a builtin.
492 if (getStorageClass() == Static)
493 return 0;
494
Douglas Gregor3c385e52009-02-14 18:57:46 +0000495 // If this function is at translation-unit scope and we're not in
496 // C++, it refers to the C library function.
497 if (!Context.getLangOptions().CPlusPlus &&
498 getDeclContext()->isTranslationUnit())
499 return BuiltinID;
500
501 // If the function is in an extern "C" linkage specification and is
502 // not marked "overloadable", it's the real function.
503 if (isa<LinkageSpecDecl>(getDeclContext()) &&
504 cast<LinkageSpecDecl>(getDeclContext())->getLanguage()
505 == LinkageSpecDecl::lang_c &&
Argyrios Kyrtzidis40b598e2009-06-30 02:34:44 +0000506 !getAttr<OverloadableAttr>())
Douglas Gregor3c385e52009-02-14 18:57:46 +0000507 return BuiltinID;
508
509 // Not a builtin
Douglas Gregor3e41d602009-02-13 23:20:09 +0000510 return 0;
511}
512
513
Chris Lattner1ad9b282009-04-25 06:03:53 +0000514/// getNumParams - Return the number of parameters this function must have
Chris Lattner2dbd2852009-04-25 06:12:16 +0000515/// based on its FunctionType. This is the length of the PararmInfo array
Chris Lattner1ad9b282009-04-25 06:03:53 +0000516/// after it has been created.
517unsigned FunctionDecl::getNumParams() const {
Chris Lattner11ddb7d2009-04-25 05:56:45 +0000518 const FunctionType *FT = getType()->getAsFunctionType();
Douglas Gregor72564e72009-02-26 23:50:07 +0000519 if (isa<FunctionNoProtoType>(FT))
Chris Lattnerd3b90652008-03-15 05:43:15 +0000520 return 0;
Douglas Gregor72564e72009-02-26 23:50:07 +0000521 return cast<FunctionProtoType>(FT)->getNumArgs();
Chris Lattner11ddb7d2009-04-25 05:56:45 +0000522
Reid Spencer5f016e22007-07-11 17:01:13 +0000523}
524
Ted Kremenekfc767612009-01-14 00:42:25 +0000525void FunctionDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
526 unsigned NumParams) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000527 assert(ParamInfo == 0 && "Already has param info!");
Chris Lattner2dbd2852009-04-25 06:12:16 +0000528 assert(NumParams == getNumParams() && "Parameter count mismatch!");
Reid Spencer5f016e22007-07-11 17:01:13 +0000529
530 // Zero params -> null pointer.
531 if (NumParams) {
Steve Naroffc0ac4922009-01-27 23:20:32 +0000532 void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);
Ted Kremenekfc767612009-01-14 00:42:25 +0000533 ParamInfo = new (Mem) ParmVarDecl*[NumParams];
Reid Spencer5f016e22007-07-11 17:01:13 +0000534 memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
Argyrios Kyrtzidis55d608c2009-06-20 08:09:14 +0000535
Argyrios Kyrtzidis96888cc2009-06-23 00:42:00 +0000536 // Update source range. The check below allows us to set EndRangeLoc before
537 // setting the parameters.
Argyrios Kyrtzidiscb5f8f52009-06-23 00:42:15 +0000538 if (EndRangeLoc.isInvalid() || EndRangeLoc == getLocation())
Argyrios Kyrtzidis55d608c2009-06-20 08:09:14 +0000539 EndRangeLoc = NewParamInfo[NumParams-1]->getLocEnd();
Reid Spencer5f016e22007-07-11 17:01:13 +0000540 }
541}
542
Chris Lattner8123a952008-04-10 02:22:51 +0000543/// getMinRequiredArguments - Returns the minimum number of arguments
544/// needed to call this function. This may be fewer than the number of
545/// function parameters, if some of the parameters have default
Chris Lattner9e979552008-04-12 23:52:44 +0000546/// arguments (in C++).
Chris Lattner8123a952008-04-10 02:22:51 +0000547unsigned FunctionDecl::getMinRequiredArguments() const {
548 unsigned NumRequiredArgs = getNumParams();
549 while (NumRequiredArgs > 0
Anders Carlssonae0b4e72009-06-06 04:14:07 +0000550 && getParamDecl(NumRequiredArgs-1)->hasDefaultArg())
Chris Lattner8123a952008-04-10 02:22:51 +0000551 --NumRequiredArgs;
552
553 return NumRequiredArgs;
554}
555
Douglas Gregor68584ed2009-06-18 16:11:24 +0000556bool FunctionDecl::hasActiveGNUInlineAttribute(ASTContext &Context) const {
Argyrios Kyrtzidis40b598e2009-06-30 02:34:44 +0000557 if (!isInline() || !hasAttr<GNUInlineAttr>())
Douglas Gregor9f9bf252009-04-28 06:37:30 +0000558 return false;
559
Argyrios Kyrtzidisc37929c2009-07-14 03:20:21 +0000560 for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I)
561 if (I->isInline() && !I->hasAttr<GNUInlineAttr>())
Douglas Gregor9f9bf252009-04-28 06:37:30 +0000562 return false;
Douglas Gregor9f9bf252009-04-28 06:37:30 +0000563
564 return true;
565}
566
Douglas Gregor68584ed2009-06-18 16:11:24 +0000567bool FunctionDecl::isExternGNUInline(ASTContext &Context) const {
568 if (!hasActiveGNUInlineAttribute(Context))
Douglas Gregor9f9bf252009-04-28 06:37:30 +0000569 return false;
570
Argyrios Kyrtzidisc37929c2009-07-14 03:20:21 +0000571 for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I)
572 if (I->getStorageClass() == Extern && I->hasAttr<GNUInlineAttr>())
Douglas Gregor9f9bf252009-04-28 06:37:30 +0000573 return true;
574
575 return false;
576}
577
Douglas Gregor127102b2009-06-29 20:59:39 +0000578void
579FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
Argyrios Kyrtzidis1e4bc092009-07-18 08:50:35 +0000580 redeclarable_base::setPreviousDeclaration(PrevDecl);
Argyrios Kyrtzidisf23e8392009-07-18 08:50:13 +0000581
Douglas Gregor127102b2009-06-29 20:59:39 +0000582 if (FunctionTemplateDecl *FunTmpl = getDescribedFunctionTemplate()) {
583 FunctionTemplateDecl *PrevFunTmpl
584 = PrevDecl? PrevDecl->getDescribedFunctionTemplate() : 0;
585 assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch");
586 FunTmpl->setPreviousDeclaration(PrevFunTmpl);
587 }
588}
589
Argyrios Kyrtzidisb57a4fe2009-07-18 00:34:07 +0000590FunctionDecl *FunctionDecl::getCanonicalDecl() {
Argyrios Kyrtzidisf23e8392009-07-18 08:50:13 +0000591 return getFirstDeclaration();
Argyrios Kyrtzidisfc7e2a82009-07-05 22:21:56 +0000592}
593
Douglas Gregor1cd1b1e2008-11-06 22:13:31 +0000594/// getOverloadedOperator - Which C++ overloaded operator this
595/// function represents, if any.
596OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
Douglas Gregore94ca9e42008-11-18 14:39:36 +0000597 if (getDeclName().getNameKind() == DeclarationName::CXXOperatorName)
598 return getDeclName().getCXXOverloadedOperator();
Douglas Gregor1cd1b1e2008-11-06 22:13:31 +0000599 else
600 return OO_None;
601}
602
Douglas Gregor16e8be22009-06-29 17:30:29 +0000603FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const {
604 if (FunctionTemplateSpecializationInfo *Info
605 = TemplateOrSpecialization
606 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
Douglas Gregor1fd2dd12009-06-29 22:39:32 +0000607 return Info->Template.getPointer();
Douglas Gregor16e8be22009-06-29 17:30:29 +0000608 }
609 return 0;
610}
611
612const TemplateArgumentList *
613FunctionDecl::getTemplateSpecializationArgs() const {
614 if (FunctionTemplateSpecializationInfo *Info
615 = TemplateOrSpecialization
616 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
617 return Info->TemplateArguments;
618 }
619 return 0;
620}
621
Douglas Gregor1637be72009-06-26 00:10:03 +0000622void
623FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context,
624 FunctionTemplateDecl *Template,
Douglas Gregor127102b2009-06-29 20:59:39 +0000625 const TemplateArgumentList *TemplateArgs,
626 void *InsertPos) {
Douglas Gregor16e8be22009-06-29 17:30:29 +0000627 FunctionTemplateSpecializationInfo *Info
628 = TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
Douglas Gregor1637be72009-06-26 00:10:03 +0000629 if (!Info)
Douglas Gregor16e8be22009-06-29 17:30:29 +0000630 Info = new (Context) FunctionTemplateSpecializationInfo;
Douglas Gregor1637be72009-06-26 00:10:03 +0000631
Douglas Gregor127102b2009-06-29 20:59:39 +0000632 Info->Function = this;
Douglas Gregor1fd2dd12009-06-29 22:39:32 +0000633 Info->Template.setPointer(Template);
634 Info->Template.setInt(0); // Implicit instantiation, unless told otherwise
Douglas Gregor1637be72009-06-26 00:10:03 +0000635 Info->TemplateArguments = TemplateArgs;
636 TemplateOrSpecialization = Info;
Douglas Gregor127102b2009-06-29 20:59:39 +0000637
638 // Insert this function template specialization into the set of known
639 // function template specialiations.
640 Template->getSpecializations().InsertNode(Info, InsertPos);
Douglas Gregor1637be72009-06-26 00:10:03 +0000641}
642
Douglas Gregor1fd2dd12009-06-29 22:39:32 +0000643bool FunctionDecl::isExplicitSpecialization() const {
644 // FIXME: check this property for explicit specializations of member
645 // functions of class templates.
646 FunctionTemplateSpecializationInfo *Info
647 = TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
648 if (!Info)
649 return false;
650
651 return Info->isExplicitSpecialization();
652}
653
654void FunctionDecl::setExplicitSpecialization(bool ES) {
655 // FIXME: set this property for explicit specializations of member functions
656 // of class templates.
657 FunctionTemplateSpecializationInfo *Info
658 = TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
659 if (Info)
660 Info->setExplicitSpecialization(ES);
661}
662
Chris Lattner8a934232008-03-31 00:36:02 +0000663//===----------------------------------------------------------------------===//
Douglas Gregorbcbffc42009-01-07 00:43:41 +0000664// TagDecl Implementation
Ted Kremenek4b7c9832008-09-05 17:16:31 +0000665//===----------------------------------------------------------------------===//
666
Argyrios Kyrtzidisf602c8b2009-07-14 03:17:17 +0000667SourceRange TagDecl::getSourceRange() const {
668 SourceLocation E = RBraceLoc.isValid() ? RBraceLoc : getLocation();
Douglas Gregor741dd9a2009-07-21 14:46:17 +0000669 return SourceRange(TagKeywordLoc, E);
Argyrios Kyrtzidisf602c8b2009-07-14 03:17:17 +0000670}
671
Argyrios Kyrtzidisb57a4fe2009-07-18 00:34:07 +0000672TagDecl* TagDecl::getCanonicalDecl() {
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000673 return getFirstDeclaration();
Argyrios Kyrtzidisb57a4fe2009-07-18 00:34:07 +0000674}
675
Douglas Gregor0b7a1582009-01-17 00:42:38 +0000676void TagDecl::startDefinition() {
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000677 if (TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>())) {
678 TagT->decl.setPointer(this);
679 TagT->decl.setInt(1);
680 }
Douglas Gregor0b7a1582009-01-17 00:42:38 +0000681}
682
683void TagDecl::completeDefinition() {
Douglas Gregor0b7a1582009-01-17 00:42:38 +0000684 IsDefinition = true;
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000685 if (TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>())) {
686 assert(TagT->decl.getPointer() == this &&
687 "Attempt to redefine a tag definition?");
688 TagT->decl.setInt(0);
689 }
Douglas Gregor0b7a1582009-01-17 00:42:38 +0000690}
691
Ted Kremenek4b7c9832008-09-05 17:16:31 +0000692TagDecl* TagDecl::getDefinition(ASTContext& C) const {
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000693 if (isDefinition())
694 return const_cast<TagDecl *>(this);
695
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000696 for (redecl_iterator R = redecls_begin(), REnd = redecls_end();
697 R != REnd; ++R)
698 if (R->isDefinition())
699 return *R;
700
701 return 0;
Ted Kremenek4b7c9832008-09-05 17:16:31 +0000702}
703
704//===----------------------------------------------------------------------===//
Chris Lattner8a934232008-03-31 00:36:02 +0000705// RecordDecl Implementation
706//===----------------------------------------------------------------------===//
Reid Spencer5f016e22007-07-11 17:01:13 +0000707
Argyrios Kyrtzidis35bc0822008-10-15 00:42:39 +0000708RecordDecl::RecordDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000709 IdentifierInfo *Id, RecordDecl *PrevDecl,
710 SourceLocation TKL)
711 : TagDecl(DK, TK, DC, L, Id, PrevDecl, TKL) {
Ted Kremenek63597922008-09-02 21:12:32 +0000712 HasFlexibleArrayMember = false;
Douglas Gregorbcbffc42009-01-07 00:43:41 +0000713 AnonymousStructOrUnion = false;
Fariborz Jahanian082b02e2009-07-08 01:18:33 +0000714 HasObjectMember = false;
Ted Kremenek63597922008-09-02 21:12:32 +0000715 assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
Ted Kremenek63597922008-09-02 21:12:32 +0000716}
717
718RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
Ted Kremenek4b7c9832008-09-05 17:16:31 +0000719 SourceLocation L, IdentifierInfo *Id,
Douglas Gregor741dd9a2009-07-21 14:46:17 +0000720 SourceLocation TKL, RecordDecl* PrevDecl) {
Ted Kremenekdf042e62008-09-05 01:34:33 +0000721
Douglas Gregor8e9e9ef2009-07-29 23:36:44 +0000722 RecordDecl* R = new (C) RecordDecl(Record, TK, DC, L, Id, PrevDecl, TKL);
Ted Kremenek4b7c9832008-09-05 17:16:31 +0000723 C.getTypeDeclType(R, PrevDecl);
724 return R;
Ted Kremenek63597922008-09-02 21:12:32 +0000725}
726
Argyrios Kyrtzidis997b6c62008-08-08 14:08:55 +0000727RecordDecl::~RecordDecl() {
Argyrios Kyrtzidis997b6c62008-08-08 14:08:55 +0000728}
729
730void RecordDecl::Destroy(ASTContext& C) {
Argyrios Kyrtzidis997b6c62008-08-08 14:08:55 +0000731 TagDecl::Destroy(C);
732}
733
Douglas Gregorc9b5b402009-03-25 15:59:44 +0000734bool RecordDecl::isInjectedClassName() const {
735 return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
736 cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
737}
738
Douglas Gregor44b43212008-12-11 16:49:14 +0000739/// completeDefinition - Notes that the definition of this type is now
740/// complete.
741void RecordDecl::completeDefinition(ASTContext& C) {
Reid Spencer5f016e22007-07-11 17:01:13 +0000742 assert(!isDefinition() && "Cannot redefine record!");
Douglas Gregor0b7a1582009-01-17 00:42:38 +0000743 TagDecl::completeDefinition();
Reid Spencer5f016e22007-07-11 17:01:13 +0000744}
745
Steve Naroff56ee6892008-10-08 17:01:13 +0000746//===----------------------------------------------------------------------===//
747// BlockDecl Implementation
748//===----------------------------------------------------------------------===//
749
750BlockDecl::~BlockDecl() {
751}
752
753void BlockDecl::Destroy(ASTContext& C) {
754 if (Body)
755 Body->Destroy(C);
756
757 for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
758 (*I)->Destroy(C);
Ted Kremenek879d27a2009-03-13 23:17:24 +0000759
760 C.Deallocate(ParamInfo);
Steve Naroff56ee6892008-10-08 17:01:13 +0000761 Decl::Destroy(C);
762}
Steve Naroffe78b8092009-03-13 16:56:44 +0000763
764void BlockDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
765 unsigned NParms) {
766 assert(ParamInfo == 0 && "Already has param info!");
767
768 // Zero params -> null pointer.
769 if (NParms) {
770 NumParams = NParms;
771 void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);
772 ParamInfo = new (Mem) ParmVarDecl*[NumParams];
773 memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
774 }
775}
776
777unsigned BlockDecl::getNumParams() const {
778 return NumParams;
779}