mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 06:31:50 +08:00
[ELF] toString(const InputFile *): synchronize toStringCache
The function may be called currently for diagnostics.
This commit is contained in:
@@ -47,14 +47,18 @@ std::unique_ptr<TarWriter> elf::tar;
|
||||
|
||||
// Returns "<internal>", "foo.a(bar.o)" or "baz.o".
|
||||
std::string lld::toString(const InputFile *f) {
|
||||
static std::mutex mu;
|
||||
if (!f)
|
||||
return "<internal>";
|
||||
|
||||
if (f->toStringCache.empty()) {
|
||||
if (f->archiveName.empty())
|
||||
f->toStringCache = f->getName();
|
||||
else
|
||||
(f->archiveName + "(" + f->getName() + ")").toVector(f->toStringCache);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mu);
|
||||
if (f->toStringCache.empty()) {
|
||||
if (f->archiveName.empty())
|
||||
f->toStringCache = f->getName();
|
||||
else
|
||||
(f->archiveName + "(" + f->getName() + ")").toVector(f->toStringCache);
|
||||
}
|
||||
}
|
||||
return std::string(f->toStringCache);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user