[clang] b5716de - [RetainCountChecker] Use std::optional in RetainCountDiagnostics.cpp (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 10 08:07:17 PST 2022


Author: Kazu Hirata
Date: 2022-12-10T08:07:12-08:00
New Revision: b5716decbd4a4be3dba2318799871b062f3859d2

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

LOG: [RetainCountChecker] Use std::optional in RetainCountDiagnostics.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
index 9133b66fec7c..3afaf622aab4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -15,6 +15,7 @@
 #include "RetainCountChecker.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include <optional>
 
 using namespace clang;
 using namespace ento;
@@ -166,10 +167,10 @@ static bool shouldGenerateNote(llvm::raw_string_ostream &os,
 /// Finds argument index of the out paramter in the call @c S
 /// corresponding to the symbol @c Sym.
 /// If none found, returns std::nullopt.
-static Optional<unsigned> findArgIdxOfSymbol(ProgramStateRef CurrSt,
-                                             const LocationContext *LCtx,
-                                             SymbolRef &Sym,
-                                             Optional<CallEventRef<>> CE) {
+static std::optional<unsigned> findArgIdxOfSymbol(ProgramStateRef CurrSt,
+                                                  const LocationContext *LCtx,
+                                                  SymbolRef &Sym,
+                                                  Optional<CallEventRef<>> CE) {
   if (!CE)
     return std::nullopt;
 
@@ -182,7 +183,7 @@ static Optional<unsigned> findArgIdxOfSymbol(ProgramStateRef CurrSt,
   return std::nullopt;
 }
 
-static Optional<std::string> findMetaClassAlloc(const Expr *Callee) {
+static std::optional<std::string> findMetaClassAlloc(const Expr *Callee) {
   if (const auto *ME = dyn_cast<MemberExpr>(Callee)) {
     if (ME->getMemberDecl()->getNameAsString() != "alloc")
       return std::nullopt;


        


More information about the cfe-commits mailing list