Integrate LLVM at llvm/llvm-project@ff96267b4202
Updates LLVM usage to match
[ff96267b4202](https://github.com/llvm/llvm-project/commit/ff96267b4202)
PiperOrigin-RevId: 505964460
diff --git a/nullability_verification/pointer_nullability_analysis.cc b/nullability_verification/pointer_nullability_analysis.cc
index 80dc0df..f795194 100644
--- a/nullability_verification/pointer_nullability_analysis.cc
+++ b/nullability_verification/pointer_nullability_analysis.cc
@@ -4,6 +4,7 @@
#include "nullability_verification/pointer_nullability_analysis.h"
+#include <optional>
#include <string>
#include "absl/log/check.h"
@@ -182,7 +183,7 @@
NullabilityKind getPointerNullability(const Expr* E,
PointerNullabilityAnalysis::Lattice& L) {
QualType ExprType = E->getType();
- Optional<NullabilityKind> Nullability = ExprType->getNullability();
+ std::optional<NullabilityKind> Nullability = ExprType->getNullability();
// If the expression's type does not contain nullability information, it may
// be a template instantiation. Look up the nullability in the
diff --git a/nullability_verification/pointer_nullability_diagnosis.cc b/nullability_verification/pointer_nullability_diagnosis.cc
index 1706e0c..6c81070 100644
--- a/nullability_verification/pointer_nullability_diagnosis.cc
+++ b/nullability_verification/pointer_nullability_diagnosis.cc
@@ -51,20 +51,20 @@
isNullableOrUntracked(E, Env);
}
-llvm::Optional<CFGElement> diagnoseDereference(
+std::optional<CFGElement> diagnoseDereference(
const UnaryOperator* UnaryOp, const MatchFinder::MatchResult&,
const TransferStateForDiagnostics<PointerNullabilityLattice>& State) {
if (isNullableOrUntracked(UnaryOp->getSubExpr(), State.Env)) {
- return llvm::Optional<CFGElement>(CFGStmt(UnaryOp));
+ return std::optional<CFGElement>(CFGStmt(UnaryOp));
}
return std::nullopt;
}
-llvm::Optional<CFGElement> diagnoseArrow(
+std::optional<CFGElement> diagnoseArrow(
const MemberExpr* MemberExpr, const MatchFinder::MatchResult& Result,
const TransferStateForDiagnostics<PointerNullabilityLattice>& State) {
if (isNullableOrUntracked(MemberExpr->getBase(), State.Env)) {
- return llvm::Optional<CFGElement>(CFGStmt(MemberExpr));
+ return std::optional<CFGElement>(CFGStmt(MemberExpr));
}
return std::nullopt;
}
@@ -144,7 +144,7 @@
// Compare the nullability computed by nullability analysis with the
// expected one.
const Expr* GivenExpr = CE->getArg(0);
- Optional<ArrayRef<NullabilityKind>> MaybeComputed =
+ std::optional<ArrayRef<NullabilityKind>> MaybeComputed =
State.Lattice.getExprNullability(GivenExpr);
if (!MaybeComputed.has_value()) {
llvm::dbgs()
@@ -170,7 +170,7 @@
// TODO(b/233582219): Handle call expressions whose callee is not a decl (e.g.
// a function returned from another function), or when the callee cannot be
// interpreted as a function type (e.g. a pointer to a function pointer).
-llvm::Optional<CFGElement> diagnoseCallExpr(
+std::optional<CFGElement> diagnoseCallExpr(
const CallExpr* CE, const MatchFinder::MatchResult& Result,
const TransferStateForDiagnostics<PointerNullabilityLattice>& State) {
auto* Callee = CE->getCalleeDecl();
@@ -185,7 +185,7 @@
!diagnoseAssertNullabilityCall(CE, State, *Result.Context)) {
// TODO: Handle __assert_nullability failures differently from regular
// diagnostic ([[unsafe]]) failures.
- return llvm::Optional<CFGElement>(CFGStmt(CE));
+ return std::optional<CFGElement>(CFGStmt(CE));
}
}
@@ -199,11 +199,11 @@
return isIncompatibleArgumentList(ParamTypes, Args, State.Env,
*Result.Context)
- ? llvm::Optional<CFGElement>(CFGStmt(CE))
+ ? std::optional<CFGElement>(CFGStmt(CE))
: std::nullopt;
}
-llvm::Optional<CFGElement> diagnoseConstructExpr(
+std::optional<CFGElement> diagnoseConstructExpr(
const CXXConstructExpr* CE, const MatchFinder::MatchResult& Result,
const TransferStateForDiagnostics<PointerNullabilityLattice>& State) {
auto ConstructorParamTypes = CE->getConstructor()
@@ -213,11 +213,11 @@
ArrayRef<const Expr*> ConstructorArgs(CE->getArgs(), CE->getNumArgs());
return isIncompatibleArgumentList(ConstructorParamTypes, ConstructorArgs,
State.Env, *Result.Context)
- ? llvm::Optional<CFGElement>(CFGStmt(CE))
+ ? std::optional<CFGElement>(CFGStmt(CE))
: std::nullopt;
}
-llvm::Optional<CFGElement> diagnoseReturn(
+std::optional<CFGElement> diagnoseReturn(
const ReturnStmt* RS, const MatchFinder::MatchResult& Result,
const TransferStateForDiagnostics<PointerNullabilityLattice>& State) {
auto ReturnType = cast<FunctionDecl>(State.Env.getDeclCtx())->getReturnType();
@@ -232,11 +232,11 @@
return isIncompatibleAssignment(ReturnType, ReturnExpr, State.Env,
*Result.Context)
- ? llvm::Optional<CFGElement>(CFGStmt(RS))
+ ? std::optional<CFGElement>(CFGStmt(RS))
: std::nullopt;
}
-llvm::Optional<CFGElement> diagnoseMemberInitializer(
+std::optional<CFGElement> diagnoseMemberInitializer(
const CXXCtorInitializer* CI, const MatchFinder::MatchResult& Result,
const TransferStateForDiagnostics<PointerNullabilityLattice>& State) {
assert(CI->isAnyMemberInitializer());
@@ -247,14 +247,14 @@
auto MemberInitExpr = CI->getInit();
return isIncompatibleAssignment(MemberType, MemberInitExpr, State.Env,
*Result.Context)
- ? llvm::Optional<CFGElement>(CFGInitializer(CI))
+ ? std::optional<CFGElement>(CFGInitializer(CI))
: std::nullopt;
}
auto buildDiagnoser() {
return CFGMatchSwitchBuilder<const dataflow::TransferStateForDiagnostics<
PointerNullabilityLattice>,
- llvm::Optional<CFGElement>>()
+ std::optional<CFGElement>>()
// (*)
.CaseOfCFGStmt<UnaryOperator>(isPointerDereference(), diagnoseDereference)
// (->)
diff --git a/nullability_verification/pointer_nullability_lattice.h b/nullability_verification/pointer_nullability_lattice.h
index f4829aa..86ca00d 100644
--- a/nullability_verification/pointer_nullability_lattice.h
+++ b/nullability_verification/pointer_nullability_lattice.h
@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_CRUBIT_NULLABILITY_VERIFICATION_POINTER_NULLABILITY_LATTICE_H_
#define THIRD_PARTY_CRUBIT_NULLABILITY_VERIFICATION_POINTER_NULLABILITY_LATTICE_H_
+#include <optional>
#include <ostream>
#include "absl/container/flat_hash_map.h"
@@ -30,12 +31,13 @@
*ExprToNullability)
: ExprToNullability(ExprToNullability) {}
- Optional<ArrayRef<NullabilityKind>> getExprNullability(const Expr *E) const {
+ std::optional<ArrayRef<NullabilityKind>> getExprNullability(
+ const Expr *E) const {
E = &dataflow::ignoreCFGOmittedNodes(*E);
auto I = ExprToNullability->find(&dataflow::ignoreCFGOmittedNodes(*E));
return I == ExprToNullability->end()
? std::nullopt
- : Optional<ArrayRef<NullabilityKind>>(I->second);
+ : std::optional<ArrayRef<NullabilityKind>>(I->second);
}
// If the `ExprToNullability` map already contains an entry for `E`, does
diff --git a/nullability_verification/pointer_nullability_verification_test.cc b/nullability_verification/pointer_nullability_verification_test.cc
index 944fd8d..0970ce0 100644
--- a/nullability_verification/pointer_nullability_verification_test.cc
+++ b/nullability_verification/pointer_nullability_verification_test.cc
@@ -2,6 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#include <optional>
#include <set>
#include <string>
@@ -61,10 +62,10 @@
}
auto &SrcMgr = AnalysisData.ASTCtx.getSourceManager();
for (auto Element : Diagnostics) {
- if (Optional<CFGStmt> stmt = Element.getAs<CFGStmt>()) {
+ if (std::optional<CFGStmt> stmt = Element.getAs<CFGStmt>()) {
ActualLines.insert(SrcMgr.getPresumedLineNumber(
stmt->getStmt()->getBeginLoc()));
- } else if (Optional<CFGInitializer> init =
+ } else if (std::optional<CFGInitializer> init =
Element.getAs<CFGInitializer>()) {
ActualLines.insert(SrcMgr.getPresumedLineNumber(
init->getInitializer()->getSourceLocation()));