[PATCH] D87080: [AST] Reduce the size of TemplateArgumentLocInfo.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 7 00:00:43 PDT 2020


hokein added inline comments.


================
Comment at: clang/include/clang/AST/TemplateBase.h:429
+      auto *T = getTemplate();
+      T->Ctx->Deallocate(T);
+    }
----------------
sammccall wrote:
> sammccall wrote:
> > this is a no-op, and thus not worth stashing a pointer to Ctx for!
> > 
> > It also doesn't delete T, and it's probably best to do that even if it's (currently) a no-op
> If you're going to destroy T in the destructor, then you can't have trivial copies, as the second one is pointing at deallocated memory.
> (Well, apart from the fact that deallocation does nothing).
> 
> So I think we probably either want:
>  - allocation on ASTContext, trivial copies, no deallocation
>  - allocation on heap, copies reallocate
>  - allocation on heap using shared_ptr
>  - copies disallowed (but I think we rely on them being available)
chose the first one. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87080/new/

https://reviews.llvm.org/D87080



More information about the cfe-commits mailing list