aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp')
-rw-r--r--contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp b/contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp
index 11ace84b9ceb..de1ddab88fd4 100644
--- a/contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp
+++ b/contrib/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp
@@ -96,13 +96,18 @@ ModuleSummaryIndexObjectFile::create(MemoryBufferRef Object) {
// Parse the module summary index out of an IR file and return the summary
// index object if found, or nullptr if not.
Expected<std::unique_ptr<ModuleSummaryIndex>>
-llvm::getModuleSummaryIndexForFile(StringRef Path) {
+llvm::getModuleSummaryIndexForFile(StringRef Path, StringRef Identifier) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
MemoryBuffer::getFileOrSTDIN(Path);
std::error_code EC = FileOrErr.getError();
if (EC)
return errorCodeToError(EC);
- MemoryBufferRef BufferRef = (FileOrErr.get())->getMemBufferRef();
+ std::unique_ptr<MemoryBuffer> MemBuffer = std::move(FileOrErr.get());
+ // If Identifier is non-empty, use it as the buffer identifier, which
+ // will become the module path in the index.
+ if (Identifier.empty())
+ Identifier = MemBuffer->getBufferIdentifier();
+ MemoryBufferRef BufferRef(MemBuffer->getBuffer(), Identifier);
if (IgnoreEmptyThinLTOIndexFile && !BufferRef.getBufferSize())
return nullptr;
Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =