From 8678918d321e6439b535d2c7f4613498b08797f6 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Tue, 4 Oct 2016 23:41:45 +0000 Subject: [PATCH] [CUDA] Destroy deferred diagnostics before destroying the ASTContext's PartialDiagnostic allocator. Summary: This will let us (in a separate patch) allocate deferred diagnostics in the ASTContext's PartialDiagnostic arena. Reviewers: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25260 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283271 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/ASTContext.h | 12 ++++++------ lib/CodeGen/CodeGenModule.cpp | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 0a184bc2e3..7c0d19c56f 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -325,12 +325,6 @@ class ASTContext : public RefCountedBase { }; llvm::DenseMap ModuleInitializers; - /// Diagnostics that are emitted if and only if the given function is - /// codegen'ed. Access these through FunctionDecl::addDeferredDiag() and - /// FunctionDecl::takeDeferredDiags(). - llvm::DenseMap> - DeferredDiags; - public: /// \brief A type synonym for the TemplateOrInstantiation mapping. typedef llvm::PointerUnion @@ -454,6 +448,12 @@ private: /// \brief Allocator for partial diagnostics. PartialDiagnostic::StorageAllocator DiagAllocator; + /// Diagnostics that are emitted if and only if the given function is + /// codegen'ed. Access these through FunctionDecl::addDeferredDiag() and + /// FunctionDecl::takeDeferredDiags(). + llvm::DenseMap> + DeferredDiags; + /// \brief The current C++ ABI. std::unique_ptr ABI; CXXABI *createCXXABI(const TargetInfo &T); diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 9bf3ae2752..845edcd2a1 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -509,6 +509,9 @@ void CodeGenModule::Release() { DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID())); PD.Emit(Builder); } + // Clear the deferred diags so they don't outlive the ASTContext's + // PartialDiagnostic allocator. + DeferredDiags.clear(); } void CodeGenModule::UpdateCompletedType(const TagDecl *TD) { -- 2.40.0