@@ -3365,23 +3365,30 @@ APValue &MSGuidDecl::getAsAPValue() const {
3365
3365
3366
3366
void UnnamedGlobalConstantDecl::anchor () {}
3367
3367
3368
- UnnamedGlobalConstantDecl::UnnamedGlobalConstantDecl (DeclContext *DC,
3368
+ UnnamedGlobalConstantDecl::UnnamedGlobalConstantDecl (const ASTContext &C,
3369
+ DeclContext *DC,
3369
3370
QualType Ty,
3370
- const APValue &Value )
3371
+ const APValue &Val )
3371
3372
: ValueDecl(Decl::UnnamedGlobalConstant, DC, SourceLocation(),
3372
3373
DeclarationName(), Ty),
3373
- Value(Value) {}
3374
+ Value(Val) {
3375
+ // Cleanup the embedded APValue if required (note that our destructor is never
3376
+ // run)
3377
+ if (Value.needsCleanup ())
3378
+ C.addDestruction (&Value);
3379
+ }
3374
3380
3375
3381
UnnamedGlobalConstantDecl *
3376
3382
UnnamedGlobalConstantDecl::Create (const ASTContext &C, QualType T,
3377
3383
const APValue &Value) {
3378
3384
DeclContext *DC = C.getTranslationUnitDecl ();
3379
- return new (C, DC) UnnamedGlobalConstantDecl (DC, T, Value);
3385
+ return new (C, DC) UnnamedGlobalConstantDecl (C, DC, T, Value);
3380
3386
}
3381
3387
3382
3388
UnnamedGlobalConstantDecl *
3383
3389
UnnamedGlobalConstantDecl::CreateDeserialized (ASTContext &C, unsigned ID) {
3384
- return new (C, ID) UnnamedGlobalConstantDecl (nullptr , QualType (), APValue ());
3390
+ return new (C, ID)
3391
+ UnnamedGlobalConstantDecl (C, nullptr , QualType (), APValue ());
3385
3392
}
3386
3393
3387
3394
void UnnamedGlobalConstantDecl::printName (llvm::raw_ostream &OS) const {
0 commit comments