This is an archive of the discontinued LLVM Phabricator instance.

[clang] Don't clear AST if we have consumers running after the main action
ClosedPublic

Authored by aeubanks on Oct 20 2021, 3:46 PM.

Details

Summary

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.

Diff Detail

Event Timeline

aeubanks requested review of this revision.Oct 20 2021, 3:46 PM
aeubanks created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2021, 3:46 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dblaikie accepted this revision.Oct 20 2021, 9:10 PM
dblaikie added inline comments.
clang/test/Misc/clear-ast-before-backend-plugins.c
4–9

Can you test that the "consumers running after the main action" are actually running here in a relatively lightweight manner? (ie: in a way that depends on as little details of their behavior as possible, just that they ran)

This revision is now accepted and ready to land.Oct 20 2021, 9:10 PM
hans accepted this revision.Oct 21 2021, 4:58 AM

lgtm

aeubanks added inline comments.Oct 21 2021, 9:02 AM
clang/test/Misc/clear-ast-before-backend-plugins.c
4–9

I don't think so, the only observable behavior is anything the plugin does, and this plugin only prints things. Clang on its own doesn't do much debug logging.

dblaikie added inline comments.Oct 21 2021, 10:55 AM
clang/test/Misc/clear-ast-before-backend-plugins.c
4–9

Sorry, I figured it'd probably be something like that - I just meant testing a fairly vague part of that plugin-specific output (seems you chose a plugin with pretty simple/stable output, so it wouldn't be high maintenance to depend on some parts of its output).

aeubanks added inline comments.Oct 21 2021, 11:08 AM
clang/test/Misc/clear-ast-before-backend-plugins.c
4–9

Ah I can do that.