[PATCH] D25260: [CUDA] Destroy deferred diagnostics before destroying the ASTContext's PartialDiagnostic allocator.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 16:16:12 PDT 2016


jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added a subscriber: cfe-commits.

This will let us (in a separate patch) allocate deferred diagnostics in
the ASTContext's PartialDiagnostic arena.


https://reviews.llvm.org/D25260

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -509,6 +509,9 @@
     DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
     PD.Emit(Builder);
   }
+  // Clear the deferred diags so they don't outlive the ASTContext from whence
+  // they're allocated.
+  DeferredDiags.clear();
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
Index: clang/include/clang/AST/ASTContext.h
===================================================================
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -325,12 +325,6 @@
   };
   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 @@
   /// \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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25260.73575.patch
Type: text/x-patch
Size: 1778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161004/b2f3126c/attachment.bin>


More information about the cfe-commits mailing list