[clang] b5fdd53 - [Checkers] Use std::optional in StdLibraryFunctionsChecker.cpp (NFC)

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


Author: Kazu Hirata
Date: 2022-12-10T08:09:00-08:00
New Revision: b5fdd533e5c8ed9726bfaaf961272010cbde6c75

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

LOG: [Checkers] Use std::optional in StdLibraryFunctionsChecker.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/StdLibraryFunctionsChecker.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index d7befdc553e3..2535bf5a368f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -52,6 +52,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 
+#include <optional>
 #include <string>
 
 using namespace clang;
@@ -296,13 +297,13 @@ class StdLibraryFunctionsChecker
   //   // Here, ptr is the buffer, and its minimum size is `size * nmemb`.
   class BufferSizeConstraint : public ValueConstraint {
     // The concrete value which is the minimum size for the buffer.
-    llvm::Optional<llvm::APSInt> ConcreteSize;
+    std::optional<llvm::APSInt> ConcreteSize;
     // The argument which holds the size of the buffer.
-    llvm::Optional<ArgNo> SizeArgN;
+    std::optional<ArgNo> SizeArgN;
     // The argument which is a multiplier to size. This is set in case of
     // `fread` like functions where the size is computed as a multiplication of
     // two arguments.
-    llvm::Optional<ArgNo> SizeMultiplierArgN;
+    std::optional<ArgNo> SizeMultiplierArgN;
     // The operator we use in apply. This is negated in negate().
     BinaryOperator::Opcode Op = BO_LE;
 


        


More information about the cfe-commits mailing list