Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 1 | //===--- DeclCXX.cpp - C++ Declaration AST Node Implementation ------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the C++ related Decl classes. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/DeclCXX.h" |
| 15 | #include "clang/AST/ASTContext.h" |
Douglas Gregor | 7d7e672 | 2008-11-12 23:21:09 +0000 | [diff] [blame] | 16 | #include "clang/Basic/IdentifierTable.h" |
Douglas Gregor | fdfab6b | 2008-12-23 21:31:30 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 18 | using namespace clang; |
| 19 | |
| 20 | //===----------------------------------------------------------------------===// |
| 21 | // Decl Allocation/Deallocation Method Implementations |
| 22 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 23 | |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame^] | 24 | CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC, |
Douglas Gregor | 7d7e672 | 2008-11-12 23:21:09 +0000 | [diff] [blame] | 25 | SourceLocation L, IdentifierInfo *Id) |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame^] | 26 | : RecordDecl(K, TK, DC, L, Id), |
Douglas Gregor | 7d7e672 | 2008-11-12 23:21:09 +0000 | [diff] [blame] | 27 | UserDeclaredConstructor(false), UserDeclaredCopyConstructor(false), |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 28 | UserDeclaredCopyAssignment(false), UserDeclaredDestructor(false), |
| 29 | Aggregate(true), PlainOldData(true), Polymorphic(false), Bases(0), |
| 30 | NumBases(0), Conversions(DC, DeclarationName()) { } |
Douglas Gregor | 7d7e672 | 2008-11-12 23:21:09 +0000 | [diff] [blame] | 31 | |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 32 | CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC, |
| 33 | SourceLocation L, IdentifierInfo *Id, |
| 34 | CXXRecordDecl* PrevDecl) { |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame^] | 35 | CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, L, Id); |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 36 | C.getTypeDeclType(R, PrevDecl); |
| 37 | return R; |
| 38 | } |
| 39 | |
Douglas Gregor | f8268ae | 2008-10-22 17:49:05 +0000 | [diff] [blame] | 40 | CXXRecordDecl::~CXXRecordDecl() { |
Douglas Gregor | f8268ae | 2008-10-22 17:49:05 +0000 | [diff] [blame] | 41 | delete [] Bases; |
| 42 | } |
| 43 | |
Douglas Gregor | 57c856b | 2008-10-23 18:13:27 +0000 | [diff] [blame] | 44 | void |
| 45 | CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, |
| 46 | unsigned NumBases) { |
Douglas Gregor | 64bffa9 | 2008-11-05 16:20:31 +0000 | [diff] [blame] | 47 | // C++ [dcl.init.aggr]p1: |
| 48 | // An aggregate is an array or a class (clause 9) with [...] |
| 49 | // no base classes [...]. |
| 50 | Aggregate = false; |
| 51 | |
Douglas Gregor | 57c856b | 2008-10-23 18:13:27 +0000 | [diff] [blame] | 52 | if (this->Bases) |
| 53 | delete [] this->Bases; |
| 54 | |
| 55 | this->Bases = new CXXBaseSpecifier[NumBases]; |
| 56 | this->NumBases = NumBases; |
| 57 | for (unsigned i = 0; i < NumBases; ++i) |
| 58 | this->Bases[i] = *Bases[i]; |
| 59 | } |
| 60 | |
Douglas Gregor | 396b7cd | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 61 | bool CXXRecordDecl::hasConstCopyConstructor(ASTContext &Context) const { |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 62 | QualType ClassType |
| 63 | = Context.getTypeDeclType(const_cast<CXXRecordDecl*>(this)); |
Douglas Gregor | 9e7d9de | 2008-12-15 21:24:18 +0000 | [diff] [blame] | 64 | DeclarationName ConstructorName |
| 65 | = Context.DeclarationNames.getCXXConstructorName( |
| 66 | Context.getCanonicalType(ClassType)); |
| 67 | unsigned TypeQuals; |
Douglas Gregor | fdfab6b | 2008-12-23 21:31:30 +0000 | [diff] [blame] | 68 | DeclContext::lookup_const_iterator Con, ConEnd; |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 69 | for (llvm::tie(Con, ConEnd) = this->lookup(ConstructorName); |
Douglas Gregor | fdfab6b | 2008-12-23 21:31:30 +0000 | [diff] [blame] | 70 | Con != ConEnd; ++Con) { |
Douglas Gregor | 396b7cd | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 71 | if (cast<CXXConstructorDecl>(*Con)->isCopyConstructor(Context, TypeQuals) && |
Eli Friedman | e8e3205 | 2008-12-16 20:06:41 +0000 | [diff] [blame] | 72 | (TypeQuals & QualType::Const) != 0) |
Douglas Gregor | 396b7cd | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 73 | return true; |
| 74 | } |
Douglas Gregor | fdfab6b | 2008-12-23 21:31:30 +0000 | [diff] [blame] | 75 | |
Douglas Gregor | 396b7cd | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 76 | return false; |
| 77 | } |
| 78 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 79 | bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context) const { |
| 80 | QualType ClassType = Context.getCanonicalType(Context.getTypeDeclType( |
| 81 | const_cast<CXXRecordDecl*>(this))); |
| 82 | DeclarationName OpName =Context.DeclarationNames.getCXXOperatorName(OO_Equal); |
| 83 | |
| 84 | DeclContext::lookup_const_iterator Op, OpEnd; |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 85 | for (llvm::tie(Op, OpEnd) = this->lookup(OpName); |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 86 | Op != OpEnd; ++Op) { |
| 87 | // C++ [class.copy]p9: |
| 88 | // A user-declared copy assignment operator is a non-static non-template |
| 89 | // member function of class X with exactly one parameter of type X, X&, |
| 90 | // const X&, volatile X& or const volatile X&. |
| 91 | const CXXMethodDecl* Method = cast<CXXMethodDecl>(*Op); |
| 92 | if (Method->isStatic()) |
| 93 | continue; |
| 94 | // TODO: Skip templates? Or is this implicitly done due to parameter types? |
| 95 | const FunctionTypeProto *FnType = |
| 96 | Method->getType()->getAsFunctionTypeProto(); |
| 97 | assert(FnType && "Overloaded operator has no prototype."); |
| 98 | // Don't assert on this; an invalid decl might have been left in the AST. |
| 99 | if (FnType->getNumArgs() != 1 || FnType->isVariadic()) |
| 100 | continue; |
| 101 | bool AcceptsConst = true; |
| 102 | QualType ArgType = FnType->getArgType(0); |
| 103 | if (const ReferenceType *Ref = ArgType->getAsReferenceType()) { |
| 104 | ArgType = Ref->getPointeeType(); |
| 105 | // Is it a non-const reference? |
| 106 | if (!ArgType.isConstQualified()) |
| 107 | AcceptsConst = false; |
| 108 | } |
| 109 | if (Context.getCanonicalType(ArgType).getUnqualifiedType() != ClassType) |
| 110 | continue; |
| 111 | |
| 112 | // We have a single argument of type cv X or cv X&, i.e. we've found the |
| 113 | // copy assignment operator. Return whether it accepts const arguments. |
| 114 | return AcceptsConst; |
| 115 | } |
| 116 | assert(isInvalidDecl() && |
| 117 | "No copy assignment operator declared in valid code."); |
| 118 | return false; |
| 119 | } |
| 120 | |
| 121 | void |
Douglas Gregor | 9e7d9de | 2008-12-15 21:24:18 +0000 | [diff] [blame] | 122 | CXXRecordDecl::addedConstructor(ASTContext &Context, |
| 123 | CXXConstructorDecl *ConDecl) { |
Douglas Gregor | 6b3945f | 2009-01-07 19:46:03 +0000 | [diff] [blame] | 124 | if (!ConDecl->isImplicit()) { |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 125 | // Note that we have a user-declared constructor. |
| 126 | UserDeclaredConstructor = true; |
| 127 | |
Douglas Gregor | 64bffa9 | 2008-11-05 16:20:31 +0000 | [diff] [blame] | 128 | // C++ [dcl.init.aggr]p1: |
| 129 | // An aggregate is an array or a class (clause 9) with no |
| 130 | // user-declared constructors (12.1) [...]. |
| 131 | Aggregate = false; |
| 132 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 133 | // C++ [class]p4: |
| 134 | // A POD-struct is an aggregate class [...] |
| 135 | PlainOldData = false; |
| 136 | |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 137 | // Note when we have a user-declared copy constructor, which will |
| 138 | // suppress the implicit declaration of a copy constructor. |
| 139 | if (ConDecl->isCopyConstructor(Context)) |
| 140 | UserDeclaredCopyConstructor = true; |
| 141 | } |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 144 | void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context, |
| 145 | CXXMethodDecl *OpDecl) { |
| 146 | // We're interested specifically in copy assignment operators. |
| 147 | // Unlike addedConstructor, this method is not called for implicit |
| 148 | // declarations. |
| 149 | const FunctionTypeProto *FnType = OpDecl->getType()->getAsFunctionTypeProto(); |
| 150 | assert(FnType && "Overloaded operator has no proto function type."); |
| 151 | assert(FnType->getNumArgs() == 1 && !FnType->isVariadic()); |
| 152 | QualType ArgType = FnType->getArgType(0); |
| 153 | if (const ReferenceType *Ref = ArgType->getAsReferenceType()) |
| 154 | ArgType = Ref->getPointeeType(); |
| 155 | |
| 156 | ArgType = ArgType.getUnqualifiedType(); |
| 157 | QualType ClassType = Context.getCanonicalType(Context.getTypeDeclType( |
| 158 | const_cast<CXXRecordDecl*>(this))); |
| 159 | |
| 160 | if (ClassType != Context.getCanonicalType(ArgType)) |
| 161 | return; |
| 162 | |
| 163 | // This is a copy assignment operator. |
| 164 | // Suppress the implicit declaration of a copy constructor. |
| 165 | UserDeclaredCopyAssignment = true; |
| 166 | |
| 167 | // C++ [class]p4: |
| 168 | // A POD-struct is an aggregate class that [...] has no user-defined copy |
| 169 | // assignment operator [...]. |
| 170 | PlainOldData = false; |
| 171 | } |
| 172 | |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 173 | void CXXRecordDecl::addConversionFunction(ASTContext &Context, |
| 174 | CXXConversionDecl *ConvDecl) { |
| 175 | Conversions.addOverload(ConvDecl); |
| 176 | } |
| 177 | |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 178 | CXXMethodDecl * |
| 179 | CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
Douglas Gregor | 10bd368 | 2008-11-17 22:58:34 +0000 | [diff] [blame] | 180 | SourceLocation L, DeclarationName N, |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 181 | QualType T, bool isStatic, bool isInline) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 182 | return new (C) CXXMethodDecl(CXXMethod, RD, L, N, T, isStatic, isInline); |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | QualType CXXMethodDecl::getThisType(ASTContext &C) const { |
Argyrios Kyrtzidis | b0d178d | 2008-10-24 22:28:18 +0000 | [diff] [blame] | 186 | // C++ 9.3.2p1: The type of this in a member function of a class X is X*. |
| 187 | // If the member function is declared const, the type of this is const X*, |
| 188 | // if the member function is declared volatile, the type of this is |
| 189 | // volatile X*, and if the member function is declared const volatile, |
| 190 | // the type of this is const volatile X*. |
| 191 | |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 192 | assert(isInstance() && "No 'this' for static methods!"); |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 193 | QualType ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(getParent())); |
Argyrios Kyrtzidis | 971c4fa | 2008-10-24 21:46:40 +0000 | [diff] [blame] | 194 | ClassTy = ClassTy.getWithAdditionalQualifiers(getTypeQualifiers()); |
| 195 | return C.getPointerType(ClassTy).withConst(); |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 198 | CXXBaseOrMemberInitializer:: |
| 199 | CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs) |
| 200 | : Args(0), NumArgs(0) { |
| 201 | BaseOrMember = reinterpret_cast<uintptr_t>(BaseType.getTypePtr()); |
| 202 | assert((BaseOrMember & 0x01) == 0 && "Invalid base class type pointer"); |
| 203 | BaseOrMember |= 0x01; |
| 204 | |
| 205 | if (NumArgs > 0) { |
| 206 | this->NumArgs = NumArgs; |
| 207 | this->Args = new Expr*[NumArgs]; |
| 208 | for (unsigned Idx = 0; Idx < NumArgs; ++Idx) |
| 209 | this->Args[Idx] = Args[Idx]; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | CXXBaseOrMemberInitializer:: |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 214 | CXXBaseOrMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs) |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 215 | : Args(0), NumArgs(0) { |
| 216 | BaseOrMember = reinterpret_cast<uintptr_t>(Member); |
| 217 | assert((BaseOrMember & 0x01) == 0 && "Invalid member pointer"); |
| 218 | |
| 219 | if (NumArgs > 0) { |
| 220 | this->NumArgs = NumArgs; |
| 221 | this->Args = new Expr*[NumArgs]; |
| 222 | for (unsigned Idx = 0; Idx < NumArgs; ++Idx) |
| 223 | this->Args[Idx] = Args[Idx]; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | CXXBaseOrMemberInitializer::~CXXBaseOrMemberInitializer() { |
| 228 | delete [] Args; |
| 229 | } |
| 230 | |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 231 | CXXConstructorDecl * |
| 232 | CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 233 | SourceLocation L, DeclarationName N, |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 234 | QualType T, bool isExplicit, |
| 235 | bool isInline, bool isImplicitlyDeclared) { |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 236 | assert(N.getNameKind() == DeclarationName::CXXConstructorName && |
| 237 | "Name must refer to a constructor"); |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 238 | return new (C) CXXConstructorDecl(RD, L, N, T, isExplicit, isInline, |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 239 | isImplicitlyDeclared); |
| 240 | } |
| 241 | |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 242 | bool CXXConstructorDecl::isDefaultConstructor() const { |
| 243 | // C++ [class.ctor]p5: |
Douglas Gregor | 64bffa9 | 2008-11-05 16:20:31 +0000 | [diff] [blame] | 244 | // A default constructor for a class X is a constructor of class |
| 245 | // X that can be called without an argument. |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 246 | return (getNumParams() == 0) || |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 247 | (getNumParams() > 0 && getParamDecl(0)->getDefaultArg() != 0); |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | bool |
| 251 | CXXConstructorDecl::isCopyConstructor(ASTContext &Context, |
| 252 | unsigned &TypeQuals) const { |
| 253 | // C++ [class.copy]p2: |
Douglas Gregor | 64bffa9 | 2008-11-05 16:20:31 +0000 | [diff] [blame] | 254 | // A non-template constructor for class X is a copy constructor |
| 255 | // if its first parameter is of type X&, const X&, volatile X& or |
| 256 | // const volatile X&, and either there are no other parameters |
| 257 | // or else all other parameters have default arguments (8.3.6). |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 258 | if ((getNumParams() < 1) || |
| 259 | (getNumParams() > 1 && getParamDecl(1)->getDefaultArg() == 0)) |
| 260 | return false; |
| 261 | |
| 262 | const ParmVarDecl *Param = getParamDecl(0); |
| 263 | |
| 264 | // Do we have a reference type? |
| 265 | const ReferenceType *ParamRefType = Param->getType()->getAsReferenceType(); |
| 266 | if (!ParamRefType) |
| 267 | return false; |
| 268 | |
| 269 | // Is it a reference to our class type? |
| 270 | QualType PointeeType |
| 271 | = Context.getCanonicalType(ParamRefType->getPointeeType()); |
| 272 | QualType ClassTy |
| 273 | = Context.getTagDeclType(const_cast<CXXRecordDecl*>(getParent())); |
| 274 | if (PointeeType.getUnqualifiedType() != ClassTy) |
| 275 | return false; |
| 276 | |
| 277 | // We have a copy constructor. |
| 278 | TypeQuals = PointeeType.getCVRQualifiers(); |
| 279 | return true; |
| 280 | } |
| 281 | |
Douglas Gregor | 60d62c2 | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 282 | bool CXXConstructorDecl::isConvertingConstructor() const { |
| 283 | // C++ [class.conv.ctor]p1: |
| 284 | // A constructor declared without the function-specifier explicit |
| 285 | // that can be called with a single parameter specifies a |
| 286 | // conversion from the type of its first parameter to the type of |
| 287 | // its class. Such a constructor is called a converting |
| 288 | // constructor. |
| 289 | if (isExplicit()) |
| 290 | return false; |
| 291 | |
| 292 | return (getNumParams() == 0 && |
| 293 | getType()->getAsFunctionTypeProto()->isVariadic()) || |
| 294 | (getNumParams() == 1) || |
| 295 | (getNumParams() > 1 && getParamDecl(1)->getDefaultArg() != 0); |
| 296 | } |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 297 | |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 298 | CXXDestructorDecl * |
| 299 | CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 300 | SourceLocation L, DeclarationName N, |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 301 | QualType T, bool isInline, |
| 302 | bool isImplicitlyDeclared) { |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 303 | assert(N.getNameKind() == DeclarationName::CXXDestructorName && |
| 304 | "Name must refer to a destructor"); |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 305 | return new (C) CXXDestructorDecl(RD, L, N, T, isInline, |
| 306 | isImplicitlyDeclared); |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 307 | } |
| 308 | |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 309 | CXXConversionDecl * |
| 310 | CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 311 | SourceLocation L, DeclarationName N, |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 312 | QualType T, bool isInline, bool isExplicit) { |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 313 | assert(N.getNameKind() == DeclarationName::CXXConversionFunctionName && |
| 314 | "Name must refer to a conversion function"); |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 315 | return new (C) CXXConversionDecl(RD, L, N, T, isInline, isExplicit); |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 316 | } |
| 317 | |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 318 | CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
| 319 | SourceLocation L, IdentifierInfo *Id, |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 320 | QualType T) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 321 | return new (C) CXXClassVarDecl(RD, L, Id, T); |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 322 | } |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 323 | |
| 324 | OverloadedFunctionDecl * |
| 325 | OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC, |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 326 | DeclarationName N) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 327 | return new (C) OverloadedFunctionDecl(DC, N); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 328 | } |
Chris Lattner | 21ef7ae | 2008-11-04 16:51:42 +0000 | [diff] [blame] | 329 | |
| 330 | LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 331 | DeclContext *DC, |
Chris Lattner | 21ef7ae | 2008-11-04 16:51:42 +0000 | [diff] [blame] | 332 | SourceLocation L, |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 333 | LanguageIDs Lang, bool Braces) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame] | 334 | return new (C) LinkageSpecDecl(DC, L, Lang, Braces); |
Douglas Gregor | f44515a | 2008-12-16 22:23:02 +0000 | [diff] [blame] | 335 | } |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 336 | |
| 337 | UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC, |
| 338 | SourceLocation L, |
| 339 | SourceLocation NamespaceLoc, |
| 340 | SourceLocation IdentLoc, |
| 341 | NamespaceDecl *Used, |
| 342 | DeclContext *CommonAncestor) { |
| 343 | return new (C) UsingDirectiveDecl(DC, L, NamespaceLoc, IdentLoc, |
| 344 | Used, CommonAncestor); |
| 345 | } |
| 346 | |