[clang] Don't clear AST if we have consumers running after the main action
authorArthur Eubanks <aeubanks@google.com>
Wed, 20 Oct 2021 22:43:10 +0000 (15:43 -0700)
committerArthur Eubanks <aeubanks@google.com>
Thu, 21 Oct 2021 16:03:57 +0000 (09:03 -0700)
commit2dcad7754a204d5dbb78fef8f6b13cd005456e33
tree7421630d2dcac1fd76a68f8eb3c1db0764f51358
parentb8da594750762f811283820c19b02cedfb6632d4
[clang] Don't clear AST if we have consumers running after the main action

Downstream users may have Clang plugins. By default these plugins run
after the main action if they are specified on the command line.

Since these plugins are ASTConsumers, presumably they inspect the AST.
So we shouldn't clear it if any plugins run after the main action.

Reviewed By: dblaikie, hans

Differential Revision: https://reviews.llvm.org/D112190
clang/lib/Frontend/FrontendAction.cpp
clang/test/Misc/clear-ast-before-backend-plugins.c [new file with mode: 0644]