Chris Lattner | a11999d | 2006-10-15 22:34:45 +0000 | [diff] [blame] | 1 | //===--- Decl.cpp - Declaration AST Node Implementation -------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Decl class and subclasses. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/Decl.h" |
Chris Lattner | 17ed487 | 2006-11-20 04:58:19 +0000 | [diff] [blame] | 15 | #include "clang/Lex/IdentifierTable.h" |
Chris Lattner | 6d9a685 | 2006-10-25 05:11:20 +0000 | [diff] [blame] | 16 | using namespace llvm; |
| 17 | using namespace clang; |
Chris Lattner | a11999d | 2006-10-15 22:34:45 +0000 | [diff] [blame] | 18 | |
Chris Lattner | 6d9a685 | 2006-10-25 05:11:20 +0000 | [diff] [blame] | 19 | // Out-of-line virtual method providing a home for Decl. |
| 20 | Decl::~Decl() { |
| 21 | } |
Chris Lattner | 17ed487 | 2006-11-20 04:58:19 +0000 | [diff] [blame] | 22 | |
| 23 | const char *Decl::getName() const { |
| 24 | return getIdentifier()->getName(); |
| 25 | } |
Chris Lattner | c5cdf4d | 2007-01-21 07:42:07 +0000 | [diff] [blame] | 26 | |
| 27 | |
| 28 | FunctionDecl::~FunctionDecl() { |
| 29 | delete[] ParamInfo; |
| 30 | } |
| 31 | |
| 32 | unsigned FunctionDecl::getNumParams() const { |
| 33 | return cast<FunctionTypeProto>(getType().getTypePtr())->getNumArgs(); |
| 34 | } |
| 35 | |
| 36 | void FunctionDecl::setParams(VarDecl **NewParamInfo, unsigned NumParams) { |
| 37 | assert(ParamInfo == 0 && "Already has param info!"); |
| 38 | assert(NumParams == getNumParams() && "Parameter count mismatch!"); |
| 39 | |
| 40 | ParamInfo = new VarDecl*[NumParams]; |
| 41 | memcpy(ParamInfo, NewParamInfo, sizeof(VarDecl*)*NumParams); |
| 42 | } |