[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 3 07:24:34 PDT 2025
================
@@ -139,16 +283,17 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
return nullptr;
// If there are no registered plugins we don't need to wrap the consumer
- if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
- return Consumer;
+ if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) {
----------------
ilya-biryukov wrote:
I have also moved the code around in my head, but never actually spelled it out, sorry.
My full suggestion would be:
- move this if to the end of the function after the plugin consumer registrationg is finished.
- right before the final line, do this:
```cpp
assert(Consumers.size() >= 1 && "should have added the main consumer");
if (Consumers.size() == 1)
return std::move(Consumers.front());
return std::make_unique<MultiplexConsumer>(std::move(Consumers));
```
If the only way to produce many consumers is compiler plugins, this shortcut makes sense. Now that we also have this custom logic, I feel it adds another condition that one needs to track and just makes things more error-prone.
https://github.com/llvm/llvm-project/pull/133910
More information about the cfe-commits
mailing list