summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-include-fixer
diff options
context:
space:
mode:
authorChris Bieneman <chris.bieneman@me.com>2022-09-01 16:31:23 -0500
committerChris Bieneman <chris.bieneman@me.com>2022-09-02 13:57:39 -0500
commit5b5329bd41ba977459fcd7abb7cf438fd98c98e0 (patch)
tree5bf4a8bc736e4856001d32a74339e2ee96fd8a5b /clang-tools-extra/clang-include-fixer
parent1491282165bfb87b15bd806ab53b3e9910ee7b29 (diff)
downloadllvm-5b5329bd41ba977459fcd7abb7cf438fd98c98e0.tar.gz
[NFC] Make MultiplexExternalSemaSource own sources
This change refactors the MuiltiplexExternalSemaSource to take ownership of the underlying sources. As a result it makes a larger cleanup of external source ownership in Sema and the ChainedIncludesSource. Reviewed By: aaron.ballman, aprantl Differential Revision: https://reviews.llvm.org/D133158
Diffstat (limited to 'clang-tools-extra/clang-include-fixer')
-rw-r--r--clang-tools-extra/clang-include-fixer/IncludeFixer.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
index 2af1f622aa92..45fc15619eca 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
@@ -27,13 +27,14 @@ namespace {
class Action : public clang::ASTFrontendAction {
public:
explicit Action(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths)
- : SemaSource(SymbolIndexMgr, MinimizeIncludePaths,
- /*GenerateDiagnostics=*/false) {}
+ : SemaSource(new IncludeFixerSemaSource(SymbolIndexMgr,
+ MinimizeIncludePaths,
+ /*GenerateDiagnostics=*/false)) {}
std::unique_ptr<clang::ASTConsumer>
CreateASTConsumer(clang::CompilerInstance &Compiler,
StringRef InFile) override {
- SemaSource.setFilePath(InFile);
+ SemaSource->setFilePath(InFile);
return std::make_unique<clang::ASTConsumer>();
}
@@ -51,8 +52,8 @@ public:
CompletionConsumer = &Compiler->getCodeCompletionConsumer();
Compiler->createSema(getTranslationUnitKind(), CompletionConsumer);
- SemaSource.setCompilerInstance(Compiler);
- Compiler->getSema().addExternalSource(&SemaSource);
+ SemaSource->setCompilerInstance(Compiler);
+ Compiler->getSema().addExternalSource(SemaSource.get());
clang::ParseAST(Compiler->getSema(), Compiler->getFrontendOpts().ShowStats,
Compiler->getFrontendOpts().SkipFunctionBodies);
@@ -61,12 +62,12 @@ public:
IncludeFixerContext
getIncludeFixerContext(const clang::SourceManager &SourceManager,
clang::HeaderSearch &HeaderSearch) const {
- return SemaSource.getIncludeFixerContext(SourceManager, HeaderSearch,
- SemaSource.getMatchedSymbols());
+ return SemaSource->getIncludeFixerContext(SourceManager, HeaderSearch,
+ SemaSource->getMatchedSymbols());
}
private:
- IncludeFixerSemaSource SemaSource;
+ IntrusiveRefCntPtr<IncludeFixerSemaSource> SemaSource;
};
} // namespace