Fix use-after-free

Summary:
The warning
```
lldb/source/Core/FormatEntity.cpp:2350:25: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling]
```
is emitted after annotating `llvm::StringRef` with `[[gsl::Pointer]]`.

The reason is that in
```
 size_t FormatEntity::AutoComplete(CompletionRequest &request) {
  llvm::StringRef str = request.GetCursorArgumentPrefix().str();
```
the function `GetCursorArgumentPrefix()` returns a `StringRef`, and `StringRef::str()` returns
a temporary `std::string`.

Reviewers: jingham, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 369304
This commit is contained in:
Matthias Gehre 2019-08-19 21:39:16 +00:00
parent de7674ce76
commit 8b0d15e43f
1 changed files with 1 additions and 1 deletions

View File

@ -2347,7 +2347,7 @@ static void AddMatches(const FormatEntity::Entry::Definition *def,
}
size_t FormatEntity::AutoComplete(CompletionRequest &request) {
llvm::StringRef str = request.GetCursorArgumentPrefix().str();
llvm::StringRef str = request.GetCursorArgumentPrefix();
request.SetWordComplete(false);