1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | #include "clang/AST/DeclCXX.h" |
14 | #include "clang/AST/ASTContext.h" |
15 | #include "clang/AST/ASTLambda.h" |
16 | #include "clang/AST/ASTMutationListener.h" |
17 | #include "clang/AST/ASTUnresolvedSet.h" |
18 | #include "clang/AST/CXXInheritance.h" |
19 | #include "clang/AST/DeclBase.h" |
20 | #include "clang/AST/DeclTemplate.h" |
21 | #include "clang/AST/DeclarationName.h" |
22 | #include "clang/AST/Expr.h" |
23 | #include "clang/AST/ExprCXX.h" |
24 | #include "clang/AST/LambdaCapture.h" |
25 | #include "clang/AST/NestedNameSpecifier.h" |
26 | #include "clang/AST/ODRHash.h" |
27 | #include "clang/AST/Type.h" |
28 | #include "clang/AST/TypeLoc.h" |
29 | #include "clang/AST/UnresolvedSet.h" |
30 | #include "clang/Basic/Diagnostic.h" |
31 | #include "clang/Basic/IdentifierTable.h" |
32 | #include "clang/Basic/LLVM.h" |
33 | #include "clang/Basic/LangOptions.h" |
34 | #include "clang/Basic/OperatorKinds.h" |
35 | #include "clang/Basic/PartialDiagnostic.h" |
36 | #include "clang/Basic/SourceLocation.h" |
37 | #include "clang/Basic/Specifiers.h" |
38 | #include "llvm/ADT/None.h" |
39 | #include "llvm/ADT/SmallPtrSet.h" |
40 | #include "llvm/ADT/SmallVector.h" |
41 | #include "llvm/ADT/iterator_range.h" |
42 | #include "llvm/Support/Casting.h" |
43 | #include "llvm/Support/ErrorHandling.h" |
44 | #include "llvm/Support/raw_ostream.h" |
45 | #include <algorithm> |
46 | #include <cassert> |
47 | #include <cstddef> |
48 | #include <cstdint> |
49 | |
50 | using namespace clang; |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | void AccessSpecDecl::anchor() {} |
57 | |
58 | AccessSpecDecl *AccessSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
59 | return new (C, ID) AccessSpecDecl(EmptyShell()); |
60 | } |
61 | |
62 | void LazyASTUnresolvedSet::getFromExternalSource(ASTContext &C) const { |
63 | ExternalASTSource *Source = C.getExternalSource(); |
64 | (0) . __assert_fail ("Impl.Decls.isLazy() && \"getFromExternalSource for non-lazy set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 64, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Impl.Decls.isLazy() && "getFromExternalSource for non-lazy set"); |
65 | (0) . __assert_fail ("Source && \"getFromExternalSource with no external source\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 65, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Source && "getFromExternalSource with no external source"); |
66 | |
67 | for (ASTUnresolvedSet::iterator I = Impl.begin(); I != Impl.end(); ++I) |
68 | I.setDecl(cast<NamedDecl>(Source->GetExternalDecl( |
69 | reinterpret_cast<uintptr_t>(I.getDecl()) >> 2))); |
70 | Impl.Decls.setLazy(false); |
71 | } |
72 | |
73 | CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D) |
74 | : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0), |
75 | Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false), |
76 | Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true), |
77 | HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false), |
78 | HasPrivateFields(false), HasProtectedFields(false), |
79 | HasPublicFields(false), HasMutableFields(false), HasVariantMembers(false), |
80 | HasOnlyCMembers(true), HasInClassInitializer(false), |
81 | HasUninitializedReferenceMember(false), HasUninitializedFields(false), |
82 | HasInheritedConstructor(false), HasInheritedAssignment(false), |
83 | NeedOverloadResolutionForCopyConstructor(false), |
84 | NeedOverloadResolutionForMoveConstructor(false), |
85 | NeedOverloadResolutionForMoveAssignment(false), |
86 | NeedOverloadResolutionForDestructor(false), |
87 | DefaultedCopyConstructorIsDeleted(false), |
88 | DefaultedMoveConstructorIsDeleted(false), |
89 | DefaultedMoveAssignmentIsDeleted(false), |
90 | DefaultedDestructorIsDeleted(false), HasTrivialSpecialMembers(SMF_All), |
91 | HasTrivialSpecialMembersForCall(SMF_All), |
92 | DeclaredNonTrivialSpecialMembers(0), |
93 | DeclaredNonTrivialSpecialMembersForCall(0), HasIrrelevantDestructor(true), |
94 | HasConstexprNonCopyMoveConstructor(false), |
95 | HasDefaultedDefaultConstructor(false), |
96 | DefaultedDefaultConstructorIsConstexpr(true), |
97 | HasConstexprDefaultConstructor(false), |
98 | HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false), |
99 | UserProvidedDefaultConstructor(false), DeclaredSpecialMembers(0), |
100 | ImplicitCopyConstructorCanHaveConstParamForVBase(true), |
101 | ImplicitCopyConstructorCanHaveConstParamForNonVBase(true), |
102 | ImplicitCopyAssignmentHasConstParam(true), |
103 | HasDeclaredCopyConstructorWithConstParam(false), |
104 | HasDeclaredCopyAssignmentWithConstParam(false), IsLambda(false), |
105 | IsParsingBaseSpecifiers(false), HasODRHash(false), Definition(D) {} |
106 | |
107 | CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const { |
108 | return Bases.get(Definition->getASTContext().getExternalSource()); |
109 | } |
110 | |
111 | CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getVBasesSlowCase() const { |
112 | return VBases.get(Definition->getASTContext().getExternalSource()); |
113 | } |
114 | |
115 | CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, |
116 | DeclContext *DC, SourceLocation StartLoc, |
117 | SourceLocation IdLoc, IdentifierInfo *Id, |
118 | CXXRecordDecl *PrevDecl) |
119 | : RecordDecl(K, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl), |
120 | DefinitionData(PrevDecl ? PrevDecl->DefinitionData |
121 | : nullptr) {} |
122 | |
123 | CXXRecordDecl *CXXRecordDecl::Create(const ASTContext &C, TagKind TK, |
124 | DeclContext *DC, SourceLocation StartLoc, |
125 | SourceLocation IdLoc, IdentifierInfo *Id, |
126 | CXXRecordDecl *PrevDecl, |
127 | bool DelayTypeCreation) { |
128 | auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TK, C, DC, StartLoc, IdLoc, Id, |
129 | PrevDecl); |
130 | R->setMayHaveOutOfDateDef(C.getLangOpts().Modules); |
131 | |
132 | |
133 | if (!DelayTypeCreation) |
134 | C.getTypeDeclType(R, PrevDecl); |
135 | return R; |
136 | } |
137 | |
138 | CXXRecordDecl * |
139 | CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC, |
140 | TypeSourceInfo *Info, SourceLocation Loc, |
141 | bool Dependent, bool IsGeneric, |
142 | LambdaCaptureDefault CaptureDefault) { |
143 | auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, C, DC, Loc, Loc, |
144 | nullptr, nullptr); |
145 | R->setBeingDefined(true); |
146 | R->DefinitionData = |
147 | new (C) struct LambdaDefinitionData(R, Info, Dependent, IsGeneric, |
148 | CaptureDefault); |
149 | R->setMayHaveOutOfDateDef(false); |
150 | R->setImplicit(true); |
151 | C.getTypeDeclType(R, ); |
152 | return R; |
153 | } |
154 | |
155 | CXXRecordDecl * |
156 | CXXRecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { |
157 | auto *R = new (C, ID) CXXRecordDecl( |
158 | CXXRecord, TTK_Struct, C, nullptr, SourceLocation(), SourceLocation(), |
159 | nullptr, nullptr); |
160 | R->setMayHaveOutOfDateDef(false); |
161 | return R; |
162 | } |
163 | |
164 | |
165 | |
166 | |
167 | static bool hasRepeatedBaseClass(const CXXRecordDecl *StartRD) { |
168 | llvm::SmallPtrSet<const CXXRecordDecl*, 8> SeenBaseTypes; |
169 | SmallVector<const CXXRecordDecl*, 8> WorkList = {StartRD}; |
170 | while (!WorkList.empty()) { |
171 | const CXXRecordDecl *RD = WorkList.pop_back_val(); |
172 | for (const CXXBaseSpecifier &BaseSpec : RD->bases()) { |
173 | if (const CXXRecordDecl *B = BaseSpec.getType()->getAsCXXRecordDecl()) { |
174 | if (!SeenBaseTypes.insert(B).second) |
175 | return true; |
176 | WorkList.push_back(B); |
177 | } |
178 | } |
179 | } |
180 | return false; |
181 | } |
182 | |
183 | void |
184 | CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, |
185 | unsigned NumBases) { |
186 | ASTContext &C = getASTContext(); |
187 | |
188 | if (!data().Bases.isOffset() && data().NumBases > 0) |
189 | C.Deallocate(data().getBases()); |
190 | |
191 | if (NumBases) { |
192 | if (!C.getLangOpts().CPlusPlus17) { |
193 | |
194 | |
195 | data().Aggregate = false; |
196 | } |
197 | |
198 | |
199 | |
200 | data().PlainOldData = false; |
201 | } |
202 | |
203 | |
204 | llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes; |
205 | |
206 | |
207 | SmallVector<const CXXBaseSpecifier *, 8> VBases; |
208 | |
209 | data().Bases = new(C) CXXBaseSpecifier [NumBases]; |
210 | data().NumBases = NumBases; |
211 | for (unsigned i = 0; i < NumBases; ++i) { |
212 | data().getBases()[i] = *Bases[i]; |
213 | |
214 | const CXXBaseSpecifier *Base = Bases[i]; |
215 | QualType BaseType = Base->getType(); |
216 | |
217 | if (BaseType->isDependentType()) |
218 | continue; |
219 | auto *BaseClassDecl = |
220 | cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl()); |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | if (BaseClassDecl->data().HasBasesWithFields || |
228 | !BaseClassDecl->field_empty()) { |
229 | if (data().HasBasesWithFields) |
230 | |
231 | data().IsStandardLayout = false; |
232 | data().HasBasesWithFields = true; |
233 | } |
234 | |
235 | |
236 | |
237 | |
238 | |
239 | if (BaseClassDecl->data().HasBasesWithNonStaticDataMembers || |
240 | BaseClassDecl->hasDirectFields()) { |
241 | if (data().HasBasesWithNonStaticDataMembers) |
242 | data().IsCXX11StandardLayout = false; |
243 | data().HasBasesWithNonStaticDataMembers = true; |
244 | } |
245 | |
246 | if (!BaseClassDecl->isEmpty()) { |
247 | |
248 | |
249 | |
250 | data().Empty = false; |
251 | } |
252 | |
253 | |
254 | |
255 | if (Base->getAccessSpecifier() != AS_public) |
256 | data().Aggregate = false; |
257 | |
258 | |
259 | |
260 | |
261 | if (BaseClassDecl->isPolymorphic()) { |
262 | data().Polymorphic = true; |
263 | |
264 | |
265 | data().Aggregate = false; |
266 | } |
267 | |
268 | |
269 | |
270 | |
271 | if (!BaseClassDecl->isStandardLayout()) |
272 | data().IsStandardLayout = false; |
273 | if (!BaseClassDecl->isCXX11StandardLayout()) |
274 | data().IsCXX11StandardLayout = false; |
275 | |
276 | |
277 | if (!hasNonLiteralTypeFieldsOrBases() && !BaseType->isLiteralType(C)) |
278 | data().HasNonLiteralTypeFieldsOrBases = true; |
279 | |
280 | |
281 | for (const auto &VBase : BaseClassDecl->vbases()) { |
282 | |
283 | if (SeenVBaseTypes.insert(C.getCanonicalType(VBase.getType())).second) { |
284 | VBases.push_back(&VBase); |
285 | |
286 | |
287 | |
288 | |
289 | |
290 | |
291 | if (CXXRecordDecl *VBaseDecl = VBase.getType()->getAsCXXRecordDecl()) |
292 | if (!VBaseDecl->hasCopyConstructorWithConstParam()) |
293 | data().ImplicitCopyConstructorCanHaveConstParamForVBase = false; |
294 | |
295 | |
296 | |
297 | data().Aggregate = false; |
298 | } |
299 | } |
300 | |
301 | if (Base->isVirtual()) { |
302 | |
303 | if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second) |
304 | VBases.push_back(Base); |
305 | |
306 | |
307 | |
308 | |
309 | data().Empty = false; |
310 | |
311 | |
312 | |
313 | data().Aggregate = false; |
314 | |
315 | |
316 | |
317 | |
318 | |
319 | data().HasTrivialSpecialMembers &= SMF_Destructor; |
320 | data().HasTrivialSpecialMembersForCall &= SMF_Destructor; |
321 | |
322 | |
323 | |
324 | |
325 | data().IsStandardLayout = false; |
326 | data().IsCXX11StandardLayout = false; |
327 | |
328 | |
329 | |
330 | |
331 | data().DefaultedDefaultConstructorIsConstexpr = false; |
332 | |
333 | |
334 | |
335 | |
336 | |
337 | |
338 | if (!BaseClassDecl->hasCopyConstructorWithConstParam()) |
339 | data().ImplicitCopyConstructorCanHaveConstParamForVBase = false; |
340 | } else { |
341 | |
342 | |
343 | |
344 | |
345 | if (!BaseClassDecl->hasTrivialDefaultConstructor()) |
346 | data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor; |
347 | |
348 | |
349 | |
350 | |
351 | |
352 | |
353 | if (!BaseClassDecl->hasTrivialCopyConstructor()) |
354 | data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor; |
355 | |
356 | if (!BaseClassDecl->hasTrivialCopyConstructorForCall()) |
357 | data().HasTrivialSpecialMembersForCall &= ~SMF_CopyConstructor; |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | if (!BaseClassDecl->hasTrivialMoveConstructor()) |
364 | data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor; |
365 | |
366 | if (!BaseClassDecl->hasTrivialMoveConstructorForCall()) |
367 | data().HasTrivialSpecialMembersForCall &= ~SMF_MoveConstructor; |
368 | |
369 | |
370 | |
371 | |
372 | |
373 | |
374 | if (!BaseClassDecl->hasTrivialCopyAssignment()) |
375 | data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment; |
376 | |
377 | |
378 | |
379 | |
380 | if (!BaseClassDecl->hasTrivialMoveAssignment()) |
381 | data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment; |
382 | |
383 | |
384 | |
385 | |
386 | |
387 | if (!BaseClassDecl->hasConstexprDefaultConstructor()) |
388 | data().DefaultedDefaultConstructorIsConstexpr = false; |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | |
395 | if (!BaseClassDecl->hasCopyConstructorWithConstParam()) |
396 | data().ImplicitCopyConstructorCanHaveConstParamForNonVBase = false; |
397 | } |
398 | |
399 | |
400 | |
401 | |
402 | if (!BaseClassDecl->hasTrivialDestructor()) |
403 | data().HasTrivialSpecialMembers &= ~SMF_Destructor; |
404 | |
405 | if (!BaseClassDecl->hasTrivialDestructorForCall()) |
406 | data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor; |
407 | |
408 | if (!BaseClassDecl->hasIrrelevantDestructor()) |
409 | data().HasIrrelevantDestructor = false; |
410 | |
411 | |
412 | |
413 | |
414 | |
415 | |
416 | if (!BaseClassDecl->hasCopyAssignmentWithConstParam()) |
417 | data().ImplicitCopyAssignmentHasConstParam = false; |
418 | |
419 | |
420 | |
421 | if (BaseClassDecl->hasObjectMember()) |
422 | setHasObjectMember(true); |
423 | |
424 | if (BaseClassDecl->hasVolatileMember()) |
425 | setHasVolatileMember(true); |
426 | |
427 | if (BaseClassDecl->getArgPassingRestrictions() == |
428 | RecordDecl::APK_CanNeverPassInRegs) |
429 | setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs); |
430 | |
431 | |
432 | if (BaseClassDecl->hasMutableFields()) { |
433 | data().HasMutableFields = true; |
434 | data().NeedOverloadResolutionForCopyConstructor = true; |
435 | } |
436 | |
437 | if (BaseClassDecl->hasUninitializedReferenceMember()) |
438 | data().HasUninitializedReferenceMember = true; |
439 | |
440 | if (!BaseClassDecl->allowConstDefaultInit()) |
441 | data().HasUninitializedFields = true; |
442 | |
443 | addedClassSubobject(BaseClassDecl); |
444 | } |
445 | |
446 | |
447 | |
448 | |
449 | |
450 | |
451 | |
452 | |
453 | if (data().IsStandardLayout && NumBases > 1 && hasRepeatedBaseClass(this)) |
454 | data().IsStandardLayout = false; |
455 | |
456 | if (VBases.empty()) { |
457 | data().IsParsingBaseSpecifiers = false; |
458 | return; |
459 | } |
460 | |
461 | |
462 | data().VBases = new (C) CXXBaseSpecifier[VBases.size()]; |
463 | data().NumVBases = VBases.size(); |
464 | for (int I = 0, E = VBases.size(); I != E; ++I) { |
465 | QualType Type = VBases[I]->getType(); |
466 | if (!Type->isDependentType()) |
467 | addedClassSubobject(Type->getAsCXXRecordDecl()); |
468 | data().getVBases()[I] = *VBases[I]; |
469 | } |
470 | |
471 | data().IsParsingBaseSpecifiers = false; |
472 | } |
473 | |
474 | unsigned CXXRecordDecl::getODRHash() const { |
475 | (0) . __assert_fail ("hasDefinition() && \"ODRHash only for records with definitions\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 475, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(hasDefinition() && "ODRHash only for records with definitions"); |
476 | |
477 | |
478 | if (DefinitionData->HasODRHash) |
479 | return DefinitionData->ODRHash; |
480 | |
481 | |
482 | ODRHash Hash; |
483 | Hash.AddCXXRecordDecl(getDefinition()); |
484 | DefinitionData->HasODRHash = true; |
485 | DefinitionData->ODRHash = Hash.CalculateHash(); |
486 | |
487 | return DefinitionData->ODRHash; |
488 | } |
489 | |
490 | void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) { |
491 | |
492 | |
493 | |
494 | |
495 | |
496 | |
497 | if (!Subobj->hasSimpleCopyConstructor()) |
498 | data().NeedOverloadResolutionForCopyConstructor = true; |
499 | if (!Subobj->hasSimpleMoveConstructor()) |
500 | data().NeedOverloadResolutionForMoveConstructor = true; |
501 | |
502 | |
503 | |
504 | |
505 | |
506 | |
507 | |
508 | if (!Subobj->hasSimpleMoveAssignment()) |
509 | data().NeedOverloadResolutionForMoveAssignment = true; |
510 | |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | |
518 | if (!Subobj->hasSimpleDestructor()) { |
519 | data().NeedOverloadResolutionForCopyConstructor = true; |
520 | data().NeedOverloadResolutionForMoveConstructor = true; |
521 | data().NeedOverloadResolutionForDestructor = true; |
522 | } |
523 | } |
524 | |
525 | bool CXXRecordDecl::hasAnyDependentBases() const { |
526 | if (!isDependentContext()) |
527 | return false; |
528 | |
529 | return !forallBases([](const CXXRecordDecl *) { return true; }); |
530 | } |
531 | |
532 | bool CXXRecordDecl::isTriviallyCopyable() const { |
533 | |
534 | |
535 | |
536 | if (hasNonTrivialCopyConstructor()) return false; |
537 | |
538 | if (hasNonTrivialMoveConstructor()) return false; |
539 | |
540 | if (hasNonTrivialCopyAssignment()) return false; |
541 | |
542 | if (hasNonTrivialMoveAssignment()) return false; |
543 | |
544 | if (!hasTrivialDestructor()) return false; |
545 | |
546 | return true; |
547 | } |
548 | |
549 | void CXXRecordDecl::markedVirtualFunctionPure() { |
550 | |
551 | |
552 | data().Abstract = true; |
553 | } |
554 | |
555 | bool CXXRecordDecl::hasSubobjectAtOffsetZeroOfEmptyBaseType( |
556 | ASTContext &Ctx, const CXXRecordDecl *XFirst) { |
557 | if (!getNumBases()) |
558 | return false; |
559 | |
560 | llvm::SmallPtrSet<const CXXRecordDecl*, 8> Bases; |
561 | llvm::SmallPtrSet<const CXXRecordDecl*, 8> M; |
562 | SmallVector<const CXXRecordDecl*, 8> WorkList; |
563 | |
564 | |
565 | auto Visit = [&](const CXXRecordDecl *RD) -> bool { |
566 | RD = RD->getCanonicalDecl(); |
567 | |
568 | |
569 | |
570 | |
571 | |
572 | |
573 | |
574 | if (!RD->data().HasBasesWithFields) { |
575 | |
576 | |
577 | if (Bases.empty()) { |
578 | bool RDIsBase = !forallBases([&](const CXXRecordDecl *Base) -> bool { |
579 | Base = Base->getCanonicalDecl(); |
580 | if (RD == Base) |
581 | return false; |
582 | Bases.insert(Base); |
583 | return true; |
584 | }); |
585 | if (RDIsBase) |
586 | return true; |
587 | } else { |
588 | if (Bases.count(RD)) |
589 | return true; |
590 | } |
591 | } |
592 | |
593 | if (M.insert(RD).second) |
594 | WorkList.push_back(RD); |
595 | return false; |
596 | }; |
597 | |
598 | if (Visit(XFirst)) |
599 | return true; |
600 | |
601 | while (!WorkList.empty()) { |
602 | const CXXRecordDecl *X = WorkList.pop_back_val(); |
603 | |
604 | |
605 | |
606 | |
607 | |
608 | |
609 | |
610 | for (auto *FD : X->fields()) { |
611 | |
612 | |
613 | if (FD->isUnnamedBitfield()) |
614 | continue; |
615 | |
616 | |
617 | QualType T = Ctx.getBaseElementType(FD->getType()); |
618 | if (auto *RD = T->getAsCXXRecordDecl()) |
619 | if (Visit(RD)) |
620 | return true; |
621 | |
622 | if (!X->isUnion()) |
623 | break; |
624 | } |
625 | } |
626 | |
627 | return false; |
628 | } |
629 | |
630 | bool CXXRecordDecl::lambdaIsDefaultConstructibleAndAssignable() const { |
631 | (0) . __assert_fail ("isLambda() && \"not a lambda\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 631, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isLambda() && "not a lambda"); |
632 | |
633 | |
634 | |
635 | |
636 | |
637 | |
638 | |
639 | |
640 | |
641 | |
642 | |
643 | if (getLambdaCaptureDefault() != LCD_None) |
644 | return false; |
645 | return getASTContext().getLangOpts().CPlusPlus2a; |
646 | } |
647 | |
648 | void CXXRecordDecl::addedMember(Decl *D) { |
649 | if (!D->isImplicit() && |
650 | !isa<FieldDecl>(D) && |
651 | !isa<IndirectFieldDecl>(D) && |
652 | (!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() == TTK_Class || |
653 | cast<TagDecl>(D)->getTagKind() == TTK_Interface)) |
654 | data().HasOnlyCMembers = false; |
655 | |
656 | |
657 | if (D->getFriendObjectKind() || D->isInvalidDecl()) |
658 | return; |
659 | |
660 | auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(D); |
661 | if (FunTmpl) |
662 | D = FunTmpl->getTemplatedDecl(); |
663 | |
664 | |
665 | Decl *DUnderlying = D; |
666 | if (auto *ND = dyn_cast<NamedDecl>(DUnderlying)) { |
667 | DUnderlying = ND->getUnderlyingDecl(); |
668 | if (auto *UnderlyingFunTmpl = dyn_cast<FunctionTemplateDecl>(DUnderlying)) |
669 | DUnderlying = UnderlyingFunTmpl->getTemplatedDecl(); |
670 | } |
671 | |
672 | if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) { |
673 | if (Method->isVirtual()) { |
674 | |
675 | |
676 | data().Aggregate = false; |
677 | |
678 | |
679 | |
680 | data().PlainOldData = false; |
681 | |
682 | |
683 | |
684 | data().Empty = false; |
685 | |
686 | |
687 | |
688 | |
689 | data().Polymorphic = true; |
690 | |
691 | |
692 | |
693 | |
694 | |
695 | data().HasTrivialSpecialMembers &= SMF_Destructor; |
696 | data().HasTrivialSpecialMembersForCall &= SMF_Destructor; |
697 | |
698 | |
699 | |
700 | |
701 | data().IsStandardLayout = false; |
702 | data().IsCXX11StandardLayout = false; |
703 | } |
704 | } |
705 | |
706 | |
707 | |
708 | if (!isBeingDefined() && D->isImplicit()) |
709 | if (ASTMutationListener *L = getASTMutationListener()) |
710 | L->AddedCXXImplicitMember(data().Definition, D); |
711 | |
712 | |
713 | unsigned SMKind = 0; |
714 | |
715 | |
716 | if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(D)) { |
717 | if (!Constructor->isImplicit()) { |
718 | |
719 | data().UserDeclaredConstructor = true; |
720 | |
721 | |
722 | |
723 | |
724 | |
725 | data().PlainOldData = false; |
726 | } |
727 | |
728 | if (Constructor->isDefaultConstructor()) { |
729 | SMKind |= SMF_DefaultConstructor; |
730 | |
731 | if (Constructor->isUserProvided()) |
732 | data().UserProvidedDefaultConstructor = true; |
733 | if (Constructor->isConstexpr()) |
734 | data().HasConstexprDefaultConstructor = true; |
735 | if (Constructor->isDefaulted()) |
736 | data().HasDefaultedDefaultConstructor = true; |
737 | } |
738 | |
739 | if (!FunTmpl) { |
740 | unsigned Quals; |
741 | if (Constructor->isCopyConstructor(Quals)) { |
742 | SMKind |= SMF_CopyConstructor; |
743 | |
744 | if (Quals & Qualifiers::Const) |
745 | data().HasDeclaredCopyConstructorWithConstParam = true; |
746 | } else if (Constructor->isMoveConstructor()) |
747 | SMKind |= SMF_MoveConstructor; |
748 | } |
749 | |
750 | |
751 | |
752 | |
753 | |
754 | |
755 | |
756 | if (getASTContext().getLangOpts().CPlusPlus2a |
757 | ? !Constructor->isImplicit() |
758 | : (Constructor->isUserProvided() || Constructor->isExplicit())) |
759 | data().Aggregate = false; |
760 | } |
761 | |
762 | |
763 | if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(DUnderlying)) { |
764 | |
765 | |
766 | |
767 | |
768 | |
769 | |
770 | if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor()) |
771 | data().HasConstexprNonCopyMoveConstructor = true; |
772 | } |
773 | |
774 | |
775 | if (const auto *DD = dyn_cast<CXXDestructorDecl>(D)) { |
776 | SMKind |= SMF_Destructor; |
777 | |
778 | if (DD->isUserProvided()) |
779 | data().HasIrrelevantDestructor = false; |
780 | |
781 | |
782 | |
783 | |
784 | |
785 | |
786 | if (DD->isVirtual()) { |
787 | data().HasTrivialSpecialMembers &= ~SMF_Destructor; |
788 | data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor; |
789 | } |
790 | } |
791 | |
792 | |
793 | if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) { |
794 | if (Method->isCopyAssignmentOperator()) { |
795 | SMKind |= SMF_CopyAssignment; |
796 | |
797 | const auto *ParamTy = |
798 | Method->getParamDecl(0)->getType()->getAs<ReferenceType>(); |
799 | if (!ParamTy || ParamTy->getPointeeType().isConstQualified()) |
800 | data().HasDeclaredCopyAssignmentWithConstParam = true; |
801 | } |
802 | |
803 | if (Method->isMoveAssignmentOperator()) |
804 | SMKind |= SMF_MoveAssignment; |
805 | |
806 | |
807 | if (auto *Conversion = dyn_cast<CXXConversionDecl>(D)) { |
808 | |
809 | |
810 | |
811 | |
812 | |
813 | |
814 | AccessSpecifier AS = Conversion->getAccessUnsafe(); |
815 | |
816 | if (Conversion->getPrimaryTemplate()) { |
817 | |
818 | } else { |
819 | ASTContext &Ctx = getASTContext(); |
820 | ASTUnresolvedSet &Conversions = data().Conversions.get(Ctx); |
821 | NamedDecl *Primary = |
822 | FunTmpl ? cast<NamedDecl>(FunTmpl) : cast<NamedDecl>(Conversion); |
823 | if (Primary->getPreviousDecl()) |
824 | Conversions.replace(cast<NamedDecl>(Primary->getPreviousDecl()), |
825 | Primary, AS); |
826 | else |
827 | Conversions.addDecl(Ctx, Primary, AS); |
828 | } |
829 | } |
830 | |
831 | if (SMKind) { |
832 | |
833 | |
834 | data().HasTrivialSpecialMembers &= |
835 | data().DeclaredSpecialMembers | ~SMKind; |
836 | data().HasTrivialSpecialMembersForCall &= |
837 | data().DeclaredSpecialMembers | ~SMKind; |
838 | |
839 | if (!Method->isImplicit() && !Method->isUserProvided()) { |
840 | |
841 | |
842 | |
843 | } else if (Method->isTrivial()) { |
844 | data().HasTrivialSpecialMembers |= SMKind; |
845 | data().HasTrivialSpecialMembersForCall |= SMKind; |
846 | } else if (Method->isTrivialForCall()) { |
847 | data().HasTrivialSpecialMembersForCall |= SMKind; |
848 | data().DeclaredNonTrivialSpecialMembers |= SMKind; |
849 | } else { |
850 | data().DeclaredNonTrivialSpecialMembers |= SMKind; |
851 | |
852 | |
853 | |
854 | |
855 | |
856 | if (!Method->isUserProvided()) |
857 | data().DeclaredNonTrivialSpecialMembersForCall |= SMKind; |
858 | } |
859 | |
860 | |
861 | |
862 | data().DeclaredSpecialMembers |= SMKind; |
863 | |
864 | if (!Method->isImplicit()) { |
865 | data().UserDeclaredSpecialMembers |= SMKind; |
866 | |
867 | |
868 | |
869 | |
870 | |
871 | |
872 | |
873 | |
874 | |
875 | |
876 | |
877 | |
878 | data().PlainOldData = false; |
879 | } |
880 | } |
881 | |
882 | return; |
883 | } |
884 | |
885 | |
886 | if (const auto *Field = dyn_cast<FieldDecl>(D)) { |
887 | ASTContext &Context = getASTContext(); |
888 | |
889 | |
890 | |
891 | |
892 | |
893 | |
894 | if (data().HasBasesWithFields) |
895 | data().IsStandardLayout = false; |
896 | |
897 | |
898 | |
899 | |
900 | |
901 | if (Field->isUnnamedBitfield()) { |
902 | |
903 | |
904 | |
905 | if (data().Empty && !Field->isZeroLengthBitField(Context) && |
906 | Context.getLangOpts().getClangABICompat() > |
907 | LangOptions::ClangABI::Ver6) |
908 | data().Empty = false; |
909 | return; |
910 | } |
911 | |
912 | |
913 | |
914 | |
915 | |
916 | if (data().HasBasesWithNonStaticDataMembers) |
917 | data().IsCXX11StandardLayout = false; |
918 | |
919 | |
920 | |
921 | |
922 | |
923 | |
924 | if (D->getAccess() == AS_private || D->getAccess() == AS_protected) { |
925 | data().Aggregate = false; |
926 | data().PlainOldData = false; |
927 | } |
928 | |
929 | |
930 | |
931 | bool IsFirstField = !data().HasPrivateFields && |
932 | !data().HasProtectedFields && !data().HasPublicFields; |
933 | |
934 | |
935 | |
936 | |
937 | |
938 | switch (D->getAccess()) { |
939 | case AS_private: data().HasPrivateFields = true; break; |
940 | case AS_protected: data().HasProtectedFields = true; break; |
941 | case AS_public: data().HasPublicFields = true; break; |
942 | case AS_none: llvm_unreachable("Invalid access specifier"); |
943 | }; |
944 | if ((data().HasPrivateFields + data().HasProtectedFields + |
945 | data().HasPublicFields) > 1) { |
946 | data().IsStandardLayout = false; |
947 | data().IsCXX11StandardLayout = false; |
948 | } |
949 | |
950 | |
951 | if (Field->isMutable()) { |
952 | data().HasMutableFields = true; |
953 | data().NeedOverloadResolutionForCopyConstructor = true; |
954 | } |
955 | |
956 | |
957 | |
958 | |
959 | if (isUnion() && !Field->isAnonymousStructOrUnion()) |
960 | data().HasVariantMembers = true; |
961 | |
962 | |
963 | |
964 | |
965 | |
966 | |
967 | |
968 | |
969 | QualType T = Context.getBaseElementType(Field->getType()); |
970 | if (T->isObjCRetainableType() || T.isObjCGCStrong()) { |
971 | if (T.hasNonTrivialObjCLifetime()) { |
972 | |
973 | |
974 | |
975 | |
976 | |
977 | |
978 | setHasObjectMember(true); |
979 | struct DefinitionData &Data = data(); |
980 | Data.PlainOldData = false; |
981 | Data.HasTrivialSpecialMembers = 0; |
982 | |
983 | |
984 | |
985 | Qualifiers::ObjCLifetime LT = T.getQualifiers().getObjCLifetime(); |
986 | if (LT != Qualifiers::OCL_Strong && LT != Qualifiers::OCL_Weak) |
987 | data().HasTrivialSpecialMembersForCall = 0; |
988 | |
989 | |
990 | if (LT == Qualifiers::OCL_Weak) |
991 | setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs); |
992 | |
993 | Data.HasIrrelevantDestructor = false; |
994 | |
995 | if (isUnion()) { |
996 | data().DefaultedCopyConstructorIsDeleted = true; |
997 | data().DefaultedMoveConstructorIsDeleted = true; |
998 | data().DefaultedMoveAssignmentIsDeleted = true; |
999 | data().DefaultedDestructorIsDeleted = true; |
1000 | data().NeedOverloadResolutionForCopyConstructor = true; |
1001 | data().NeedOverloadResolutionForMoveConstructor = true; |
1002 | data().NeedOverloadResolutionForMoveAssignment = true; |
1003 | data().NeedOverloadResolutionForDestructor = true; |
1004 | } |
1005 | } else if (!Context.getLangOpts().ObjCAutoRefCount) { |
1006 | setHasObjectMember(true); |
1007 | } |
1008 | } else if (!T.isCXX98PODType(Context)) |
1009 | data().PlainOldData = false; |
1010 | |
1011 | if (T->isReferenceType()) { |
1012 | if (!Field->hasInClassInitializer()) |
1013 | data().HasUninitializedReferenceMember = true; |
1014 | |
1015 | |
1016 | |
1017 | |
1018 | data().IsStandardLayout = false; |
1019 | data().IsCXX11StandardLayout = false; |
1020 | |
1021 | |
1022 | |
1023 | |
1024 | if (T->isRValueReferenceType()) |
1025 | data().DefaultedCopyConstructorIsDeleted = true; |
1026 | } |
1027 | |
1028 | if (!Field->hasInClassInitializer() && !Field->isMutable()) { |
1029 | if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) { |
1030 | if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit()) |
1031 | data().HasUninitializedFields = true; |
1032 | } else { |
1033 | data().HasUninitializedFields = true; |
1034 | } |
1035 | } |
1036 | |
1037 | |
1038 | if (!T->isLiteralType(Context) || T.isVolatileQualified()) |
1039 | data().HasNonLiteralTypeFieldsOrBases = true; |
1040 | |
1041 | if (Field->hasInClassInitializer() || |
1042 | (Field->isAnonymousStructOrUnion() && |
1043 | Field->getType()->getAsCXXRecordDecl()->hasInClassInitializer())) { |
1044 | data().HasInClassInitializer = true; |
1045 | |
1046 | |
1047 | |
1048 | |
1049 | data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor; |
1050 | |
1051 | |
1052 | |
1053 | |
1054 | |
1055 | |
1056 | if (!getASTContext().getLangOpts().CPlusPlus14) |
1057 | data().Aggregate = false; |
1058 | |
1059 | |
1060 | |
1061 | data().PlainOldData = false; |
1062 | } |
1063 | |
1064 | |
1065 | |
1066 | |
1067 | |
1068 | if (T->isReferenceType()) |
1069 | data().DefaultedMoveAssignmentIsDeleted = true; |
1070 | |
1071 | if (const auto *RecordTy = T->getAs<RecordType>()) { |
1072 | auto *FieldRec = cast<CXXRecordDecl>(RecordTy->getDecl()); |
1073 | if (FieldRec->getDefinition()) { |
1074 | addedClassSubobject(FieldRec); |
1075 | |
1076 | |
1077 | |
1078 | if (T.getCVRQualifiers() & (Qualifiers::Const | Qualifiers::Volatile)) { |
1079 | |
1080 | |
1081 | |
1082 | data().NeedOverloadResolutionForCopyConstructor = true; |
1083 | data().NeedOverloadResolutionForMoveConstructor = true; |
1084 | data().NeedOverloadResolutionForMoveAssignment = true; |
1085 | } |
1086 | |
1087 | |
1088 | |
1089 | |
1090 | |
1091 | |
1092 | if (isUnion()) { |
1093 | if (FieldRec->hasNonTrivialCopyConstructor()) |
1094 | data().DefaultedCopyConstructorIsDeleted = true; |
1095 | if (FieldRec->hasNonTrivialMoveConstructor()) |
1096 | data().DefaultedMoveConstructorIsDeleted = true; |
1097 | if (FieldRec->hasNonTrivialMoveAssignment()) |
1098 | data().DefaultedMoveAssignmentIsDeleted = true; |
1099 | if (FieldRec->hasNonTrivialDestructor()) |
1100 | data().DefaultedDestructorIsDeleted = true; |
1101 | } |
1102 | |
1103 | |
1104 | |
1105 | if (Field->isAnonymousStructOrUnion()) { |
1106 | data().NeedOverloadResolutionForCopyConstructor |= |
1107 | FieldRec->data().NeedOverloadResolutionForCopyConstructor; |
1108 | data().NeedOverloadResolutionForMoveConstructor |= |
1109 | FieldRec->data().NeedOverloadResolutionForMoveConstructor; |
1110 | data().NeedOverloadResolutionForMoveAssignment |= |
1111 | FieldRec->data().NeedOverloadResolutionForMoveAssignment; |
1112 | data().NeedOverloadResolutionForDestructor |= |
1113 | FieldRec->data().NeedOverloadResolutionForDestructor; |
1114 | } |
1115 | |
1116 | |
1117 | |
1118 | |
1119 | |
1120 | |
1121 | if (!FieldRec->hasTrivialDefaultConstructor()) |
1122 | data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor; |
1123 | |
1124 | |
1125 | |
1126 | |
1127 | |
1128 | |
1129 | |
1130 | if (!FieldRec->hasTrivialCopyConstructor()) |
1131 | data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor; |
1132 | |
1133 | if (!FieldRec->hasTrivialCopyConstructorForCall()) |
1134 | data().HasTrivialSpecialMembersForCall &= ~SMF_CopyConstructor; |
1135 | |
1136 | |
1137 | |
1138 | |
1139 | if (!FieldRec->hasTrivialMoveConstructor()) |
1140 | data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor; |
1141 | |
1142 | if (!FieldRec->hasTrivialMoveConstructorForCall()) |
1143 | data().HasTrivialSpecialMembersForCall &= ~SMF_MoveConstructor; |
1144 | |
1145 | |
1146 | |
1147 | |
1148 | |
1149 | |
1150 | |
1151 | if (!FieldRec->hasTrivialCopyAssignment()) |
1152 | data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment; |
1153 | |
1154 | |
1155 | |
1156 | if (!FieldRec->hasTrivialMoveAssignment()) |
1157 | data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment; |
1158 | |
1159 | if (!FieldRec->hasTrivialDestructor()) |
1160 | data().HasTrivialSpecialMembers &= ~SMF_Destructor; |
1161 | if (!FieldRec->hasTrivialDestructorForCall()) |
1162 | data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor; |
1163 | if (!FieldRec->hasIrrelevantDestructor()) |
1164 | data().HasIrrelevantDestructor = false; |
1165 | if (FieldRec->hasObjectMember()) |
1166 | setHasObjectMember(true); |
1167 | if (FieldRec->hasVolatileMember()) |
1168 | setHasVolatileMember(true); |
1169 | if (FieldRec->getArgPassingRestrictions() == |
1170 | RecordDecl::APK_CanNeverPassInRegs) |
1171 | setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs); |
1172 | |
1173 | |
1174 | |
1175 | |
1176 | |
1177 | if (!FieldRec->isStandardLayout()) |
1178 | data().IsStandardLayout = false; |
1179 | if (!FieldRec->isCXX11StandardLayout()) |
1180 | data().IsCXX11StandardLayout = false; |
1181 | |
1182 | |
1183 | |
1184 | |
1185 | |
1186 | if (data().IsStandardLayout && (isUnion() || IsFirstField) && |
1187 | hasSubobjectAtOffsetZeroOfEmptyBaseType(Context, FieldRec)) |
1188 | data().IsStandardLayout = false; |
1189 | |
1190 | |
1191 | |
1192 | |
1193 | |
1194 | if (data().IsCXX11StandardLayout && IsFirstField) { |
1195 | |
1196 | |
1197 | for (const auto &BI : bases()) { |
1198 | if (Context.hasSameUnqualifiedType(BI.getType(), T)) { |
1199 | data().IsCXX11StandardLayout = false; |
1200 | break; |
1201 | } |
1202 | } |
1203 | } |
1204 | |
1205 | |
1206 | if (FieldRec->hasMutableFields()) { |
1207 | data().HasMutableFields = true; |
1208 | data().NeedOverloadResolutionForCopyConstructor = true; |
1209 | } |
1210 | |
1211 | |
1212 | |
1213 | |
1214 | |
1215 | |
1216 | |
1217 | |
1218 | if (!Field->hasInClassInitializer() && |
1219 | !FieldRec->hasConstexprDefaultConstructor() && !isUnion()) |
1220 | |
1221 | |
1222 | data().DefaultedDefaultConstructorIsConstexpr = false; |
1223 | |
1224 | |
1225 | |
1226 | |
1227 | |
1228 | |
1229 | if (!FieldRec->hasCopyConstructorWithConstParam()) |
1230 | data().ImplicitCopyConstructorCanHaveConstParamForNonVBase = false; |
1231 | |
1232 | |
1233 | |
1234 | |
1235 | |
1236 | |
1237 | |
1238 | if (!FieldRec->hasCopyAssignmentWithConstParam()) |
1239 | data().ImplicitCopyAssignmentHasConstParam = false; |
1240 | |
1241 | if (FieldRec->hasUninitializedReferenceMember() && |
1242 | !Field->hasInClassInitializer()) |
1243 | data().HasUninitializedReferenceMember = true; |
1244 | |
1245 | |
1246 | |
1247 | |
1248 | if (FieldRec->hasVariantMembers() && |
1249 | Field->isAnonymousStructOrUnion()) |
1250 | data().HasVariantMembers = true; |
1251 | } |
1252 | } else { |
1253 | |
1254 | if (!T->isLiteralType(Context) || |
1255 | (!Field->hasInClassInitializer() && !isUnion())) |
1256 | data().DefaultedDefaultConstructorIsConstexpr = false; |
1257 | |
1258 | |
1259 | |
1260 | |
1261 | |
1262 | |
1263 | if (T.isConstQualified()) |
1264 | data().DefaultedMoveAssignmentIsDeleted = true; |
1265 | } |
1266 | |
1267 | |
1268 | |
1269 | data().Empty = false; |
1270 | } |
1271 | |
1272 | |
1273 | if (auto *Shadow = dyn_cast<UsingShadowDecl>(D)) { |
1274 | if (Shadow->getDeclName().getNameKind() |
1275 | == DeclarationName::CXXConversionFunctionName) { |
1276 | ASTContext &Ctx = getASTContext(); |
1277 | data().Conversions.get(Ctx).addDecl(Ctx, Shadow, Shadow->getAccess()); |
1278 | } |
1279 | } |
1280 | |
1281 | if (const auto *Using = dyn_cast<UsingDecl>(D)) { |
1282 | if (Using->getDeclName().getNameKind() == |
1283 | DeclarationName::CXXConstructorName) { |
1284 | data().HasInheritedConstructor = true; |
1285 | |
1286 | |
1287 | data().Aggregate = false; |
1288 | } |
1289 | |
1290 | if (Using->getDeclName().getCXXOverloadedOperator() == OO_Equal) |
1291 | data().HasInheritedAssignment = true; |
1292 | } |
1293 | } |
1294 | |
1295 | void CXXRecordDecl::finishedDefaultedOrDeletedMember(CXXMethodDecl *D) { |
1296 | isImplicit() && !D->isUserProvided()", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1296, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->isImplicit() && !D->isUserProvided()); |
1297 | |
1298 | |
1299 | unsigned SMKind = 0; |
1300 | |
1301 | if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(D)) { |
1302 | if (Constructor->isDefaultConstructor()) { |
1303 | SMKind |= SMF_DefaultConstructor; |
1304 | if (Constructor->isConstexpr()) |
1305 | data().HasConstexprDefaultConstructor = true; |
1306 | } |
1307 | if (Constructor->isCopyConstructor()) |
1308 | SMKind |= SMF_CopyConstructor; |
1309 | else if (Constructor->isMoveConstructor()) |
1310 | SMKind |= SMF_MoveConstructor; |
1311 | else if (Constructor->isConstexpr()) |
1312 | |
1313 | data().HasConstexprNonCopyMoveConstructor = true; |
1314 | } else if (isa<CXXDestructorDecl>(D)) { |
1315 | SMKind |= SMF_Destructor; |
1316 | if (!D->isTrivial() || D->getAccess() != AS_public || D->isDeleted()) |
1317 | data().HasIrrelevantDestructor = false; |
1318 | } else if (D->isCopyAssignmentOperator()) |
1319 | SMKind |= SMF_CopyAssignment; |
1320 | else if (D->isMoveAssignmentOperator()) |
1321 | SMKind |= SMF_MoveAssignment; |
1322 | |
1323 | |
1324 | |
1325 | if (D->isTrivial()) |
1326 | data().HasTrivialSpecialMembers |= SMKind; |
1327 | else |
1328 | data().DeclaredNonTrivialSpecialMembers |= SMKind; |
1329 | } |
1330 | |
1331 | void CXXRecordDecl::setTrivialForCallFlags(CXXMethodDecl *D) { |
1332 | unsigned SMKind = 0; |
1333 | |
1334 | if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(D)) { |
1335 | if (Constructor->isCopyConstructor()) |
1336 | SMKind = SMF_CopyConstructor; |
1337 | else if (Constructor->isMoveConstructor()) |
1338 | SMKind = SMF_MoveConstructor; |
1339 | } else if (isa<CXXDestructorDecl>(D)) |
1340 | SMKind = SMF_Destructor; |
1341 | |
1342 | if (D->isTrivialForCall()) |
1343 | data().HasTrivialSpecialMembersForCall |= SMKind; |
1344 | else |
1345 | data().DeclaredNonTrivialSpecialMembersForCall |= SMKind; |
1346 | } |
1347 | |
1348 | bool CXXRecordDecl::isCLike() const { |
1349 | if (getTagKind() == TTK_Class || getTagKind() == TTK_Interface || |
1350 | !TemplateOrInstantiation.isNull()) |
1351 | return false; |
1352 | if (!hasDefinition()) |
1353 | return true; |
1354 | |
1355 | return isPOD() && data().HasOnlyCMembers; |
1356 | } |
1357 | |
1358 | bool CXXRecordDecl::isGenericLambda() const { |
1359 | if (!isLambda()) return false; |
1360 | return getLambdaData().IsGenericLambda; |
1361 | } |
1362 | |
1363 | #ifndef NDEBUG |
1364 | static bool allLookupResultsAreTheSame(const DeclContext::lookup_result &R) { |
1365 | for (auto *D : R) |
1366 | if (!declaresSameEntity(D, R.front())) |
1367 | return false; |
1368 | return true; |
1369 | } |
1370 | #endif |
1371 | |
1372 | CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const { |
1373 | if (!isLambda()) return nullptr; |
1374 | DeclarationName Name = |
1375 | getASTContext().DeclarationNames.getCXXOperatorName(OO_Call); |
1376 | DeclContext::lookup_result Calls = lookup(Name); |
1377 | |
1378 | (0) . __assert_fail ("!Calls.empty() && \"Missing lambda call operator!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1378, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Calls.empty() && "Missing lambda call operator!"); |
1379 | (0) . __assert_fail ("allLookupResultsAreTheSame(Calls) && \"More than one lambda call operator!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1380, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(allLookupResultsAreTheSame(Calls) && |
1380 | (0) . __assert_fail ("allLookupResultsAreTheSame(Calls) && \"More than one lambda call operator!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1380, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "More than one lambda call operator!"); |
1381 | |
1382 | NamedDecl *CallOp = Calls.front(); |
1383 | if (const auto *CallOpTmpl = dyn_cast<FunctionTemplateDecl>(CallOp)) |
1384 | return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl()); |
1385 | |
1386 | return cast<CXXMethodDecl>(CallOp); |
1387 | } |
1388 | |
1389 | CXXMethodDecl* CXXRecordDecl::getLambdaStaticInvoker() const { |
1390 | if (!isLambda()) return nullptr; |
1391 | DeclarationName Name = |
1392 | &getASTContext().Idents.get(getLambdaStaticInvokerName()); |
1393 | DeclContext::lookup_result Invoker = lookup(Name); |
1394 | if (Invoker.empty()) return nullptr; |
1395 | (0) . __assert_fail ("allLookupResultsAreTheSame(Invoker) && \"More than one static invoker operator!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1396, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(allLookupResultsAreTheSame(Invoker) && |
1396 | (0) . __assert_fail ("allLookupResultsAreTheSame(Invoker) && \"More than one static invoker operator!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1396, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "More than one static invoker operator!"); |
1397 | NamedDecl *InvokerFun = Invoker.front(); |
1398 | if (const auto *InvokerTemplate = dyn_cast<FunctionTemplateDecl>(InvokerFun)) |
1399 | return cast<CXXMethodDecl>(InvokerTemplate->getTemplatedDecl()); |
1400 | |
1401 | return cast<CXXMethodDecl>(InvokerFun); |
1402 | } |
1403 | |
1404 | void CXXRecordDecl::getCaptureFields( |
1405 | llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures, |
1406 | FieldDecl *&ThisCapture) const { |
1407 | Captures.clear(); |
1408 | ThisCapture = nullptr; |
1409 | |
1410 | LambdaDefinitionData &Lambda = getLambdaData(); |
1411 | RecordDecl::field_iterator Field = field_begin(); |
1412 | for (const LambdaCapture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures; |
1413 | C != CEnd; ++C, ++Field) { |
1414 | if (C->capturesThis()) |
1415 | ThisCapture = *Field; |
1416 | else if (C->capturesVariable()) |
1417 | Captures[C->getCapturedVar()] = *Field; |
1418 | } |
1419 | assert(Field == field_end()); |
1420 | } |
1421 | |
1422 | TemplateParameterList * |
1423 | CXXRecordDecl::getGenericLambdaTemplateParameterList() const { |
1424 | if (!isLambda()) return nullptr; |
1425 | CXXMethodDecl *CallOp = getLambdaCallOperator(); |
1426 | if (FunctionTemplateDecl *Tmpl = CallOp->getDescribedFunctionTemplate()) |
1427 | return Tmpl->getTemplateParameters(); |
1428 | return nullptr; |
1429 | } |
1430 | |
1431 | Decl *CXXRecordDecl::getLambdaContextDecl() const { |
1432 | (0) . __assert_fail ("isLambda() && \"Not a lambda closure type!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1432, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isLambda() && "Not a lambda closure type!"); |
1433 | ExternalASTSource *Source = getParentASTContext().getExternalSource(); |
1434 | return getLambdaData().ContextDecl.get(Source); |
1435 | } |
1436 | |
1437 | static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) { |
1438 | QualType T = |
1439 | cast<CXXConversionDecl>(Conv->getUnderlyingDecl()->getAsFunction()) |
1440 | ->getConversionType(); |
1441 | return Context.getCanonicalType(T); |
1442 | } |
1443 | |
1444 | |
1445 | |
1446 | |
1447 | |
1448 | |
1449 | |
1450 | |
1451 | |
1452 | |
1453 | |
1454 | |
1455 | |
1456 | static void CollectVisibleConversions(ASTContext &Context, |
1457 | CXXRecordDecl *Record, |
1458 | bool InVirtual, |
1459 | AccessSpecifier Access, |
1460 | const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes, |
1461 | ASTUnresolvedSet &Output, |
1462 | UnresolvedSetImpl &VOutput, |
1463 | llvm::SmallPtrSet<NamedDecl*, 8> &HiddenVBaseCs) { |
1464 | |
1465 | |
1466 | |
1467 | const llvm::SmallPtrSet<CanQualType, 8> *HiddenTypes = &ParentHiddenTypes; |
1468 | llvm::SmallPtrSet<CanQualType, 8> HiddenTypesBuffer; |
1469 | |
1470 | |
1471 | |
1472 | CXXRecordDecl::conversion_iterator ConvI = Record->conversion_begin(); |
1473 | CXXRecordDecl::conversion_iterator ConvE = Record->conversion_end(); |
1474 | if (ConvI != ConvE) { |
1475 | HiddenTypesBuffer = ParentHiddenTypes; |
1476 | HiddenTypes = &HiddenTypesBuffer; |
1477 | |
1478 | for (CXXRecordDecl::conversion_iterator I = ConvI; I != ConvE; ++I) { |
1479 | CanQualType ConvType(GetConversionType(Context, I.getDecl())); |
1480 | bool Hidden = ParentHiddenTypes.count(ConvType); |
1481 | if (!Hidden) |
1482 | HiddenTypesBuffer.insert(ConvType); |
1483 | |
1484 | |
1485 | |
1486 | if (Hidden && InVirtual) |
1487 | HiddenVBaseCs.insert(cast<NamedDecl>(I.getDecl()->getCanonicalDecl())); |
1488 | |
1489 | |
1490 | else if (!Hidden) { |
1491 | AccessSpecifier IAccess |
1492 | = CXXRecordDecl::MergeAccess(Access, I.getAccess()); |
1493 | |
1494 | if (InVirtual) |
1495 | VOutput.addDecl(I.getDecl(), IAccess); |
1496 | else |
1497 | Output.addDecl(Context, I.getDecl(), IAccess); |
1498 | } |
1499 | } |
1500 | } |
1501 | |
1502 | |
1503 | for (const auto &I : Record->bases()) { |
1504 | const RecordType *RT = I.getType()->getAs<RecordType>(); |
1505 | if (!RT) continue; |
1506 | |
1507 | AccessSpecifier BaseAccess |
1508 | = CXXRecordDecl::MergeAccess(Access, I.getAccessSpecifier()); |
1509 | bool BaseInVirtual = InVirtual || I.isVirtual(); |
1510 | |
1511 | auto *Base = cast<CXXRecordDecl>(RT->getDecl()); |
1512 | CollectVisibleConversions(Context, Base, BaseInVirtual, BaseAccess, |
1513 | *HiddenTypes, Output, VOutput, HiddenVBaseCs); |
1514 | } |
1515 | } |
1516 | |
1517 | |
1518 | |
1519 | |
1520 | |
1521 | static void CollectVisibleConversions(ASTContext &Context, |
1522 | CXXRecordDecl *Record, |
1523 | ASTUnresolvedSet &Output) { |
1524 | |
1525 | |
1526 | |
1527 | UnresolvedSet<8> VBaseCs; |
1528 | |
1529 | |
1530 | |
1531 | llvm::SmallPtrSet<NamedDecl*, 8> HiddenVBaseCs; |
1532 | |
1533 | |
1534 | llvm::SmallPtrSet<CanQualType, 8> HiddenTypes; |
1535 | |
1536 | |
1537 | |
1538 | CXXRecordDecl::conversion_iterator ConvI = Record->conversion_begin(); |
1539 | CXXRecordDecl::conversion_iterator ConvE = Record->conversion_end(); |
1540 | Output.append(Context, ConvI, ConvE); |
1541 | for (; ConvI != ConvE; ++ConvI) |
1542 | HiddenTypes.insert(GetConversionType(Context, ConvI.getDecl())); |
1543 | |
1544 | |
1545 | for (const auto &I : Record->bases()) { |
1546 | const RecordType *RT = I.getType()->getAs<RecordType>(); |
1547 | if (!RT) continue; |
1548 | |
1549 | CollectVisibleConversions(Context, cast<CXXRecordDecl>(RT->getDecl()), |
1550 | I.isVirtual(), I.getAccessSpecifier(), |
1551 | HiddenTypes, Output, VBaseCs, HiddenVBaseCs); |
1552 | } |
1553 | |
1554 | |
1555 | for (UnresolvedSetIterator I = VBaseCs.begin(), E = VBaseCs.end(); |
1556 | I != E; ++I) { |
1557 | if (!HiddenVBaseCs.count(cast<NamedDecl>(I.getDecl()->getCanonicalDecl()))) |
1558 | Output.addDecl(Context, I.getDecl(), I.getAccess()); |
1559 | } |
1560 | } |
1561 | |
1562 | |
1563 | |
1564 | llvm::iterator_range<CXXRecordDecl::conversion_iterator> |
1565 | CXXRecordDecl::getVisibleConversionFunctions() { |
1566 | ASTContext &Ctx = getASTContext(); |
1567 | |
1568 | ASTUnresolvedSet *Set; |
1569 | if (bases_begin() == bases_end()) { |
1570 | |
1571 | Set = &data().Conversions.get(Ctx); |
1572 | } else { |
1573 | Set = &data().VisibleConversions.get(Ctx); |
1574 | |
1575 | if (!data().ComputedVisibleConversions) { |
1576 | CollectVisibleConversions(Ctx, this, *Set); |
1577 | data().ComputedVisibleConversions = true; |
1578 | } |
1579 | } |
1580 | return llvm::make_range(Set->begin(), Set->end()); |
1581 | } |
1582 | |
1583 | void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) { |
1584 | |
1585 | |
1586 | |
1587 | |
1588 | |
1589 | |
1590 | |
1591 | |
1592 | |
1593 | |
1594 | |
1595 | ASTUnresolvedSet &Convs = data().Conversions.get(getASTContext()); |
1596 | for (unsigned I = 0, E = Convs.size(); I != E; ++I) { |
1597 | if (Convs[I].getDecl() == ConvDecl) { |
1598 | Convs.erase(I); |
1599 | (0) . __assert_fail ("std..find(Convs.begin(), Convs.end(), ConvDecl) == Convs.end() && \"conversion was found multiple times in unresolved set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1600, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(std::find(Convs.begin(), Convs.end(), ConvDecl) == Convs.end() |
1600 | (0) . __assert_fail ("std..find(Convs.begin(), Convs.end(), ConvDecl) == Convs.end() && \"conversion was found multiple times in unresolved set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1600, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> && "conversion was found multiple times in unresolved set"); |
1601 | return; |
1602 | } |
1603 | } |
1604 | |
1605 | llvm_unreachable("conversion not found in set!"); |
1606 | } |
1607 | |
1608 | CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() const { |
1609 | if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) |
1610 | return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom()); |
1611 | |
1612 | return nullptr; |
1613 | } |
1614 | |
1615 | MemberSpecializationInfo *CXXRecordDecl::getMemberSpecializationInfo() const { |
1616 | return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>(); |
1617 | } |
1618 | |
1619 | void |
1620 | CXXRecordDecl::setInstantiationOfMemberClass(CXXRecordDecl *RD, |
1621 | TemplateSpecializationKind TSK) { |
1622 | (0) . __assert_fail ("TemplateOrInstantiation.isNull() && \"Previous template or instantiation?\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1623, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(TemplateOrInstantiation.isNull() && |
1623 | (0) . __assert_fail ("TemplateOrInstantiation.isNull() && \"Previous template or instantiation?\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1623, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Previous template or instantiation?"); |
1624 | (this)", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1624, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!isa<ClassTemplatePartialSpecializationDecl>(this)); |
1625 | TemplateOrInstantiation |
1626 | = new (getASTContext()) MemberSpecializationInfo(RD, TSK); |
1627 | } |
1628 | |
1629 | ClassTemplateDecl *CXXRecordDecl::getDescribedClassTemplate() const { |
1630 | return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl *>(); |
1631 | } |
1632 | |
1633 | void CXXRecordDecl::setDescribedClassTemplate(ClassTemplateDecl *Template) { |
1634 | TemplateOrInstantiation = Template; |
1635 | } |
1636 | |
1637 | TemplateSpecializationKind CXXRecordDecl::getTemplateSpecializationKind() const{ |
1638 | if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(this)) |
1639 | return Spec->getSpecializationKind(); |
1640 | |
1641 | if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) |
1642 | return MSInfo->getTemplateSpecializationKind(); |
1643 | |
1644 | return TSK_Undeclared; |
1645 | } |
1646 | |
1647 | void |
1648 | CXXRecordDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK) { |
1649 | if (auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(this)) { |
1650 | Spec->setSpecializationKind(TSK); |
1651 | return; |
1652 | } |
1653 | |
1654 | if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) { |
1655 | MSInfo->setTemplateSpecializationKind(TSK); |
1656 | return; |
1657 | } |
1658 | |
1659 | llvm_unreachable("Not a class template or member class specialization"); |
1660 | } |
1661 | |
1662 | const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { |
1663 | auto GetDefinitionOrSelf = |
1664 | [](const CXXRecordDecl *D) -> const CXXRecordDecl * { |
1665 | if (auto *Def = D->getDefinition()) |
1666 | return Def; |
1667 | return D; |
1668 | }; |
1669 | |
1670 | |
1671 | |
1672 | if (auto *TD = dyn_cast<ClassTemplateSpecializationDecl>(this)) { |
1673 | auto From = TD->getInstantiatedFrom(); |
1674 | if (auto *CTD = From.dyn_cast<ClassTemplateDecl *>()) { |
1675 | while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) { |
1676 | if (NewCTD->isMemberSpecialization()) |
1677 | break; |
1678 | CTD = NewCTD; |
1679 | } |
1680 | return GetDefinitionOrSelf(CTD->getTemplatedDecl()); |
1681 | } |
1682 | if (auto *CTPSD = |
1683 | From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) { |
1684 | while (auto *NewCTPSD = CTPSD->getInstantiatedFromMember()) { |
1685 | if (NewCTPSD->isMemberSpecialization()) |
1686 | break; |
1687 | CTPSD = NewCTPSD; |
1688 | } |
1689 | return GetDefinitionOrSelf(CTPSD); |
1690 | } |
1691 | } |
1692 | |
1693 | if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) { |
1694 | if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) { |
1695 | const CXXRecordDecl *RD = this; |
1696 | while (auto *NewRD = RD->getInstantiatedFromMemberClass()) |
1697 | RD = NewRD; |
1698 | return GetDefinitionOrSelf(RD); |
1699 | } |
1700 | } |
1701 | |
1702 | (0) . __assert_fail ("!isTemplateInstantiation(this->getTemplateSpecializationKind()) && \"couldn't find pattern for class template instantiation\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1703, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!isTemplateInstantiation(this->getTemplateSpecializationKind()) && |
1703 | (0) . __assert_fail ("!isTemplateInstantiation(this->getTemplateSpecializationKind()) && \"couldn't find pattern for class template instantiation\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1703, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "couldn't find pattern for class template instantiation"); |
1704 | return nullptr; |
1705 | } |
1706 | |
1707 | CXXDestructorDecl *CXXRecordDecl::getDestructor() const { |
1708 | ASTContext &Context = getASTContext(); |
1709 | QualType ClassType = Context.getTypeDeclType(this); |
1710 | |
1711 | DeclarationName Name |
1712 | = Context.DeclarationNames.getCXXDestructorName( |
1713 | Context.getCanonicalType(ClassType)); |
1714 | |
1715 | DeclContext::lookup_result R = lookup(Name); |
1716 | |
1717 | return R.empty() ? nullptr : dyn_cast<CXXDestructorDecl>(R.front()); |
1718 | } |
1719 | |
1720 | bool CXXRecordDecl::isAnyDestructorNoReturn() const { |
1721 | |
1722 | if (const CXXDestructorDecl *Destructor = getDestructor()) |
1723 | if (Destructor->isNoReturn()) |
1724 | return true; |
1725 | |
1726 | |
1727 | for (const auto &Base : bases()) |
1728 | if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl()) |
1729 | if (RD->isAnyDestructorNoReturn()) |
1730 | return true; |
1731 | |
1732 | |
1733 | for (const auto *Field : fields()) |
1734 | if (const CXXRecordDecl *RD = |
1735 | Field->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl()) |
1736 | if (RD->isAnyDestructorNoReturn()) |
1737 | return true; |
1738 | |
1739 | |
1740 | return false; |
1741 | } |
1742 | |
1743 | static bool isDeclContextInNamespace(const DeclContext *DC) { |
1744 | while (!DC->isTranslationUnit()) { |
1745 | if (DC->isNamespace()) |
1746 | return true; |
1747 | DC = DC->getParent(); |
1748 | } |
1749 | return false; |
1750 | } |
1751 | |
1752 | bool CXXRecordDecl::isInterfaceLike() const { |
1753 | (0) . __assert_fail ("hasDefinition() && \"checking for interface-like without a definition\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1753, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(hasDefinition() && "checking for interface-like without a definition"); |
1754 | |
1755 | if (isInterface()) |
1756 | return true; |
1757 | |
1758 | |
1759 | |
1760 | |
1761 | if (isLambda() || hasUserDeclaredConstructor() || |
1762 | hasUserDeclaredDestructor() || !field_empty() || hasFriends() || |
1763 | getNumVBases() > 0 || conversion_end() - conversion_begin() > 0) |
1764 | return false; |
1765 | |
1766 | |
1767 | for (const auto *const Method : methods()) |
1768 | if (Method->isDefined() && !Method->isImplicit()) |
1769 | return false; |
1770 | |
1771 | |
1772 | const auto *Uuid = getAttr<UuidAttr>(); |
1773 | |
1774 | |
1775 | |
1776 | if (Uuid && isStruct() && !getDeclContext()->isExternCContext() && |
1777 | !isDeclContextInNamespace(getDeclContext()) && |
1778 | ((getName() == "IUnknown" && |
1779 | Uuid->getGuid() == "00000000-0000-0000-C000-000000000046") || |
1780 | (getName() == "IDispatch" && |
1781 | Uuid->getGuid() == "00020400-0000-0000-C000-000000000046"))) { |
1782 | if (getNumBases() > 0) |
1783 | return false; |
1784 | return true; |
1785 | } |
1786 | |
1787 | |
1788 | |
1789 | |
1790 | |
1791 | if (getNumBases() != 1) |
1792 | return false; |
1793 | |
1794 | const auto BaseSpec = *bases_begin(); |
1795 | if (BaseSpec.isVirtual() || BaseSpec.getAccessSpecifier() != AS_public) |
1796 | return false; |
1797 | const auto *Base = BaseSpec.getType()->getAsCXXRecordDecl(); |
1798 | if (Base->isInterface() || !Base->isInterfaceLike()) |
1799 | return false; |
1800 | return true; |
1801 | } |
1802 | |
1803 | void CXXRecordDecl::completeDefinition() { |
1804 | completeDefinition(nullptr); |
1805 | } |
1806 | |
1807 | void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { |
1808 | RecordDecl::completeDefinition(); |
1809 | |
1810 | |
1811 | |
1812 | if (mayBeAbstract()) { |
1813 | CXXFinalOverriderMap MyFinalOverriders; |
1814 | if (!FinalOverriders) { |
1815 | getFinalOverriders(MyFinalOverriders); |
1816 | FinalOverriders = &MyFinalOverriders; |
1817 | } |
1818 | |
1819 | bool Done = false; |
1820 | for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(), |
1821 | MEnd = FinalOverriders->end(); |
1822 | M != MEnd && !Done; ++M) { |
1823 | for (OverridingMethods::iterator SO = M->second.begin(), |
1824 | SOEnd = M->second.end(); |
1825 | SO != SOEnd && !Done; ++SO) { |
1826 | (0) . __assert_fail ("SO->second.size() > 0 && \"All virtual functions have overriding virtual functions\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1827, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(SO->second.size() > 0 && |
1827 | (0) . __assert_fail ("SO->second.size() > 0 && \"All virtual functions have overriding virtual functions\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1827, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "All virtual functions have overriding virtual functions"); |
1828 | |
1829 | |
1830 | |
1831 | |
1832 | |
1833 | if (SO->second.front().Method->isPure()) { |
1834 | data().Abstract = true; |
1835 | Done = true; |
1836 | break; |
1837 | } |
1838 | } |
1839 | } |
1840 | } |
1841 | |
1842 | |
1843 | for (conversion_iterator I = conversion_begin(), E = conversion_end(); |
1844 | I != E; ++I) |
1845 | I.setAccess((*I)->getAccess()); |
1846 | } |
1847 | |
1848 | bool CXXRecordDecl::mayBeAbstract() const { |
1849 | if (data().Abstract || isInvalidDecl() || !data().Polymorphic || |
1850 | isDependentContext()) |
1851 | return false; |
1852 | |
1853 | for (const auto &B : bases()) { |
1854 | const auto *BaseDecl = |
1855 | cast<CXXRecordDecl>(B.getType()->getAs<RecordType>()->getDecl()); |
1856 | if (BaseDecl->isAbstract()) |
1857 | return true; |
1858 | } |
1859 | |
1860 | return false; |
1861 | } |
1862 | |
1863 | void CXXDeductionGuideDecl::anchor() {} |
1864 | |
1865 | CXXDeductionGuideDecl *CXXDeductionGuideDecl::Create( |
1866 | ASTContext &C, DeclContext *DC, SourceLocation StartLoc, bool IsExplicit, |
1867 | const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, |
1868 | SourceLocation EndLocation) { |
1869 | return new (C, DC) CXXDeductionGuideDecl(C, DC, StartLoc, IsExplicit, |
1870 | NameInfo, T, TInfo, EndLocation); |
1871 | } |
1872 | |
1873 | CXXDeductionGuideDecl *CXXDeductionGuideDecl::CreateDeserialized(ASTContext &C, |
1874 | unsigned ID) { |
1875 | return new (C, ID) CXXDeductionGuideDecl(C, nullptr, SourceLocation(), false, |
1876 | DeclarationNameInfo(), QualType(), |
1877 | nullptr, SourceLocation()); |
1878 | } |
1879 | |
1880 | void CXXMethodDecl::anchor() {} |
1881 | |
1882 | bool CXXMethodDecl::isStatic() const { |
1883 | const CXXMethodDecl *MD = getCanonicalDecl(); |
1884 | |
1885 | if (MD->getStorageClass() == SC_Static) |
1886 | return true; |
1887 | |
1888 | OverloadedOperatorKind OOK = getDeclName().getCXXOverloadedOperator(); |
1889 | return isStaticOverloadedOperator(OOK); |
1890 | } |
1891 | |
1892 | static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD, |
1893 | const CXXMethodDecl *BaseMD) { |
1894 | for (const CXXMethodDecl *MD : DerivedMD->overridden_methods()) { |
1895 | if (MD->getCanonicalDecl() == BaseMD->getCanonicalDecl()) |
1896 | return true; |
1897 | if (recursivelyOverrides(MD, BaseMD)) |
1898 | return true; |
1899 | } |
1900 | return false; |
1901 | } |
1902 | |
1903 | CXXMethodDecl * |
1904 | CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD, |
1905 | bool MayBeBase) { |
1906 | if (this->getParent()->getCanonicalDecl() == RD->getCanonicalDecl()) |
1907 | return this; |
1908 | |
1909 | |
1910 | if (isa<CXXDestructorDecl>(this)) { |
1911 | CXXMethodDecl *MD = RD->getDestructor(); |
1912 | if (MD) { |
1913 | if (recursivelyOverrides(MD, this)) |
1914 | return MD; |
1915 | if (MayBeBase && recursivelyOverrides(this, MD)) |
1916 | return MD; |
1917 | } |
1918 | return nullptr; |
1919 | } |
1920 | |
1921 | for (auto *ND : RD->lookup(getDeclName())) { |
1922 | auto *MD = dyn_cast<CXXMethodDecl>(ND); |
1923 | if (!MD) |
1924 | continue; |
1925 | if (recursivelyOverrides(MD, this)) |
1926 | return MD; |
1927 | if (MayBeBase && recursivelyOverrides(this, MD)) |
1928 | return MD; |
1929 | } |
1930 | |
1931 | for (const auto &I : RD->bases()) { |
1932 | const RecordType *RT = I.getType()->getAs<RecordType>(); |
1933 | if (!RT) |
1934 | continue; |
1935 | const auto *Base = cast<CXXRecordDecl>(RT->getDecl()); |
1936 | CXXMethodDecl *T = this->getCorrespondingMethodInClass(Base); |
1937 | if (T) |
1938 | return T; |
1939 | } |
1940 | |
1941 | return nullptr; |
1942 | } |
1943 | |
1944 | CXXMethodDecl * |
1945 | CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
1946 | SourceLocation StartLoc, |
1947 | const DeclarationNameInfo &NameInfo, |
1948 | QualType T, TypeSourceInfo *TInfo, |
1949 | StorageClass SC, bool isInline, |
1950 | bool isConstexpr, SourceLocation EndLocation) { |
1951 | return new (C, RD) CXXMethodDecl(CXXMethod, C, RD, StartLoc, NameInfo, |
1952 | T, TInfo, SC, isInline, isConstexpr, |
1953 | EndLocation); |
1954 | } |
1955 | |
1956 | CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
1957 | return new (C, ID) CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(), |
1958 | DeclarationNameInfo(), QualType(), nullptr, |
1959 | SC_None, false, false, SourceLocation()); |
1960 | } |
1961 | |
1962 | CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base, |
1963 | bool IsAppleKext) { |
1964 | (0) . __assert_fail ("isVirtual() && \"this method is expected to be virtual\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 1964, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isVirtual() && "this method is expected to be virtual"); |
1965 | |
1966 | |
1967 | |
1968 | if (IsAppleKext) |
1969 | return nullptr; |
1970 | |
1971 | |
1972 | |
1973 | if (hasAttr<FinalAttr>()) |
1974 | return isPure() ? nullptr : this; |
1975 | |
1976 | |
1977 | if (!Base) |
1978 | return nullptr; |
1979 | |
1980 | |
1981 | |
1982 | Base = Base->getBestDynamicClassTypeExpr(); |
1983 | if (Base->isRValue() && Base->getType()->isRecordType()) |
1984 | return this; |
1985 | |
1986 | |
1987 | const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType(); |
1988 | if (!BestDynamicDecl) |
1989 | return nullptr; |
1990 | |
1991 | |
1992 | CXXMethodDecl *DevirtualizedMethod = |
1993 | getCorrespondingMethodInClass(BestDynamicDecl); |
1994 | |
1995 | |
1996 | |
1997 | |
1998 | if (DevirtualizedMethod->isPure()) |
1999 | return nullptr; |
2000 | |
2001 | |
2002 | if (DevirtualizedMethod->hasAttr<FinalAttr>()) |
2003 | return DevirtualizedMethod; |
2004 | |
2005 | |
2006 | |
2007 | if (BestDynamicDecl->hasAttr<FinalAttr>()) |
2008 | return DevirtualizedMethod; |
2009 | |
2010 | if (const auto *DRE = dyn_cast<DeclRefExpr>(Base)) { |
2011 | if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) |
2012 | if (VD->getType()->isRecordType()) |
2013 | |
2014 | return DevirtualizedMethod; |
2015 | |
2016 | return nullptr; |
2017 | } |
2018 | |
2019 | |
2020 | |
2021 | |
2022 | if (const auto *ME = dyn_cast<MemberExpr>(Base)) { |
2023 | const ValueDecl *VD = ME->getMemberDecl(); |
2024 | return VD->getType()->isRecordType() ? DevirtualizedMethod : nullptr; |
2025 | } |
2026 | |
2027 | |
2028 | |
2029 | if (auto *BO = dyn_cast<BinaryOperator>(Base)) { |
2030 | if (BO->isPtrMemOp()) { |
2031 | auto *MPT = BO->getRHS()->getType()->castAs<MemberPointerType>(); |
2032 | if (MPT->getPointeeType()->isRecordType()) |
2033 | return DevirtualizedMethod; |
2034 | } |
2035 | } |
2036 | |
2037 | |
2038 | return nullptr; |
2039 | } |
2040 | |
2041 | bool CXXMethodDecl::isUsualDeallocationFunction( |
2042 | SmallVectorImpl<const FunctionDecl *> &PreventedBy) const { |
2043 | (0) . __assert_fail ("PreventedBy.empty() && \"PreventedBy is expected to be empty\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2043, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(PreventedBy.empty() && "PreventedBy is expected to be empty"); |
2044 | if (getOverloadedOperator() != OO_Delete && |
2045 | getOverloadedOperator() != OO_Array_Delete) |
2046 | return false; |
2047 | |
2048 | |
2049 | |
2050 | |
2051 | if (getPrimaryTemplate()) |
2052 | return false; |
2053 | |
2054 | |
2055 | |
2056 | |
2057 | |
2058 | if (getNumParams() == 1) |
2059 | return true; |
2060 | unsigned UsualParams = 1; |
2061 | |
2062 | |
2063 | |
2064 | |
2065 | |
2066 | |
2067 | if (isDestroyingOperatorDelete()) |
2068 | ++UsualParams; |
2069 | |
2070 | |
2071 | |
2072 | |
2073 | |
2074 | |
2075 | |
2076 | |
2077 | |
2078 | |
2079 | |
2080 | ASTContext &Context = getASTContext(); |
2081 | if (UsualParams < getNumParams() && |
2082 | Context.hasSameUnqualifiedType(getParamDecl(UsualParams)->getType(), |
2083 | Context.getSizeType())) |
2084 | ++UsualParams; |
2085 | |
2086 | if (UsualParams < getNumParams() && |
2087 | getParamDecl(UsualParams)->getType()->isAlignValT()) |
2088 | ++UsualParams; |
2089 | |
2090 | if (UsualParams != getNumParams()) |
2091 | return false; |
2092 | |
2093 | |
2094 | |
2095 | |
2096 | |
2097 | |
2098 | if (Context.getLangOpts().CPlusPlus17 || |
2099 | Context.getLangOpts().AlignedAllocation || |
2100 | isDestroyingOperatorDelete()) |
2101 | return true; |
2102 | |
2103 | |
2104 | |
2105 | DeclContext::lookup_result R = getDeclContext()->lookup(getDeclName()); |
2106 | bool Result = true; |
2107 | for (const auto *D : R) { |
2108 | if (const auto *FD = dyn_cast<FunctionDecl>(D)) { |
2109 | if (FD->getNumParams() == 1) { |
2110 | PreventedBy.push_back(FD); |
2111 | Result = false; |
2112 | } |
2113 | } |
2114 | } |
2115 | return Result; |
2116 | } |
2117 | |
2118 | bool CXXMethodDecl::isCopyAssignmentOperator() const { |
2119 | |
2120 | |
2121 | |
2122 | |
2123 | if (() != OO_Equal || |
2124 | isStatic() || |
2125 | () || getDescribedFunctionTemplate() || |
2126 | getNumParams() != 1) |
2127 | return false; |
2128 | |
2129 | QualType ParamType = getParamDecl(0)->getType(); |
2130 | if (const auto *Ref = ParamType->getAs<LValueReferenceType>()) |
2131 | ParamType = Ref->getPointeeType(); |
2132 | |
2133 | ASTContext &Context = getASTContext(); |
2134 | QualType ClassType |
2135 | = Context.getCanonicalType(Context.getTypeDeclType(getParent())); |
2136 | return Context.hasSameUnqualifiedType(ClassType, ParamType); |
2137 | } |
2138 | |
2139 | bool CXXMethodDecl::isMoveAssignmentOperator() const { |
2140 | |
2141 | |
2142 | |
2143 | |
2144 | if (getOverloadedOperator() != OO_Equal || isStatic() || |
2145 | getPrimaryTemplate() || getDescribedFunctionTemplate() || |
2146 | getNumParams() != 1) |
2147 | return false; |
2148 | |
2149 | QualType ParamType = getParamDecl(0)->getType(); |
2150 | if (!isa<RValueReferenceType>(ParamType)) |
2151 | return false; |
2152 | ParamType = ParamType->getPointeeType(); |
2153 | |
2154 | ASTContext &Context = getASTContext(); |
2155 | QualType ClassType |
2156 | = Context.getCanonicalType(Context.getTypeDeclType(getParent())); |
2157 | return Context.hasSameUnqualifiedType(ClassType, ParamType); |
2158 | } |
2159 | |
2160 | void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) { |
2161 | (0) . __assert_fail ("MD->isCanonicalDecl() && \"Method is not canonical!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2161, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(MD->isCanonicalDecl() && "Method is not canonical!"); |
2162 | (0) . __assert_fail ("!MD->getParent()->isDependentContext() && \"Can't add an overridden method to a class template!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2163, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!MD->getParent()->isDependentContext() && |
2163 | (0) . __assert_fail ("!MD->getParent()->isDependentContext() && \"Can't add an overridden method to a class template!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2163, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Can't add an overridden method to a class template!"); |
2164 | (0) . __assert_fail ("MD->isVirtual() && \"Method is not virtual!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2164, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(MD->isVirtual() && "Method is not virtual!"); |
2165 | |
2166 | getASTContext().addOverriddenMethod(this, MD); |
2167 | } |
2168 | |
2169 | CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const { |
2170 | if (isa<CXXConstructorDecl>(this)) return nullptr; |
2171 | return getASTContext().overridden_methods_begin(this); |
2172 | } |
2173 | |
2174 | CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const { |
2175 | if (isa<CXXConstructorDecl>(this)) return nullptr; |
2176 | return getASTContext().overridden_methods_end(this); |
2177 | } |
2178 | |
2179 | unsigned CXXMethodDecl::size_overridden_methods() const { |
2180 | if (isa<CXXConstructorDecl>(this)) return 0; |
2181 | return getASTContext().overridden_methods_size(this); |
2182 | } |
2183 | |
2184 | CXXMethodDecl::overridden_method_range |
2185 | CXXMethodDecl::overridden_methods() const { |
2186 | if (isa<CXXConstructorDecl>(this)) |
2187 | return overridden_method_range(nullptr, nullptr); |
2188 | return getASTContext().overridden_methods(this); |
2189 | } |
2190 | |
2191 | QualType CXXMethodDecl::getThisType(const FunctionProtoType *FPT, |
2192 | const CXXRecordDecl *Decl) { |
2193 | ASTContext &C = Decl->getASTContext(); |
2194 | QualType ClassTy = C.getTypeDeclType(Decl); |
2195 | ClassTy = C.getQualifiedType(ClassTy, FPT->getMethodQuals()); |
2196 | return C.getPointerType(ClassTy); |
2197 | } |
2198 | |
2199 | QualType CXXMethodDecl::getThisType() const { |
2200 | |
2201 | |
2202 | |
2203 | |
2204 | |
2205 | (0) . __assert_fail ("isInstance() && \"No 'this' for static methods!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2205, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isInstance() && "No 'this' for static methods!"); |
2206 | |
2207 | return CXXMethodDecl::getThisType(getType()->getAs<FunctionProtoType>(), |
2208 | getParent()); |
2209 | } |
2210 | |
2211 | bool CXXMethodDecl::hasInlineBody() const { |
2212 | |
2213 | |
2214 | const FunctionDecl *CheckFn = getTemplateInstantiationPattern(); |
2215 | if (!CheckFn) |
2216 | CheckFn = this; |
2217 | |
2218 | const FunctionDecl *fn; |
2219 | return CheckFn->isDefined(fn) && !fn->isOutOfLine() && |
2220 | (fn->doesThisDeclarationHaveABody() || fn->willHaveBody()); |
2221 | } |
2222 | |
2223 | bool CXXMethodDecl::isLambdaStaticInvoker() const { |
2224 | const CXXRecordDecl *P = getParent(); |
2225 | if (P->isLambda()) { |
2226 | if (const CXXMethodDecl *StaticInvoker = P->getLambdaStaticInvoker()) { |
2227 | if (StaticInvoker == this) return true; |
2228 | if (P->isGenericLambda() && this->isFunctionTemplateSpecialization()) |
2229 | return StaticInvoker == this->getPrimaryTemplate()->getTemplatedDecl(); |
2230 | } |
2231 | } |
2232 | return false; |
2233 | } |
2234 | |
2235 | CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, |
2236 | TypeSourceInfo *TInfo, bool IsVirtual, |
2237 | SourceLocation L, Expr *Init, |
2238 | SourceLocation R, |
2239 | SourceLocation EllipsisLoc) |
2240 | : Initializee(TInfo), MemberOrEllipsisLocation(EllipsisLoc), Init(Init), |
2241 | LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(IsVirtual), |
2242 | IsWritten(false), SourceOrder(0) {} |
2243 | |
2244 | CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, |
2245 | FieldDecl *Member, |
2246 | SourceLocation MemberLoc, |
2247 | SourceLocation L, Expr *Init, |
2248 | SourceLocation R) |
2249 | : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init), |
2250 | LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false), |
2251 | IsWritten(false), SourceOrder(0) {} |
2252 | |
2253 | CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, |
2254 | IndirectFieldDecl *Member, |
2255 | SourceLocation MemberLoc, |
2256 | SourceLocation L, Expr *Init, |
2257 | SourceLocation R) |
2258 | : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init), |
2259 | LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false), |
2260 | IsWritten(false), SourceOrder(0) {} |
2261 | |
2262 | CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, |
2263 | TypeSourceInfo *TInfo, |
2264 | SourceLocation L, Expr *Init, |
2265 | SourceLocation R) |
2266 | : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R), |
2267 | IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {} |
2268 | |
2269 | int64_t CXXCtorInitializer::getID(const ASTContext &Context) const { |
2270 | return Context.getAllocator() |
2271 | .identifyKnownAlignedObject<CXXCtorInitializer>(this); |
2272 | } |
2273 | |
2274 | TypeLoc CXXCtorInitializer::getBaseClassLoc() const { |
2275 | if (isBaseInitializer()) |
2276 | return Initializee.get<TypeSourceInfo*>()->getTypeLoc(); |
2277 | else |
2278 | return {}; |
2279 | } |
2280 | |
2281 | const Type *CXXCtorInitializer::getBaseClass() const { |
2282 | if (isBaseInitializer()) |
2283 | return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr(); |
2284 | else |
2285 | return nullptr; |
2286 | } |
2287 | |
2288 | SourceLocation CXXCtorInitializer::getSourceLocation() const { |
2289 | if (isInClassMemberInitializer()) |
2290 | return getAnyMember()->getLocation(); |
2291 | |
2292 | if (isAnyMemberInitializer()) |
2293 | return getMemberLocation(); |
2294 | |
2295 | if (const auto *TSInfo = Initializee.get<TypeSourceInfo *>()) |
2296 | return TSInfo->getTypeLoc().getLocalSourceRange().getBegin(); |
2297 | |
2298 | return {}; |
2299 | } |
2300 | |
2301 | SourceRange CXXCtorInitializer::getSourceRange() const { |
2302 | if (isInClassMemberInitializer()) { |
2303 | FieldDecl *D = getAnyMember(); |
2304 | if (Expr *I = D->getInClassInitializer()) |
2305 | return I->getSourceRange(); |
2306 | return {}; |
2307 | } |
2308 | |
2309 | return SourceRange(getSourceLocation(), getRParenLoc()); |
2310 | } |
2311 | |
2312 | CXXConstructorDecl::CXXConstructorDecl( |
2313 | ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, |
2314 | const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, |
2315 | bool isExplicitSpecified, bool isInline, bool isImplicitlyDeclared, |
2316 | bool isConstexpr, InheritedConstructor Inherited) |
2317 | : CXXMethodDecl(CXXConstructor, C, RD, StartLoc, NameInfo, T, TInfo, |
2318 | SC_None, isInline, isConstexpr, SourceLocation()) { |
2319 | setNumCtorInitializers(0); |
2320 | setInheritingConstructor(static_cast<bool>(Inherited)); |
2321 | setImplicit(isImplicitlyDeclared); |
2322 | if (Inherited) |
2323 | *getTrailingObjects<InheritedConstructor>() = Inherited; |
2324 | setExplicitSpecified(isExplicitSpecified); |
2325 | } |
2326 | |
2327 | void CXXConstructorDecl::anchor() {} |
2328 | |
2329 | CXXConstructorDecl *CXXConstructorDecl::CreateDeserialized(ASTContext &C, |
2330 | unsigned ID, |
2331 | bool Inherited) { |
2332 | unsigned = additionalSizeToAlloc<InheritedConstructor>(Inherited); |
2333 | auto *Result = new (C, ID, Extra) CXXConstructorDecl( |
2334 | C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, |
2335 | false, false, false, false, InheritedConstructor()); |
2336 | Result->setInheritingConstructor(Inherited); |
2337 | return Result; |
2338 | } |
2339 | |
2340 | CXXConstructorDecl * |
2341 | CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
2342 | SourceLocation StartLoc, |
2343 | const DeclarationNameInfo &NameInfo, |
2344 | QualType T, TypeSourceInfo *TInfo, |
2345 | bool isExplicit, bool isInline, |
2346 | bool isImplicitlyDeclared, bool isConstexpr, |
2347 | InheritedConstructor Inherited) { |
2348 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXConstructorName && \"Name must refer to a constructor\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2350, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NameInfo.getName().getNameKind() |
2349 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXConstructorName && \"Name must refer to a constructor\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2350, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> == DeclarationName::CXXConstructorName && |
2350 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXConstructorName && \"Name must refer to a constructor\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2350, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Name must refer to a constructor"); |
2351 | unsigned = |
2352 | additionalSizeToAlloc<InheritedConstructor>(Inherited ? 1 : 0); |
2353 | return new (C, RD, Extra) CXXConstructorDecl( |
2354 | C, RD, StartLoc, NameInfo, T, TInfo, isExplicit, isInline, |
2355 | isImplicitlyDeclared, isConstexpr, Inherited); |
2356 | } |
2357 | |
2358 | CXXConstructorDecl::init_const_iterator CXXConstructorDecl::init_begin() const { |
2359 | return CtorInitializers.get(getASTContext().getExternalSource()); |
2360 | } |
2361 | |
2362 | CXXConstructorDecl *CXXConstructorDecl::getTargetConstructor() const { |
2363 | (0) . __assert_fail ("isDelegatingConstructor() && \"Not a delegating constructor!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2363, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isDelegatingConstructor() && "Not a delegating constructor!"); |
2364 | Expr *E = (*init_begin())->getInit()->IgnoreImplicit(); |
2365 | if (const auto *Construct = dyn_cast<CXXConstructExpr>(E)) |
2366 | return Construct->getConstructor(); |
2367 | |
2368 | return nullptr; |
2369 | } |
2370 | |
2371 | bool CXXConstructorDecl::isDefaultConstructor() const { |
2372 | |
2373 | |
2374 | |
2375 | return (getNumParams() == 0) || |
2376 | (getNumParams() > 0 && getParamDecl(0)->hasDefaultArg()); |
2377 | } |
2378 | |
2379 | bool |
2380 | CXXConstructorDecl::isCopyConstructor(unsigned &TypeQuals) const { |
2381 | return isCopyOrMoveConstructor(TypeQuals) && |
2382 | getParamDecl(0)->getType()->isLValueReferenceType(); |
2383 | } |
2384 | |
2385 | bool CXXConstructorDecl::isMoveConstructor(unsigned &TypeQuals) const { |
2386 | return isCopyOrMoveConstructor(TypeQuals) && |
2387 | getParamDecl(0)->getType()->isRValueReferenceType(); |
2388 | } |
2389 | |
2390 | |
2391 | bool CXXConstructorDecl::isCopyOrMoveConstructor(unsigned &TypeQuals) const { |
2392 | |
2393 | |
2394 | |
2395 | |
2396 | |
2397 | |
2398 | |
2399 | |
2400 | |
2401 | |
2402 | if ((getNumParams() < 1) || |
2403 | (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) || |
2404 | (getPrimaryTemplate() != nullptr) || |
2405 | (getDescribedFunctionTemplate() != nullptr)) |
2406 | return false; |
2407 | |
2408 | const ParmVarDecl *Param = getParamDecl(0); |
2409 | |
2410 | |
2411 | const auto *ParamRefType = Param->getType()->getAs<ReferenceType>(); |
2412 | if (!ParamRefType) |
2413 | return false; |
2414 | |
2415 | |
2416 | ASTContext &Context = getASTContext(); |
2417 | |
2418 | CanQualType PointeeType |
2419 | = Context.getCanonicalType(ParamRefType->getPointeeType()); |
2420 | CanQualType ClassTy |
2421 | = Context.getCanonicalType(Context.getTagDeclType(getParent())); |
2422 | if (PointeeType.getUnqualifiedType() != ClassTy) |
2423 | return false; |
2424 | |
2425 | |
2426 | |
2427 | |
2428 | TypeQuals = PointeeType.getCVRQualifiers(); |
2429 | return true; |
2430 | } |
2431 | |
2432 | bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const { |
2433 | |
2434 | |
2435 | |
2436 | |
2437 | |
2438 | |
2439 | if (isExplicit() && !AllowExplicit) |
2440 | return false; |
2441 | |
2442 | return (getNumParams() == 0 && |
2443 | getType()->getAs<FunctionProtoType>()->isVariadic()) || |
2444 | (getNumParams() == 1) || |
2445 | (getNumParams() > 1 && |
2446 | (getParamDecl(1)->hasDefaultArg() || |
2447 | getParamDecl(1)->isParameterPack())); |
2448 | } |
2449 | |
2450 | bool CXXConstructorDecl::isSpecializationCopyingObject() const { |
2451 | if ((getNumParams() < 1) || |
2452 | (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) || |
2453 | (getDescribedFunctionTemplate() != nullptr)) |
2454 | return false; |
2455 | |
2456 | const ParmVarDecl *Param = getParamDecl(0); |
2457 | |
2458 | ASTContext &Context = getASTContext(); |
2459 | CanQualType ParamType = Context.getCanonicalType(Param->getType()); |
2460 | |
2461 | |
2462 | CanQualType ClassTy |
2463 | = Context.getCanonicalType(Context.getTagDeclType(getParent())); |
2464 | if (ParamType.getUnqualifiedType() != ClassTy) |
2465 | return false; |
2466 | |
2467 | return true; |
2468 | } |
2469 | |
2470 | void CXXDestructorDecl::anchor() {} |
2471 | |
2472 | CXXDestructorDecl * |
2473 | CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2474 | return new (C, ID) |
2475 | CXXDestructorDecl(C, nullptr, SourceLocation(), DeclarationNameInfo(), |
2476 | QualType(), nullptr, false, false); |
2477 | } |
2478 | |
2479 | CXXDestructorDecl * |
2480 | CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
2481 | SourceLocation StartLoc, |
2482 | const DeclarationNameInfo &NameInfo, |
2483 | QualType T, TypeSourceInfo *TInfo, |
2484 | bool isInline, bool isImplicitlyDeclared) { |
2485 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXDestructorName && \"Name must refer to a destructor\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2487, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NameInfo.getName().getNameKind() |
2486 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXDestructorName && \"Name must refer to a destructor\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2487, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> == DeclarationName::CXXDestructorName && |
2487 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXDestructorName && \"Name must refer to a destructor\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2487, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Name must refer to a destructor"); |
2488 | return new (C, RD) CXXDestructorDecl(C, RD, StartLoc, NameInfo, T, TInfo, |
2489 | isInline, isImplicitlyDeclared); |
2490 | } |
2491 | |
2492 | void CXXDestructorDecl::setOperatorDelete(FunctionDecl *OD, Expr *ThisArg) { |
2493 | auto *First = cast<CXXDestructorDecl>(getFirstDecl()); |
2494 | if (OD && !First->OperatorDelete) { |
2495 | First->OperatorDelete = OD; |
2496 | First->OperatorDeleteThisArg = ThisArg; |
2497 | if (auto *L = getASTMutationListener()) |
2498 | L->ResolvedOperatorDelete(First, OD, ThisArg); |
2499 | } |
2500 | } |
2501 | |
2502 | void CXXConversionDecl::anchor() {} |
2503 | |
2504 | CXXConversionDecl * |
2505 | CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2506 | return new (C, ID) CXXConversionDecl(C, nullptr, SourceLocation(), |
2507 | DeclarationNameInfo(), QualType(), |
2508 | nullptr, false, false, false, |
2509 | SourceLocation()); |
2510 | } |
2511 | |
2512 | CXXConversionDecl * |
2513 | CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD, |
2514 | SourceLocation StartLoc, |
2515 | const DeclarationNameInfo &NameInfo, |
2516 | QualType T, TypeSourceInfo *TInfo, |
2517 | bool isInline, bool isExplicit, |
2518 | bool isConstexpr, SourceLocation EndLocation) { |
2519 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXConversionFunctionName && \"Name must refer to a conversion function\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2521, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NameInfo.getName().getNameKind() |
2520 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXConversionFunctionName && \"Name must refer to a conversion function\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2521, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> == DeclarationName::CXXConversionFunctionName && |
2521 | (0) . __assert_fail ("NameInfo.getName().getNameKind() == DeclarationName..CXXConversionFunctionName && \"Name must refer to a conversion function\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2521, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Name must refer to a conversion function"); |
2522 | return new (C, RD) CXXConversionDecl(C, RD, StartLoc, NameInfo, T, TInfo, |
2523 | isInline, isExplicit, isConstexpr, |
2524 | EndLocation); |
2525 | } |
2526 | |
2527 | bool CXXConversionDecl::isLambdaToBlockPointerConversion() const { |
2528 | return isImplicit() && getParent()->isLambda() && |
2529 | getConversionType()->isBlockPointerType(); |
2530 | } |
2531 | |
2532 | LinkageSpecDecl::LinkageSpecDecl(DeclContext *DC, SourceLocation ExternLoc, |
2533 | SourceLocation LangLoc, LanguageIDs lang, |
2534 | bool HasBraces) |
2535 | : Decl(LinkageSpec, DC, LangLoc), DeclContext(LinkageSpec), |
2536 | ExternLoc(ExternLoc), RBraceLoc(SourceLocation()) { |
2537 | setLanguage(lang); |
2538 | LinkageSpecDeclBits.HasBraces = HasBraces; |
2539 | } |
2540 | |
2541 | void LinkageSpecDecl::anchor() {} |
2542 | |
2543 | LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, |
2544 | DeclContext *DC, |
2545 | SourceLocation ExternLoc, |
2546 | SourceLocation LangLoc, |
2547 | LanguageIDs Lang, |
2548 | bool HasBraces) { |
2549 | return new (C, DC) LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, HasBraces); |
2550 | } |
2551 | |
2552 | LinkageSpecDecl *LinkageSpecDecl::CreateDeserialized(ASTContext &C, |
2553 | unsigned ID) { |
2554 | return new (C, ID) LinkageSpecDecl(nullptr, SourceLocation(), |
2555 | SourceLocation(), lang_c, false); |
2556 | } |
2557 | |
2558 | void UsingDirectiveDecl::anchor() {} |
2559 | |
2560 | UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC, |
2561 | SourceLocation L, |
2562 | SourceLocation NamespaceLoc, |
2563 | NestedNameSpecifierLoc QualifierLoc, |
2564 | SourceLocation IdentLoc, |
2565 | NamedDecl *Used, |
2566 | DeclContext *CommonAncestor) { |
2567 | if (auto *NS = dyn_cast_or_null<NamespaceDecl>(Used)) |
2568 | Used = NS->getOriginalNamespace(); |
2569 | return new (C, DC) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierLoc, |
2570 | IdentLoc, Used, CommonAncestor); |
2571 | } |
2572 | |
2573 | UsingDirectiveDecl *UsingDirectiveDecl::CreateDeserialized(ASTContext &C, |
2574 | unsigned ID) { |
2575 | return new (C, ID) UsingDirectiveDecl(nullptr, SourceLocation(), |
2576 | SourceLocation(), |
2577 | NestedNameSpecifierLoc(), |
2578 | SourceLocation(), nullptr, nullptr); |
2579 | } |
2580 | |
2581 | NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() { |
2582 | if (auto *NA = dyn_cast_or_null<NamespaceAliasDecl>(NominatedNamespace)) |
2583 | return NA->getNamespace(); |
2584 | return cast_or_null<NamespaceDecl>(NominatedNamespace); |
2585 | } |
2586 | |
2587 | NamespaceDecl::NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline, |
2588 | SourceLocation StartLoc, SourceLocation IdLoc, |
2589 | IdentifierInfo *Id, NamespaceDecl *PrevDecl) |
2590 | : NamedDecl(Namespace, DC, IdLoc, Id), DeclContext(Namespace), |
2591 | redeclarable_base(C), LocStart(StartLoc), |
2592 | AnonOrFirstNamespaceAndInline(nullptr, Inline) { |
2593 | setPreviousDecl(PrevDecl); |
2594 | |
2595 | if (PrevDecl) |
2596 | AnonOrFirstNamespaceAndInline.setPointer(PrevDecl->getOriginalNamespace()); |
2597 | } |
2598 | |
2599 | NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC, |
2600 | bool Inline, SourceLocation StartLoc, |
2601 | SourceLocation IdLoc, IdentifierInfo *Id, |
2602 | NamespaceDecl *PrevDecl) { |
2603 | return new (C, DC) NamespaceDecl(C, DC, Inline, StartLoc, IdLoc, Id, |
2604 | PrevDecl); |
2605 | } |
2606 | |
2607 | NamespaceDecl *NamespaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2608 | return new (C, ID) NamespaceDecl(C, nullptr, false, SourceLocation(), |
2609 | SourceLocation(), nullptr, nullptr); |
2610 | } |
2611 | |
2612 | NamespaceDecl *NamespaceDecl::getOriginalNamespace() { |
2613 | if (isFirstDecl()) |
2614 | return this; |
2615 | |
2616 | return AnonOrFirstNamespaceAndInline.getPointer(); |
2617 | } |
2618 | |
2619 | const NamespaceDecl *NamespaceDecl::getOriginalNamespace() const { |
2620 | if (isFirstDecl()) |
2621 | return this; |
2622 | |
2623 | return AnonOrFirstNamespaceAndInline.getPointer(); |
2624 | } |
2625 | |
2626 | bool NamespaceDecl::isOriginalNamespace() const { return isFirstDecl(); } |
2627 | |
2628 | NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() { |
2629 | return getNextRedeclaration(); |
2630 | } |
2631 | |
2632 | NamespaceDecl *NamespaceDecl::getPreviousDeclImpl() { |
2633 | return getPreviousDecl(); |
2634 | } |
2635 | |
2636 | NamespaceDecl *NamespaceDecl::getMostRecentDeclImpl() { |
2637 | return getMostRecentDecl(); |
2638 | } |
2639 | |
2640 | void NamespaceAliasDecl::anchor() {} |
2641 | |
2642 | NamespaceAliasDecl *NamespaceAliasDecl::getNextRedeclarationImpl() { |
2643 | return getNextRedeclaration(); |
2644 | } |
2645 | |
2646 | NamespaceAliasDecl *NamespaceAliasDecl::getPreviousDeclImpl() { |
2647 | return getPreviousDecl(); |
2648 | } |
2649 | |
2650 | NamespaceAliasDecl *NamespaceAliasDecl::getMostRecentDeclImpl() { |
2651 | return getMostRecentDecl(); |
2652 | } |
2653 | |
2654 | NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC, |
2655 | SourceLocation UsingLoc, |
2656 | SourceLocation AliasLoc, |
2657 | IdentifierInfo *Alias, |
2658 | NestedNameSpecifierLoc QualifierLoc, |
2659 | SourceLocation IdentLoc, |
2660 | NamedDecl *Namespace) { |
2661 | |
2662 | if (auto *NS = dyn_cast_or_null<NamespaceDecl>(Namespace)) |
2663 | Namespace = NS->getOriginalNamespace(); |
2664 | return new (C, DC) NamespaceAliasDecl(C, DC, UsingLoc, AliasLoc, Alias, |
2665 | QualifierLoc, IdentLoc, Namespace); |
2666 | } |
2667 | |
2668 | NamespaceAliasDecl * |
2669 | NamespaceAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2670 | return new (C, ID) NamespaceAliasDecl(C, nullptr, SourceLocation(), |
2671 | SourceLocation(), nullptr, |
2672 | NestedNameSpecifierLoc(), |
2673 | SourceLocation(), nullptr); |
2674 | } |
2675 | |
2676 | void UsingShadowDecl::anchor() {} |
2677 | |
2678 | UsingShadowDecl::UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, |
2679 | SourceLocation Loc, UsingDecl *Using, |
2680 | NamedDecl *Target) |
2681 | : NamedDecl(K, DC, Loc, Using ? Using->getDeclName() : DeclarationName()), |
2682 | redeclarable_base(C), UsingOrNextShadow(cast<NamedDecl>(Using)) { |
2683 | if (Target) |
2684 | setTargetDecl(Target); |
2685 | setImplicit(); |
2686 | } |
2687 | |
2688 | UsingShadowDecl::UsingShadowDecl(Kind K, ASTContext &C, EmptyShell Empty) |
2689 | : NamedDecl(K, nullptr, SourceLocation(), DeclarationName()), |
2690 | redeclarable_base(C) {} |
2691 | |
2692 | UsingShadowDecl * |
2693 | UsingShadowDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2694 | return new (C, ID) UsingShadowDecl(UsingShadow, C, EmptyShell()); |
2695 | } |
2696 | |
2697 | UsingDecl *UsingShadowDecl::getUsingDecl() const { |
2698 | const UsingShadowDecl *Shadow = this; |
2699 | while (const auto *NextShadow = |
2700 | dyn_cast<UsingShadowDecl>(Shadow->UsingOrNextShadow)) |
2701 | Shadow = NextShadow; |
2702 | return cast<UsingDecl>(Shadow->UsingOrNextShadow); |
2703 | } |
2704 | |
2705 | void ConstructorUsingShadowDecl::anchor() {} |
2706 | |
2707 | ConstructorUsingShadowDecl * |
2708 | ConstructorUsingShadowDecl::Create(ASTContext &C, DeclContext *DC, |
2709 | SourceLocation Loc, UsingDecl *Using, |
2710 | NamedDecl *Target, bool IsVirtual) { |
2711 | return new (C, DC) ConstructorUsingShadowDecl(C, DC, Loc, Using, Target, |
2712 | IsVirtual); |
2713 | } |
2714 | |
2715 | ConstructorUsingShadowDecl * |
2716 | ConstructorUsingShadowDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2717 | return new (C, ID) ConstructorUsingShadowDecl(C, EmptyShell()); |
2718 | } |
2719 | |
2720 | CXXRecordDecl *ConstructorUsingShadowDecl::getNominatedBaseClass() const { |
2721 | return getUsingDecl()->getQualifier()->getAsRecordDecl(); |
2722 | } |
2723 | |
2724 | void UsingDecl::anchor() {} |
2725 | |
2726 | void UsingDecl::addShadowDecl(UsingShadowDecl *S) { |
2727 | (0) . __assert_fail ("std..find(shadow_begin(), shadow_end(), S) == shadow_end() && \"declaration already in set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2728, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(std::find(shadow_begin(), shadow_end(), S) == shadow_end() && |
2728 | (0) . __assert_fail ("std..find(shadow_begin(), shadow_end(), S) == shadow_end() && \"declaration already in set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2728, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "declaration already in set"); |
2729 | getUsingDecl() == this", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2729, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(S->getUsingDecl() == this); |
2730 | |
2731 | if (FirstUsingShadow.getPointer()) |
2732 | S->UsingOrNextShadow = FirstUsingShadow.getPointer(); |
2733 | FirstUsingShadow.setPointer(S); |
2734 | } |
2735 | |
2736 | void UsingDecl::removeShadowDecl(UsingShadowDecl *S) { |
2737 | (0) . __assert_fail ("std..find(shadow_begin(), shadow_end(), S) != shadow_end() && \"declaration not in set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2738, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(std::find(shadow_begin(), shadow_end(), S) != shadow_end() && |
2738 | (0) . __assert_fail ("std..find(shadow_begin(), shadow_end(), S) != shadow_end() && \"declaration not in set\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2738, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "declaration not in set"); |
2739 | getUsingDecl() == this", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2739, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(S->getUsingDecl() == this); |
2740 | |
2741 | |
2742 | |
2743 | if (FirstUsingShadow.getPointer() == S) { |
2744 | FirstUsingShadow.setPointer( |
2745 | dyn_cast<UsingShadowDecl>(S->UsingOrNextShadow)); |
2746 | S->UsingOrNextShadow = this; |
2747 | return; |
2748 | } |
2749 | |
2750 | UsingShadowDecl *Prev = FirstUsingShadow.getPointer(); |
2751 | while (Prev->UsingOrNextShadow != S) |
2752 | Prev = cast<UsingShadowDecl>(Prev->UsingOrNextShadow); |
2753 | Prev->UsingOrNextShadow = S->UsingOrNextShadow; |
2754 | S->UsingOrNextShadow = this; |
2755 | } |
2756 | |
2757 | UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation UL, |
2758 | NestedNameSpecifierLoc QualifierLoc, |
2759 | const DeclarationNameInfo &NameInfo, |
2760 | bool HasTypename) { |
2761 | return new (C, DC) UsingDecl(DC, UL, QualifierLoc, NameInfo, HasTypename); |
2762 | } |
2763 | |
2764 | UsingDecl *UsingDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2765 | return new (C, ID) UsingDecl(nullptr, SourceLocation(), |
2766 | NestedNameSpecifierLoc(), DeclarationNameInfo(), |
2767 | false); |
2768 | } |
2769 | |
2770 | SourceRange UsingDecl::getSourceRange() const { |
2771 | SourceLocation Begin = isAccessDeclaration() |
2772 | ? getQualifierLoc().getBeginLoc() : UsingLocation; |
2773 | return SourceRange(Begin, getNameInfo().getEndLoc()); |
2774 | } |
2775 | |
2776 | void UsingPackDecl::anchor() {} |
2777 | |
2778 | UsingPackDecl *UsingPackDecl::Create(ASTContext &C, DeclContext *DC, |
2779 | NamedDecl *InstantiatedFrom, |
2780 | ArrayRef<NamedDecl *> UsingDecls) { |
2781 | size_t = additionalSizeToAlloc<NamedDecl *>(UsingDecls.size()); |
2782 | return new (C, DC, Extra) UsingPackDecl(DC, InstantiatedFrom, UsingDecls); |
2783 | } |
2784 | |
2785 | UsingPackDecl *UsingPackDecl::CreateDeserialized(ASTContext &C, unsigned ID, |
2786 | unsigned NumExpansions) { |
2787 | size_t = additionalSizeToAlloc<NamedDecl *>(NumExpansions); |
2788 | auto *Result = new (C, ID, Extra) UsingPackDecl(nullptr, nullptr, None); |
2789 | Result->NumExpansions = NumExpansions; |
2790 | auto *Trail = Result->getTrailingObjects<NamedDecl *>(); |
2791 | for (unsigned I = 0; I != NumExpansions; ++I) |
2792 | new (Trail + I) NamedDecl*(nullptr); |
2793 | return Result; |
2794 | } |
2795 | |
2796 | void UnresolvedUsingValueDecl::anchor() {} |
2797 | |
2798 | UnresolvedUsingValueDecl * |
2799 | UnresolvedUsingValueDecl::Create(ASTContext &C, DeclContext *DC, |
2800 | SourceLocation UsingLoc, |
2801 | NestedNameSpecifierLoc QualifierLoc, |
2802 | const DeclarationNameInfo &NameInfo, |
2803 | SourceLocation EllipsisLoc) { |
2804 | return new (C, DC) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc, |
2805 | QualifierLoc, NameInfo, |
2806 | EllipsisLoc); |
2807 | } |
2808 | |
2809 | UnresolvedUsingValueDecl * |
2810 | UnresolvedUsingValueDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2811 | return new (C, ID) UnresolvedUsingValueDecl(nullptr, QualType(), |
2812 | SourceLocation(), |
2813 | NestedNameSpecifierLoc(), |
2814 | DeclarationNameInfo(), |
2815 | SourceLocation()); |
2816 | } |
2817 | |
2818 | SourceRange UnresolvedUsingValueDecl::getSourceRange() const { |
2819 | SourceLocation Begin = isAccessDeclaration() |
2820 | ? getQualifierLoc().getBeginLoc() : UsingLocation; |
2821 | return SourceRange(Begin, getNameInfo().getEndLoc()); |
2822 | } |
2823 | |
2824 | void UnresolvedUsingTypenameDecl::anchor() {} |
2825 | |
2826 | UnresolvedUsingTypenameDecl * |
2827 | UnresolvedUsingTypenameDecl::Create(ASTContext &C, DeclContext *DC, |
2828 | SourceLocation UsingLoc, |
2829 | SourceLocation TypenameLoc, |
2830 | NestedNameSpecifierLoc QualifierLoc, |
2831 | SourceLocation TargetNameLoc, |
2832 | DeclarationName TargetName, |
2833 | SourceLocation EllipsisLoc) { |
2834 | return new (C, DC) UnresolvedUsingTypenameDecl( |
2835 | DC, UsingLoc, TypenameLoc, QualifierLoc, TargetNameLoc, |
2836 | TargetName.getAsIdentifierInfo(), EllipsisLoc); |
2837 | } |
2838 | |
2839 | UnresolvedUsingTypenameDecl * |
2840 | UnresolvedUsingTypenameDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2841 | return new (C, ID) UnresolvedUsingTypenameDecl( |
2842 | nullptr, SourceLocation(), SourceLocation(), NestedNameSpecifierLoc(), |
2843 | SourceLocation(), nullptr, SourceLocation()); |
2844 | } |
2845 | |
2846 | void StaticAssertDecl::anchor() {} |
2847 | |
2848 | StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC, |
2849 | SourceLocation StaticAssertLoc, |
2850 | Expr *AssertExpr, |
2851 | StringLiteral *Message, |
2852 | SourceLocation RParenLoc, |
2853 | bool Failed) { |
2854 | return new (C, DC) StaticAssertDecl(DC, StaticAssertLoc, AssertExpr, Message, |
2855 | RParenLoc, Failed); |
2856 | } |
2857 | |
2858 | StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C, |
2859 | unsigned ID) { |
2860 | return new (C, ID) StaticAssertDecl(nullptr, SourceLocation(), nullptr, |
2861 | nullptr, SourceLocation(), false); |
2862 | } |
2863 | |
2864 | void BindingDecl::anchor() {} |
2865 | |
2866 | BindingDecl *BindingDecl::Create(ASTContext &C, DeclContext *DC, |
2867 | SourceLocation IdLoc, IdentifierInfo *Id) { |
2868 | return new (C, DC) BindingDecl(DC, IdLoc, Id); |
2869 | } |
2870 | |
2871 | BindingDecl *BindingDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
2872 | return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr); |
2873 | } |
2874 | |
2875 | VarDecl *BindingDecl::getHoldingVar() const { |
2876 | Expr *B = getBinding(); |
2877 | if (!B) |
2878 | return nullptr; |
2879 | auto *DRE = dyn_cast<DeclRefExpr>(B->IgnoreImplicit()); |
2880 | if (!DRE) |
2881 | return nullptr; |
2882 | |
2883 | auto *VD = dyn_cast<VarDecl>(DRE->getDecl()); |
2884 | (0) . __assert_fail ("VD->isImplicit() && \"holding var for binding decl not implicit\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclCXX.cpp", 2884, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(VD->isImplicit() && "holding var for binding decl not implicit"); |
2885 | return VD; |
2886 | } |
2887 | |
2888 | void DecompositionDecl::anchor() {} |
2889 | |
2890 | DecompositionDecl *DecompositionDecl::Create(ASTContext &C, DeclContext *DC, |
2891 | SourceLocation StartLoc, |
2892 | SourceLocation LSquareLoc, |
2893 | QualType T, TypeSourceInfo *TInfo, |
2894 | StorageClass SC, |
2895 | ArrayRef<BindingDecl *> Bindings) { |
2896 | size_t = additionalSizeToAlloc<BindingDecl *>(Bindings.size()); |
2897 | return new (C, DC, Extra) |
2898 | DecompositionDecl(C, DC, StartLoc, LSquareLoc, T, TInfo, SC, Bindings); |
2899 | } |
2900 | |
2901 | DecompositionDecl *DecompositionDecl::CreateDeserialized(ASTContext &C, |
2902 | unsigned ID, |
2903 | unsigned NumBindings) { |
2904 | size_t = additionalSizeToAlloc<BindingDecl *>(NumBindings); |
2905 | auto *Result = new (C, ID, Extra) |
2906 | DecompositionDecl(C, nullptr, SourceLocation(), SourceLocation(), |
2907 | QualType(), nullptr, StorageClass(), None); |
2908 | |
2909 | Result->NumBindings = NumBindings; |
2910 | auto *Trail = Result->getTrailingObjects<BindingDecl *>(); |
2911 | for (unsigned I = 0; I != NumBindings; ++I) |
2912 | new (Trail + I) BindingDecl*(nullptr); |
2913 | return Result; |
2914 | } |
2915 | |
2916 | void DecompositionDecl::printName(llvm::raw_ostream &os) const { |
2917 | os << '['; |
2918 | bool Comma = false; |
2919 | for (const auto *B : bindings()) { |
2920 | if (Comma) |
2921 | os << ", "; |
2922 | B->printName(os); |
2923 | Comma = true; |
2924 | } |
2925 | os << ']'; |
2926 | } |
2927 | |
2928 | void MSPropertyDecl::anchor() {} |
2929 | |
2930 | MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC, |
2931 | SourceLocation L, DeclarationName N, |
2932 | QualType T, TypeSourceInfo *TInfo, |
2933 | SourceLocation StartL, |
2934 | IdentifierInfo *Getter, |
2935 | IdentifierInfo *Setter) { |
2936 | return new (C, DC) MSPropertyDecl(DC, L, N, T, TInfo, StartL, Getter, Setter); |
2937 | } |
2938 | |
2939 | MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C, |
2940 | unsigned ID) { |
2941 | return new (C, ID) MSPropertyDecl(nullptr, SourceLocation(), |
2942 | DeclarationName(), QualType(), nullptr, |
2943 | SourceLocation(), nullptr, nullptr); |
2944 | } |
2945 | |
2946 | static const char *getAccessName(AccessSpecifier AS) { |
2947 | switch (AS) { |
2948 | case AS_none: |
2949 | llvm_unreachable("Invalid access specifier!"); |
2950 | case AS_public: |
2951 | return "public"; |
2952 | case AS_private: |
2953 | return "private"; |
2954 | case AS_protected: |
2955 | return "protected"; |
2956 | } |
2957 | llvm_unreachable("Invalid access specifier!"); |
2958 | } |
2959 | |
2960 | const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB, |
2961 | AccessSpecifier AS) { |
2962 | return DB << getAccessName(AS); |
2963 | } |
2964 | |
2965 | const PartialDiagnostic &clang::operator<<(const PartialDiagnostic &DB, |
2966 | AccessSpecifier AS) { |
2967 | return DB << getAccessName(AS); |
2968 | } |
2969 | |