[clang-tidy][NFC] Fix buffer overflow in modernize-use-designated-initializers

Instance of DenseMap were copied into local variable,
and as a result reference to string stored in that local
variable were returned from function. At the end fix-it
were applied with already destroyed string causing some
non utf-8 characters to be printed.

Related to #80541
This commit is contained in:
Piotr Zegar 2024-02-29 20:52:32 +00:00
parent cff36bb198
commit 21be2fbd17

View File

@ -43,7 +43,7 @@ struct Designators {
unsigned size() { return getCached().size(); }
std::optional<llvm::StringRef> operator[](const SourceLocation &Location) {
const auto Designators = getCached();
const auto &Designators = getCached();
const auto Result = Designators.find(Location);
if (Result == Designators.end())
return {};