diff options
author | Kazu Hirata <kazu@google.com> | 2022-12-03 11:34:24 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2022-12-03 11:34:24 -0800 |
commit | 180600660bbbdf8e74f7372a00e24edb219f0868 (patch) | |
tree | ceed4ff196c1ee61159393a481430f309d1bbd15 /clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | |
parent | 32332909f45b55aba4cfa7fac95e28cd174655f5 (diff) | |
download | llvm-180600660bbbdf8e74f7372a00e24edb219f0868.zip llvm-180600660bbbdf8e74f7372a00e24edb219f0868.tar.gz llvm-180600660bbbdf8e74f7372a00e24edb219f0868.tar.bz2 |
[StaticAnalyzer] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
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
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp index c5fa43ac..d7befdc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -1095,13 +1095,13 @@ Optional<StdLibraryFunctionsChecker::Summary> StdLibraryFunctionsChecker::findFunctionSummary(const FunctionDecl *FD, CheckerContext &C) const { if (!FD) - return None; + return std::nullopt; initFunctionSummaries(C); auto FSMI = FunctionSummaryMap.find(FD->getCanonicalDecl()); if (FSMI == FunctionSummaryMap.end()) - return None; + return std::nullopt; return FSMI->second; } @@ -1110,7 +1110,7 @@ StdLibraryFunctionsChecker::findFunctionSummary(const CallEvent &Call, CheckerContext &C) const { const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Call.getDecl()); if (!FD) - return None; + return std::nullopt; return findFunctionSummary(FD, C); } @@ -1135,7 +1135,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( IdentifierInfo &II = ACtx.Idents.get(Name); auto LookupRes = ACtx.getTranslationUnitDecl()->lookup(&II); if (LookupRes.empty()) - return None; + return std::nullopt; // Prioritze typedef declarations. // This is needed in case of C struct typedefs. E.g.: @@ -1153,7 +1153,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( for (Decl *D : LookupRes) if (auto *TD = dyn_cast<TypeDecl>(D)) return ACtx.getTypeDeclType(TD).getCanonicalType(); - return None; + return std::nullopt; } } lookupTy(ACtx); @@ -1170,7 +1170,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( Optional<QualType> operator()(Optional<QualType> Ty) { if (Ty) return operator()(*Ty); - return None; + return std::nullopt; } } getRestrictTy(ACtx); class GetPointerTy { @@ -1182,13 +1182,13 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( Optional<QualType> operator()(Optional<QualType> Ty) { if (Ty) return operator()(*Ty); - return None; + return std::nullopt; } } getPointerTy(ACtx); class { public: Optional<QualType> operator()(Optional<QualType> Ty) { - return Ty ? Optional<QualType>(Ty->withConst()) : None; + return Ty ? Optional<QualType>(Ty->withConst()) : std::nullopt; } QualType operator()(QualType Ty) { return Ty.withConst(); } } getConstTy; @@ -1204,7 +1204,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( if (Ty) { return operator()(*Ty); } - return None; + return std::nullopt; } } getMaxValue(BVF); |