Fix use-after-free in clang-apply-replacements
authorBen Langmuir <blangmuir@apple.com>
Tue, 2 Aug 2022 20:33:12 +0000 (13:33 -0700)
committerBen Langmuir <blangmuir@apple.com>
Tue, 2 Aug 2022 20:34:20 +0000 (13:34 -0700)
Accidentally introduced a dangling StringRef in b4c6dc2e6637.

Differential Revision: https://reviews.llvm.org/D131017

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

index 9757d99..b9e83ac 100644 (file)
@@ -24,6 +24,7 @@
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -140,7 +141,7 @@ std::error_code collectReplacementsFromDirectory(
 static llvm::DenseMap<const FileEntry *, std::vector<tooling::Replacement>>
 groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
                   const clang::SourceManager &SM) {
-  std::set<StringRef> Warned;
+  llvm::StringSet<> Warned;
   llvm::DenseMap<const FileEntry *, std::vector<tooling::Replacement>>
       GroupedReplacements;