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

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 09:41:32 PDT 2022


andrewng created this revision.
andrewng added reviewers: george.karpenkov, Szelethus.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
andrewng requested review of this revision.

This issue was discovered whilst testing with ASAN.


https://reviews.llvm.org/D124683

Files:
  clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
@@ -98,11 +98,13 @@
 };
 }
 
-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))));
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124683.426094.patch
Type: text/x-patch
Size: 777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220429/df4172e8/attachment.bin>


More information about the llvm-commits mailing list