[analyzer] Fix return of llvm::StringRef to destroyed std::string

This issue was discovered whilst testing with ASAN.

Differential Revision: https://reviews.llvm.org/D124683
This commit is contained in:
Andrew Ng 2022-04-29 18:00:33 +01:00
parent d5198cf92f
commit 57c55165eb
1 changed files with 4 additions and 2 deletions

View File

@ -98,11 +98,13 @@ private:
};
}
static inline std::vector<llvm::StringRef> toRefs(std::vector<std::string> V) {
static inline std::vector<llvm::StringRef>
toRefs(const std::vector<std::string> &V) {
return std::vector<llvm::StringRef>(V.begin(), V.end());
}
static decltype(auto) callsNames(std::vector<std::string> FunctionNames) {
static decltype(auto)
callsNames(const std::vector<std::string> &FunctionNames) {
return callee(functionDecl(hasAnyName(toRefs(FunctionNames))));
}