From 57c55165ebe8283b71ea785d2b0217119f8c5c51 Mon Sep 17 00:00:00 2001 From: Andrew Ng Date: Fri, 29 Apr 2022 18:00:33 +0100 Subject: [PATCH] [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 --- .../StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp index c8eab3288094..514f53b4804f 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp @@ -98,11 +98,13 @@ private: }; } -static inline std::vector toRefs(std::vector V) { +static inline std::vector +toRefs(const std::vector &V) { return std::vector(V.begin(), V.end()); } -static decltype(auto) callsNames(std::vector FunctionNames) { +static decltype(auto) +callsNames(const std::vector &FunctionNames) { return callee(functionDecl(hasAnyName(toRefs(FunctionNames)))); }