]> granicus.if.org Git - clang/commitdiff
[CUDA] Destroy deferred diagnostics before destroying the ASTContext's PartialDiagnos...
authorJustin Lebar <jlebar@google.com>
Tue, 4 Oct 2016 23:41:45 +0000 (23:41 +0000)
committerJustin Lebar <jlebar@google.com>
Tue, 4 Oct 2016 23:41:45 +0000 (23:41 +0000)
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
lib/CodeGen/CodeGenModule.cpp

index 0a184bc2e37e765e606b09b4b9bb48e1256c550f..7c0d19c56f9a3a304fb36067e589f5393b11fbb4 100644 (file)
@@ -325,12 +325,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
   };
   llvm::DenseMap<Module*, PerModuleInitializers*> 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<const FunctionDecl *, std::vector<PartialDiagnosticAt>>
-      DeferredDiags;
-
 public:
   /// \brief A type synonym for the TemplateOrInstantiation mapping.
   typedef llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>
@@ -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<const FunctionDecl *, std::vector<PartialDiagnosticAt>>
+      DeferredDiags;
+
   /// \brief The current C++ ABI.
   std::unique_ptr<CXXABI> ABI;
   CXXABI *createCXXABI(const TargetInfo &T);
index 9bf3ae2752f99325315ef1a65a67ef970873ad1f..845edcd2a17203a31e36b12bc20cd42672cb32a7 100644 (file)
@@ -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) {