forked from OSchip/llvm-project
[clangd] Cleanup unneeded use of shared_ptr. NFC
This commit is contained in:
parent
4299d8d0ce
commit
6917f87b3c
|
@ -71,10 +71,10 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
|
||||||
: FIndex(FIndex), ServerCallbacks(ServerCallbacks) {}
|
: FIndex(FIndex), ServerCallbacks(ServerCallbacks) {}
|
||||||
|
|
||||||
void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
|
void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
|
||||||
std::shared_ptr<clang::Preprocessor> PP,
|
Preprocessor &PP,
|
||||||
const CanonicalIncludes &CanonIncludes) override {
|
const CanonicalIncludes &CanonIncludes) override {
|
||||||
if (FIndex)
|
if (FIndex)
|
||||||
FIndex->updatePreamble(Path, Version, Ctx, std::move(PP), CanonIncludes);
|
FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {
|
void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {
|
||||||
|
|
|
@ -84,8 +84,7 @@ public:
|
||||||
void AfterExecute(CompilerInstance &CI) override {
|
void AfterExecute(CompilerInstance &CI) override {
|
||||||
if (ParsedCallback) {
|
if (ParsedCallback) {
|
||||||
trace::Span Tracer("Running PreambleCallback");
|
trace::Span Tracer("Running PreambleCallback");
|
||||||
ParsedCallback(CI.getASTContext(), CI.getPreprocessorPtr(),
|
ParsedCallback(CI.getASTContext(), CI.getPreprocessor(), CanonIncludes);
|
||||||
CanonIncludes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SourceManager &SM = CI.getSourceManager();
|
const SourceManager &SM = CI.getSourceManager();
|
||||||
|
|
|
@ -72,9 +72,8 @@ struct PreambleData {
|
||||||
bool MainIsIncludeGuarded = false;
|
bool MainIsIncludeGuarded = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
using PreambleParsedCallback =
|
using PreambleParsedCallback = std::function<void(ASTContext &, Preprocessor &,
|
||||||
std::function<void(ASTContext &, std::shared_ptr<clang::Preprocessor>,
|
const CanonicalIncludes &)>;
|
||||||
const CanonicalIncludes &)>;
|
|
||||||
|
|
||||||
/// Build a preamble for the new inputs unless an old one can be reused.
|
/// Build a preamble for the new inputs unless an old one can be reused.
|
||||||
/// If \p PreambleCallback is set, it will be run on top of the AST while
|
/// If \p PreambleCallback is set, it will be run on top of the AST while
|
||||||
|
|
|
@ -977,11 +977,9 @@ void PreambleThread::build(Request Req) {
|
||||||
|
|
||||||
LatestBuild = clang::clangd::buildPreamble(
|
LatestBuild = clang::clangd::buildPreamble(
|
||||||
FileName, *Req.CI, Inputs, StoreInMemory,
|
FileName, *Req.CI, Inputs, StoreInMemory,
|
||||||
[this, Version(Inputs.Version)](ASTContext &Ctx,
|
[this, Version(Inputs.Version)](ASTContext &Ctx, Preprocessor &PP,
|
||||||
std::shared_ptr<clang::Preprocessor> PP,
|
|
||||||
const CanonicalIncludes &CanonIncludes) {
|
const CanonicalIncludes &CanonIncludes) {
|
||||||
Callbacks.onPreambleAST(FileName, Version, Ctx, std::move(PP),
|
Callbacks.onPreambleAST(FileName, Version, Ctx, PP, CanonIncludes);
|
||||||
CanonIncludes);
|
|
||||||
});
|
});
|
||||||
if (LatestBuild && isReliable(LatestBuild->CompileCommand))
|
if (LatestBuild && isReliable(LatestBuild->CompileCommand))
|
||||||
HeaderIncluders.update(FileName, LatestBuild->Includes.allHeaders());
|
HeaderIncluders.update(FileName, LatestBuild->Includes.allHeaders());
|
||||||
|
|
|
@ -134,8 +134,7 @@ public:
|
||||||
/// contains only AST nodes from the #include directives at the start of the
|
/// contains only AST nodes from the #include directives at the start of the
|
||||||
/// file. AST node in the current file should be observed on onMainAST call.
|
/// file. AST node in the current file should be observed on onMainAST call.
|
||||||
virtual void onPreambleAST(PathRef Path, llvm::StringRef Version,
|
virtual void onPreambleAST(PathRef Path, llvm::StringRef Version,
|
||||||
ASTContext &Ctx,
|
ASTContext &Ctx, Preprocessor &PP,
|
||||||
std::shared_ptr<clang::Preprocessor> PP,
|
|
||||||
const CanonicalIncludes &) {}
|
const CanonicalIncludes &) {}
|
||||||
|
|
||||||
/// The argument function is run under the critical section guarding against
|
/// The argument function is run under the critical section guarding against
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace clang {
|
||||||
namespace clangd {
|
namespace clangd {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
|
SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
|
||||||
llvm::ArrayRef<Decl *> DeclsToIndex,
|
llvm::ArrayRef<Decl *> DeclsToIndex,
|
||||||
const MainFileMacros *MacroRefsToIndex,
|
const MainFileMacros *MacroRefsToIndex,
|
||||||
const CanonicalIncludes &Includes, bool IsIndexMainAST,
|
const CanonicalIncludes &Includes, bool IsIndexMainAST,
|
||||||
|
@ -77,7 +77,7 @@ SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
|
||||||
|
|
||||||
SymbolCollector Collector(std::move(CollectorOpts));
|
SymbolCollector Collector(std::move(CollectorOpts));
|
||||||
Collector.setPreprocessor(PP);
|
Collector.setPreprocessor(PP);
|
||||||
index::indexTopLevelDecls(AST, *PP, DeclsToIndex, Collector, IndexOpts);
|
index::indexTopLevelDecls(AST, PP, DeclsToIndex, Collector, IndexOpts);
|
||||||
if (MacroRefsToIndex)
|
if (MacroRefsToIndex)
|
||||||
Collector.handleMacros(*MacroRefsToIndex);
|
Collector.handleMacros(*MacroRefsToIndex);
|
||||||
|
|
||||||
|
@ -219,18 +219,18 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
|
||||||
|
|
||||||
SlabTuple indexMainDecls(ParsedAST &AST) {
|
SlabTuple indexMainDecls(ParsedAST &AST) {
|
||||||
return indexSymbols(
|
return indexSymbols(
|
||||||
AST.getASTContext(), AST.getPreprocessorPtr(),
|
AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
|
||||||
AST.getLocalTopLevelDecls(), &AST.getMacros(), AST.getCanonicalIncludes(),
|
&AST.getMacros(), AST.getCanonicalIncludes(),
|
||||||
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
|
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
|
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
|
||||||
std::shared_ptr<Preprocessor> PP,
|
Preprocessor &PP,
|
||||||
const CanonicalIncludes &Includes) {
|
const CanonicalIncludes &Includes) {
|
||||||
std::vector<Decl *> DeclsToIndex(
|
std::vector<Decl *> DeclsToIndex(
|
||||||
AST.getTranslationUnitDecl()->decls().begin(),
|
AST.getTranslationUnitDecl()->decls().begin(),
|
||||||
AST.getTranslationUnitDecl()->decls().end());
|
AST.getTranslationUnitDecl()->decls().end());
|
||||||
return indexSymbols(AST, std::move(PP), DeclsToIndex,
|
return indexSymbols(AST, PP, DeclsToIndex,
|
||||||
/*MainFileMacros=*/nullptr, Includes,
|
/*MainFileMacros=*/nullptr, Includes,
|
||||||
/*IsIndexMainAST=*/false, Version,
|
/*IsIndexMainAST=*/false, Version,
|
||||||
/*CollectMainFileRefs=*/false);
|
/*CollectMainFileRefs=*/false);
|
||||||
|
@ -424,12 +424,11 @@ FileIndex::FileIndex()
|
||||||
MainFileIndex(std::make_unique<MemIndex>()) {}
|
MainFileIndex(std::make_unique<MemIndex>()) {}
|
||||||
|
|
||||||
void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
|
void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
|
||||||
ASTContext &AST,
|
ASTContext &AST, Preprocessor &PP,
|
||||||
std::shared_ptr<Preprocessor> PP,
|
|
||||||
const CanonicalIncludes &Includes) {
|
const CanonicalIncludes &Includes) {
|
||||||
IndexFileIn IF;
|
IndexFileIn IF;
|
||||||
std::tie(IF.Symbols, std::ignore, IF.Relations) =
|
std::tie(IF.Symbols, std::ignore, IF.Relations) =
|
||||||
indexHeaderSymbols(Version, AST, std::move(PP), Includes);
|
indexHeaderSymbols(Version, AST, PP, Includes);
|
||||||
FileShardedIndex ShardedIndex(std::move(IF));
|
FileShardedIndex ShardedIndex(std::move(IF));
|
||||||
for (auto Uri : ShardedIndex.getAllSources()) {
|
for (auto Uri : ShardedIndex.getAllSources()) {
|
||||||
auto IF = ShardedIndex.getShard(Uri);
|
auto IF = ShardedIndex.getShard(Uri);
|
||||||
|
|
|
@ -115,8 +115,7 @@ public:
|
||||||
/// Update preamble symbols of file \p Path with all declarations in \p AST
|
/// Update preamble symbols of file \p Path with all declarations in \p AST
|
||||||
/// and macros in \p PP.
|
/// and macros in \p PP.
|
||||||
void updatePreamble(PathRef Path, llvm::StringRef Version, ASTContext &AST,
|
void updatePreamble(PathRef Path, llvm::StringRef Version, ASTContext &AST,
|
||||||
std::shared_ptr<Preprocessor> PP,
|
Preprocessor &PP, const CanonicalIncludes &Includes);
|
||||||
const CanonicalIncludes &Includes);
|
|
||||||
|
|
||||||
/// Update symbols and references from main file \p Path with
|
/// Update symbols and references from main file \p Path with
|
||||||
/// `indexMainDecls`.
|
/// `indexMainDecls`.
|
||||||
|
@ -163,7 +162,7 @@ SlabTuple indexMainDecls(ParsedAST &AST);
|
||||||
/// Index declarations from \p AST and macros from \p PP that are declared in
|
/// Index declarations from \p AST and macros from \p PP that are declared in
|
||||||
/// included headers.
|
/// included headers.
|
||||||
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
|
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
|
||||||
std::shared_ptr<Preprocessor> PP,
|
Preprocessor &PP,
|
||||||
const CanonicalIncludes &Includes);
|
const CanonicalIncludes &Includes);
|
||||||
|
|
||||||
/// Takes slabs coming from a TU (multiple files) and shards them per
|
/// Takes slabs coming from a TU (multiple files) and shards them per
|
||||||
|
|
|
@ -186,7 +186,7 @@ class SymbolCollector::HeaderFileURICache {
|
||||||
// Weird double-indirect access to PP, which might not be ready yet when
|
// Weird double-indirect access to PP, which might not be ready yet when
|
||||||
// HeaderFiles is created but will be by the time it's used.
|
// HeaderFiles is created but will be by the time it's used.
|
||||||
// (IndexDataConsumer::setPreprocessor can happen before or after initialize)
|
// (IndexDataConsumer::setPreprocessor can happen before or after initialize)
|
||||||
const std::shared_ptr<Preprocessor> &PP;
|
Preprocessor *&PP;
|
||||||
const SourceManager &SM;
|
const SourceManager &SM;
|
||||||
const CanonicalIncludes *Includes;
|
const CanonicalIncludes *Includes;
|
||||||
llvm::StringRef FallbackDir;
|
llvm::StringRef FallbackDir;
|
||||||
|
@ -195,8 +195,7 @@ class SymbolCollector::HeaderFileURICache {
|
||||||
llvm::DenseMap<FileID, llvm::StringRef> CacheFIDToInclude;
|
llvm::DenseMap<FileID, llvm::StringRef> CacheFIDToInclude;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HeaderFileURICache(const std::shared_ptr<Preprocessor> &PP,
|
HeaderFileURICache(Preprocessor *&PP, const SourceManager &SM,
|
||||||
const SourceManager &SM,
|
|
||||||
const SymbolCollector::Options &Opts)
|
const SymbolCollector::Options &Opts)
|
||||||
: PP(PP), SM(SM), Includes(Opts.Includes), FallbackDir(Opts.FallbackDir) {
|
: PP(PP), SM(SM), Includes(Opts.Includes), FallbackDir(Opts.FallbackDir) {
|
||||||
}
|
}
|
||||||
|
@ -304,7 +303,7 @@ SymbolCollector::~SymbolCollector() = default;
|
||||||
void SymbolCollector::initialize(ASTContext &Ctx) {
|
void SymbolCollector::initialize(ASTContext &Ctx) {
|
||||||
ASTCtx = &Ctx;
|
ASTCtx = &Ctx;
|
||||||
HeaderFileURIs = std::make_unique<HeaderFileURICache>(
|
HeaderFileURIs = std::make_unique<HeaderFileURICache>(
|
||||||
PP, ASTCtx->getSourceManager(), Opts);
|
this->PP, ASTCtx->getSourceManager(), Opts);
|
||||||
CompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
|
CompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
|
||||||
CompletionTUInfo =
|
CompletionTUInfo =
|
||||||
std::make_unique<CodeCompletionTUInfo>(CompletionAllocator);
|
std::make_unique<CodeCompletionTUInfo>(CompletionAllocator);
|
||||||
|
@ -365,7 +364,7 @@ bool SymbolCollector::handleDeclOccurrence(
|
||||||
const Decl *D, index::SymbolRoleSet Roles,
|
const Decl *D, index::SymbolRoleSet Roles,
|
||||||
llvm::ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc,
|
llvm::ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc,
|
||||||
index::IndexDataConsumer::ASTNodeInfo ASTNode) {
|
index::IndexDataConsumer::ASTNodeInfo ASTNode) {
|
||||||
assert(ASTCtx && PP.get() && HeaderFileURIs);
|
assert(ASTCtx && PP && HeaderFileURIs);
|
||||||
assert(CompletionAllocator && CompletionTUInfo);
|
assert(CompletionAllocator && CompletionTUInfo);
|
||||||
assert(ASTNode.OrigD);
|
assert(ASTNode.OrigD);
|
||||||
// Indexing API puts canonical decl into D, which might not have a valid
|
// Indexing API puts canonical decl into D, which might not have a valid
|
||||||
|
@ -486,7 +485,7 @@ bool SymbolCollector::handleDeclOccurrence(
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
|
void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
|
||||||
assert(HeaderFileURIs && PP.get());
|
assert(HeaderFileURIs && PP);
|
||||||
const auto &SM = PP->getSourceManager();
|
const auto &SM = PP->getSourceManager();
|
||||||
const auto *MainFileEntry = SM.getFileEntryForID(SM.getMainFileID());
|
const auto *MainFileEntry = SM.getFileEntryForID(SM.getMainFileID());
|
||||||
assert(MainFileEntry);
|
assert(MainFileEntry);
|
||||||
|
@ -533,7 +532,7 @@ bool SymbolCollector::handleMacroOccurrence(const IdentifierInfo *Name,
|
||||||
const MacroInfo *MI,
|
const MacroInfo *MI,
|
||||||
index::SymbolRoleSet Roles,
|
index::SymbolRoleSet Roles,
|
||||||
SourceLocation Loc) {
|
SourceLocation Loc) {
|
||||||
assert(PP.get());
|
assert(PP);
|
||||||
// Builtin macros don't have useful locations and aren't needed in completion.
|
// Builtin macros don't have useful locations and aren't needed in completion.
|
||||||
if (MI->isBuiltinMacro())
|
if (MI->isBuiltinMacro())
|
||||||
return true;
|
return true;
|
||||||
|
@ -805,7 +804,7 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
|
||||||
|
|
||||||
// Add completion info.
|
// Add completion info.
|
||||||
// FIXME: we may want to choose a different redecl, or combine from several.
|
// FIXME: we may want to choose a different redecl, or combine from several.
|
||||||
assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
|
assert(ASTCtx && PP && "ASTContext and Preprocessor must be set.");
|
||||||
// We use the primary template, as clang does during code completion.
|
// We use the primary template, as clang does during code completion.
|
||||||
CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
|
CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
|
||||||
const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
|
const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
|
||||||
|
|
|
@ -100,8 +100,9 @@ public:
|
||||||
void initialize(ASTContext &Ctx) override;
|
void initialize(ASTContext &Ctx) override;
|
||||||
|
|
||||||
void setPreprocessor(std::shared_ptr<Preprocessor> PP) override {
|
void setPreprocessor(std::shared_ptr<Preprocessor> PP) override {
|
||||||
this->PP = std::move(PP);
|
this->PP = PP.get();
|
||||||
}
|
}
|
||||||
|
void setPreprocessor(Preprocessor &PP) { this->PP = &PP; }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
|
handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
|
||||||
|
@ -153,7 +154,7 @@ private:
|
||||||
// All relations collected from the AST.
|
// All relations collected from the AST.
|
||||||
RelationSlab::Builder Relations;
|
RelationSlab::Builder Relations;
|
||||||
ASTContext *ASTCtx;
|
ASTContext *ASTCtx;
|
||||||
std::shared_ptr<Preprocessor> PP;
|
Preprocessor *PP = nullptr;
|
||||||
std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
|
std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
|
||||||
std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
|
std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
|
||||||
Options Opts;
|
Options Opts;
|
||||||
|
|
|
@ -159,16 +159,15 @@ public:
|
||||||
// Build preamble and AST, and index them.
|
// Build preamble and AST, and index them.
|
||||||
bool buildAST() {
|
bool buildAST() {
|
||||||
log("Building preamble...");
|
log("Building preamble...");
|
||||||
Preamble =
|
Preamble = buildPreamble(File, *Invocation, Inputs, /*StoreInMemory=*/true,
|
||||||
buildPreamble(File, *Invocation, Inputs, /*StoreInMemory=*/true,
|
[&](ASTContext &Ctx, Preprocessor &PP,
|
||||||
[&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP,
|
const CanonicalIncludes &Includes) {
|
||||||
const CanonicalIncludes &Includes) {
|
if (!Opts.BuildDynamicSymbolIndex)
|
||||||
if (!Opts.BuildDynamicSymbolIndex)
|
return;
|
||||||
return;
|
log("Indexing headers...");
|
||||||
log("Indexing headers...");
|
Index.updatePreamble(File, /*Version=*/"null",
|
||||||
Index.updatePreamble(File, /*Version=*/"null", Ctx,
|
Ctx, PP, Includes);
|
||||||
std::move(PP), Includes);
|
});
|
||||||
});
|
|
||||||
if (!Preamble) {
|
if (!Preamble) {
|
||||||
elog("Failed to build preamble");
|
elog("Failed to build preamble");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -173,7 +173,7 @@ void update(FileIndex &M, llvm::StringRef Basename, llvm::StringRef Code) {
|
||||||
File.HeaderCode = std::string(Code);
|
File.HeaderCode = std::string(Code);
|
||||||
auto AST = File.build();
|
auto AST = File.build();
|
||||||
M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
|
M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
|
||||||
AST.getASTContext(), AST.getPreprocessorPtr(),
|
AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getCanonicalIncludes());
|
AST.getCanonicalIncludes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,13 +310,13 @@ TEST(FileIndexTest, RebuildWithPreamble) {
|
||||||
bool IndexUpdated = false;
|
bool IndexUpdated = false;
|
||||||
buildPreamble(FooCpp, *CI, PI,
|
buildPreamble(FooCpp, *CI, PI,
|
||||||
/*StoreInMemory=*/true,
|
/*StoreInMemory=*/true,
|
||||||
[&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP,
|
[&](ASTContext &Ctx, Preprocessor &PP,
|
||||||
const CanonicalIncludes &CanonIncludes) {
|
const CanonicalIncludes &CanonIncludes) {
|
||||||
EXPECT_FALSE(IndexUpdated)
|
EXPECT_FALSE(IndexUpdated)
|
||||||
<< "Expected only a single index update";
|
<< "Expected only a single index update";
|
||||||
IndexUpdated = true;
|
IndexUpdated = true;
|
||||||
Index.updatePreamble(FooCpp, /*Version=*/"null", Ctx,
|
Index.updatePreamble(FooCpp, /*Version=*/"null", Ctx, PP,
|
||||||
std::move(PP), CanonIncludes);
|
CanonIncludes);
|
||||||
});
|
});
|
||||||
ASSERT_TRUE(IndexUpdated);
|
ASSERT_TRUE(IndexUpdated);
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ TEST(FileIndexTest, Relations) {
|
||||||
auto AST = TU.build();
|
auto AST = TU.build();
|
||||||
FileIndex Index;
|
FileIndex Index;
|
||||||
Index.updatePreamble(testPath(TU.Filename), /*Version=*/"null",
|
Index.updatePreamble(testPath(TU.Filename), /*Version=*/"null",
|
||||||
AST.getASTContext(), AST.getPreprocessorPtr(),
|
AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getCanonicalIncludes());
|
AST.getCanonicalIncludes());
|
||||||
SymbolID A = findSymbol(TU.headerSymbols(), "A").ID;
|
SymbolID A = findSymbol(TU.headerSymbols(), "A").ID;
|
||||||
uint32_t Results = 0;
|
uint32_t Results = 0;
|
||||||
|
@ -537,7 +537,7 @@ TEST(FileIndexTest, StalePreambleSymbolsDeleted) {
|
||||||
File.HeaderCode = "int a;";
|
File.HeaderCode = "int a;";
|
||||||
auto AST = File.build();
|
auto AST = File.build();
|
||||||
M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
|
M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
|
||||||
AST.getASTContext(), AST.getPreprocessorPtr(),
|
AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getCanonicalIncludes());
|
AST.getCanonicalIncludes());
|
||||||
EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("a")));
|
EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("a")));
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ TEST(FileIndexTest, StalePreambleSymbolsDeleted) {
|
||||||
File.HeaderCode = "int b;";
|
File.HeaderCode = "int b;";
|
||||||
AST = File.build();
|
AST = File.build();
|
||||||
M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
|
M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
|
||||||
AST.getASTContext(), AST.getPreprocessorPtr(),
|
AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getCanonicalIncludes());
|
AST.getCanonicalIncludes());
|
||||||
EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("b")));
|
EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("b")));
|
||||||
}
|
}
|
||||||
|
@ -690,8 +690,8 @@ TEST(FileIndexTest, Profile) {
|
||||||
auto FileName = testPath("foo.cpp");
|
auto FileName = testPath("foo.cpp");
|
||||||
auto AST = TestTU::withHeaderCode("int a;").build();
|
auto AST = TestTU::withHeaderCode("int a;").build();
|
||||||
FI.updateMain(FileName, AST);
|
FI.updateMain(FileName, AST);
|
||||||
FI.updatePreamble(FileName, "v1", AST.getASTContext(),
|
FI.updatePreamble(FileName, "v1", AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
|
AST.getCanonicalIncludes());
|
||||||
|
|
||||||
llvm::BumpPtrAllocator Alloc;
|
llvm::BumpPtrAllocator Alloc;
|
||||||
MemoryTree MT(&Alloc);
|
MemoryTree MT(&Alloc);
|
||||||
|
|
|
@ -1122,8 +1122,7 @@ TEST_F(TUSchedulerTests, AsyncPreambleThread) {
|
||||||
BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
|
BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
|
||||||
: BlockVersion(BlockVersion), N(N) {}
|
: BlockVersion(BlockVersion), N(N) {}
|
||||||
void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
|
void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
|
||||||
std::shared_ptr<clang::Preprocessor> PP,
|
Preprocessor &, const CanonicalIncludes &) override {
|
||||||
const CanonicalIncludes &) override {
|
|
||||||
if (Version == BlockVersion)
|
if (Version == BlockVersion)
|
||||||
N.wait();
|
N.wait();
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ ParsedAST TestTU::build() const {
|
||||||
SymbolSlab TestTU::headerSymbols() const {
|
SymbolSlab TestTU::headerSymbols() const {
|
||||||
auto AST = build();
|
auto AST = build();
|
||||||
return std::get<0>(indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
|
return std::get<0>(indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
|
||||||
AST.getPreprocessorPtr(),
|
AST.getPreprocessor(),
|
||||||
AST.getCanonicalIncludes()));
|
AST.getCanonicalIncludes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ std::unique_ptr<SymbolIndex> TestTU::index() const {
|
||||||
auto AST = build();
|
auto AST = build();
|
||||||
auto Idx = std::make_unique<FileIndex>();
|
auto Idx = std::make_unique<FileIndex>();
|
||||||
Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
|
Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
|
||||||
AST.getASTContext(), AST.getPreprocessorPtr(),
|
AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getCanonicalIncludes());
|
AST.getCanonicalIncludes());
|
||||||
Idx->updateMain(testPath(Filename), AST);
|
Idx->updateMain(testPath(Filename), AST);
|
||||||
return std::move(Idx);
|
return std::move(Idx);
|
||||||
|
|
|
@ -19,7 +19,7 @@ std::unique_ptr<SymbolIndex> TestWorkspace::index() {
|
||||||
continue;
|
continue;
|
||||||
TU.Code = Input.second.Code;
|
TU.Code = Input.second.Code;
|
||||||
TU.Filename = Input.first().str();
|
TU.Filename = Input.first().str();
|
||||||
TU.preamble([&](ASTContext &Ctx, std::shared_ptr<clang::Preprocessor> PP,
|
TU.preamble([&](ASTContext &Ctx, Preprocessor &PP,
|
||||||
const CanonicalIncludes &CanonIncludes) {
|
const CanonicalIncludes &CanonIncludes) {
|
||||||
Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
|
Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
|
||||||
CanonIncludes);
|
CanonIncludes);
|
||||||
|
|
Loading…
Reference in New Issue