[PATCH] D111767: [clang] Support -clear-ast-before-backend without -disable-free

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 13 23:06:20 PDT 2021


dblaikie added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenAction.cpp:355-356
+      if (CodeGenOpts.ClearASTBeforeBackend) {
+        // The ASTContext may be unusable after this.
+        C.cleanup();
         C.getAllocator().Reset();
----------------
Any chance of refactoring such that the ASTContext is scoped such that it is destroyed here, rather than rendered unusable - to reduce the chance that it'd be accidentally used after this point?

Like what happens if CompilerInstance::setASTContext(nullptr) is called? It wouldn't null out everyone's ASTContext pointers, but would mean there's no object there - perhaps crash harder/faster than a "cleaned up" ASTContext being used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111767



More information about the cfe-commits mailing list