blob: d3688d5255750fb24944b59854ae7f2bfddc1861 [file] [log] [blame]
Chris Lattnera11999d2006-10-15 22:34:45 +00001//===--- 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 Lattner17ed4872006-11-20 04:58:19 +000015#include "clang/Lex/IdentifierTable.h"
Chris Lattner6d9a6852006-10-25 05:11:20 +000016using namespace llvm;
17using namespace clang;
Chris Lattnera11999d2006-10-15 22:34:45 +000018
Chris Lattner6d9a6852006-10-25 05:11:20 +000019// Out-of-line virtual method providing a home for Decl.
20Decl::~Decl() {
21}
Chris Lattner17ed4872006-11-20 04:58:19 +000022
23const char *Decl::getName() const {
24 return getIdentifier()->getName();
25}
Chris Lattnerc5cdf4d2007-01-21 07:42:07 +000026
27
28FunctionDecl::~FunctionDecl() {
29 delete[] ParamInfo;
30}
31
32unsigned FunctionDecl::getNumParams() const {
33 return cast<FunctionTypeProto>(getType().getTypePtr())->getNumArgs();
34}
35
36void 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}