[clang] 57c5516 - [analyzer] Fix return of llvm::StringRef to destroyed std::string

Andrew Ng via cfe-commits cfe-commits at lists.llvm.org
Sun May 1 04:36:50 PDT 2022


Author: Andrew Ng
Date: 2022-05-01T12:24:32+01:00
New Revision: 57c55165ebe8283b71ea785d2b0217119f8c5c51

URL: https://github.com/llvm/llvm-project/commit/57c55165ebe8283b71ea785d2b0217119f8c5c51
DIFF: https://github.com/llvm/llvm-project/commit/57c55165ebe8283b71ea785d2b0217119f8c5c51.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
index c8eab32880943..514f53b4804f5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp
@@ -98,11 +98,13 @@ class ObjCAutoreleaseWriteChecker : public Checker<check::ASTCodeBody> {
 };
 }
 
-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))));
 }
 


        


More information about the cfe-commits mailing list