forked from OSchip/llvm-project
Temporarily Revert "[Support] Make UniqueStringSaver wrap a StringSet"
as it's causing asan failures in clangd. Followed up offline
with repro instructions.
This reverts commit 29560a89dd
.
This commit is contained in:
parent
85725a67c7
commit
dad2e92eaf
|
@ -9,7 +9,7 @@
|
|||
#ifndef LLVM_SUPPORT_STRINGSAVER_H
|
||||
#define LLVM_SUPPORT_STRINGSAVER_H
|
||||
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
|
@ -36,8 +36,12 @@ public:
|
|||
///
|
||||
/// Compared to StringSaver, it does more work but avoids saving the same string
|
||||
/// multiple times.
|
||||
///
|
||||
/// Compared to StringPool, it performs fewer allocations but doesn't support
|
||||
/// refcounting/deletion.
|
||||
class UniqueStringSaver final {
|
||||
StringSet<BumpPtrAllocator &> Strings;
|
||||
StringSaver Strings;
|
||||
llvm::DenseSet<llvm::StringRef> Unique;
|
||||
|
||||
public:
|
||||
UniqueStringSaver(BumpPtrAllocator &Alloc) : Strings(Alloc) {}
|
||||
|
|
|
@ -19,5 +19,8 @@ StringRef StringSaver::save(StringRef S) {
|
|||
}
|
||||
|
||||
StringRef UniqueStringSaver::save(StringRef S) {
|
||||
return Strings.insert(S).first->getKey();
|
||||
auto R = Unique.insert(S);
|
||||
if (R.second) // cache miss, need to actually save the string
|
||||
*R.first = Strings.save(S); // safe replacement with equal value
|
||||
return *R.first;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue