Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Index record hasher #273

Open
wants to merge 7 commits into
base: upstream-with-swift
Choose a base branch
from
4 changes: 3 additions & 1 deletion lib/Index/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_clang_library(clangIndex
IndexDecl.cpp
IndexingAction.cpp
IndexingContext.cpp
IndexRecordHasher.cpp
IndexRecordReader.cpp
IndexRecordWriter.cpp
IndexSymbol.cpp
Expand All @@ -36,4 +35,7 @@ add_clang_library(clangIndex
clangRewrite
clangSerialization
clangToolingCore
clangIndexRecordHasher
)

add_subdirectory(RecordHasher)
7 changes: 3 additions & 4 deletions lib/Index/ClangIndexRecordWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ StringRef ClangIndexRecordWriter::getUSRNonCached(const Decl *D) {

ClangIndexRecordWriter::ClangIndexRecordWriter(ASTContext &Ctx,
RecordingOptions Opts)
: Impl(Opts.DataDirPath), Ctx(Ctx), RecordOpts(std::move(Opts)),
Hasher(Ctx) {
: Impl(Opts.DataDirPath), Ctx(Ctx), RecordOpts(std::move(Opts)) {
if (Opts.RecordSymbolCodeGenName)
CGNameGen.reset(new CodegenNameGenerator(Ctx));
}
Expand All @@ -54,7 +53,8 @@ bool ClangIndexRecordWriter::writeRecord(StringRef Filename,
std::string &Error,
std::string *OutRecordFile) {

auto RecordHash = Hasher.hashRecord(IdxRecord);
ASTContext &Ctx = getASTContext();
auto RecordHash = hashRecord(Ctx, IdxRecord);

switch (Impl.beginRecord(Filename, RecordHash, Error, OutRecordFile)) {
case IndexRecordWriter::Result::Success:
Expand All @@ -65,7 +65,6 @@ bool ClangIndexRecordWriter::writeRecord(StringRef Filename,
return false;
}

ASTContext &Ctx = getASTContext();
SourceManager &SM = Ctx.getSourceManager();
FileID FID = IdxRecord.getFileID();
auto getLineCol = [&](unsigned Offset) -> std::pair<unsigned, unsigned> {
Expand Down
1 change: 0 additions & 1 deletion lib/Index/ClangIndexRecordWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ClangIndexRecordWriter {
std::unique_ptr<CodegenNameGenerator> CGNameGen;
llvm::BumpPtrAllocator Allocator;
llvm::DenseMap<const Decl *, StringRef> USRByDecl;
IndexRecordHasher Hasher;

public:
ClangIndexRecordWriter(ASTContext &Ctx, RecordingOptions Opts);
Expand Down
Loading