llvm::Optional<bool> isSwiftPrivate() const {
return SwiftPrivateSpecified ? llvm::Optional<bool>(SwiftPrivate)
- : llvm::None;
+ : std::nullopt;
}
void setSwiftPrivate(llvm::Optional<bool> Private) {
void setSwiftBridge(const llvm::Optional<llvm::StringRef> &SwiftType) {
SwiftBridge = SwiftType
? llvm::Optional<std::string>(std::string(*SwiftType))
- : llvm::None;
+ : std::nullopt;
}
const llvm::Optional<std::string> &getNSErrorDomain() const {
}
void setNSErrorDomain(const llvm::Optional<llvm::StringRef> &Domain) {
- NSErrorDomain =
- Domain ? llvm::Optional<std::string>(std::string(*Domain)) : llvm::None;
+ NSErrorDomain = Domain ? llvm::Optional<std::string>(std::string(*Domain))
+ : std::nullopt;
}
friend bool operator==(const CommonTypeInfo &, const CommonTypeInfo &);
return HasDefaultNullability
? llvm::Optional<NullabilityKind>(
static_cast<NullabilityKind>(DefaultNullability))
- : llvm::None;
+ : std::nullopt;
}
/// Set the default nullability for properties and methods of this class.
llvm::Optional<bool> getSwiftImportAsNonGeneric() const {
return SwiftImportAsNonGenericSpecified
? llvm::Optional<bool>(SwiftImportAsNonGeneric)
- : llvm::None;
+ : std::nullopt;
}
void setSwiftImportAsNonGeneric(llvm::Optional<bool> Value) {
SwiftImportAsNonGenericSpecified = Value.has_value();
llvm::Optional<bool> getSwiftObjCMembers() const {
return SwiftObjCMembersSpecified ? llvm::Optional<bool>(SwiftObjCMembers)
- : llvm::None;
+ : std::nullopt;
}
void setSwiftObjCMembers(llvm::Optional<bool> Value) {
SwiftObjCMembersSpecified = Value.has_value();
llvm::Optional<NullabilityKind> getNullability() const {
return NullabilityAudited ? llvm::Optional<NullabilityKind>(
static_cast<NullabilityKind>(Nullable))
- : llvm::None;
+ : std::nullopt;
}
void setNullabilityAudited(NullabilityKind kind) {
llvm::Optional<bool> getSwiftImportAsAccessors() const {
return SwiftImportAsAccessorsSpecified
? llvm::Optional<bool>(SwiftImportAsAccessors)
- : llvm::None;
+ : std::nullopt;
}
void setSwiftImportAsAccessors(llvm::Optional<bool> Value) {
SwiftImportAsAccessorsSpecified = Value.has_value();
llvm::Optional<bool> isNoEscape() const {
if (!NoEscapeSpecified)
- return llvm::None;
+ return std::nullopt;
return NoEscape;
}
void setNoEscape(llvm::Optional<bool> Value) {
llvm::Optional<RetainCountConventionKind> getRetainCountConvention() const {
if (!RawRetainCountConvention)
- return llvm::None;
+ return std::nullopt;
return static_cast<RetainCountConventionKind>(RawRetainCountConvention - 1);
}
void
llvm::Optional<RetainCountConventionKind> getRetainCountConvention() const {
if (!RawRetainCountConvention)
- return llvm::None;
+ return std::nullopt;
return static_cast<RetainCountConventionKind>(RawRetainCountConvention - 1);
}
void
llvm::Optional<bool> isFlagEnum() const {
if (HasFlagEnum)
return IsFlagEnum;
- return llvm::None;
+ return std::nullopt;
}
void setFlagEnum(llvm::Optional<bool> Value) {
HasFlagEnum = Value.has_value();
}
llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
- return llvm::None;
+ return std::nullopt;
}
SmallVector<BoundNodes, 1> Nodes;
template <typename ResultT, typename ArgT,
ResultT (*Func)(ArrayRef<const ArgT *>)>
struct VariadicFunction {
- ResultT operator()() const { return Func(None); }
+ ResultT operator()() const { return Func(std::nullopt); }
template <typename... ArgsT>
ResultT operator()(const ArgT &Arg1, const ArgsT &... Args) const {
BoundNodesTreeBuilder *Builder) const = 0;
virtual llvm::Optional<clang::TraversalKind> TraversalKind() const {
- return llvm::None;
+ return std::nullopt;
}
};
inline Optional<BinaryOperatorKind>
equivalentBinaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
if (Node.getNumArgs() != 2)
- return None;
+ return std::nullopt;
switch (Node.getOperator()) {
default:
- return None;
+ return std::nullopt;
case OO_ArrowStar:
return BO_PtrMemI;
case OO_Star:
equivalentUnaryOperator<CXXOperatorCallExpr>(const CXXOperatorCallExpr &Node) {
if (Node.getNumArgs() != 1 && Node.getOperator() != OO_PlusPlus &&
Node.getOperator() != OO_MinusMinus)
- return None;
+ return std::nullopt;
switch (Node.getOperator()) {
default:
- return None;
+ return std::nullopt;
case OO_Plus:
return UO_Plus;
case OO_Minus:
case OO_PlusPlus: {
const auto *FD = Node.getDirectCallee();
if (!FD)
- return None;
+ return std::nullopt;
return FD->getNumParams() > 0 ? UO_PostInc : UO_PreInc;
}
case OO_MinusMinus: {
const auto *FD = Node.getDirectCallee();
if (!FD)
- return None;
+ return std::nullopt;
return FD->getNumParams() > 0 ? UO_PostDec : UO_PreDec;
}
case OO_Coawait:
if (!optBinaryOpcode) {
auto optUnaryOpcode = equivalentUnaryOperator(Node);
if (!optUnaryOpcode)
- return None;
+ return std::nullopt;
return UnaryOperator::getOpcodeStr(*optUnaryOpcode);
}
return BinaryOperator::getOpcodeStr(*optBinaryOpcode);
if (!optBinaryOpcode) {
auto optUnaryOpcode = equivalentUnaryOperator(Node);
if (!optUnaryOpcode)
- return None;
+ return std::nullopt;
return UnaryOperator::getOpcodeStr(*optUnaryOpcode);
}
return BinaryOperator::getOpcodeStr(*optBinaryOpcode);
Command(const Action &Source, const Tool &Creator,
ResponseFileSupport ResponseSupport, const char *Executable,
const llvm::opt::ArgStringList &Arguments, ArrayRef<InputInfo> Inputs,
- ArrayRef<InputInfo> Outputs = None);
+ ArrayRef<InputInfo> Outputs = std::nullopt);
// FIXME: This really shouldn't be copyable, but is currently copied in some
// error handling in Driver::generateCompilationDiagnostics.
Command(const Command &) = default;
CC1Command(const Action &Source, const Tool &Creator,
ResponseFileSupport ResponseSupport, const char *Executable,
const llvm::opt::ArgStringList &Arguments,
- ArrayRef<InputInfo> Inputs, ArrayRef<InputInfo> Outputs = None);
+ ArrayRef<InputInfo> Inputs,
+ ArrayRef<InputInfo> Outputs = std::nullopt);
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
CrashReportInfo *CrashInfo = nullptr) const override;
const char *Executable_,
const llvm::opt::ArgStringList &Arguments_,
ArrayRef<InputInfo> Inputs,
- ArrayRef<InputInfo> Outputs = None);
+ ArrayRef<InputInfo> Outputs = std::nullopt);
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
CrashReportInfo *CrashInfo = nullptr) const override;
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
- ArrayRef<RemappedFile> RemappedFiles = None,
+ ArrayRef<RemappedFile> RemappedFiles = std::nullopt,
bool RemappedFilesKeepOriginalName = true,
unsigned PrecompilePreambleAfterNParses = 0,
TranslationUnitKind TUKind = TU_Complete,
bool SingleFileParse = false, bool UserFilesAreVolatile = false,
bool ForSerialization = false,
bool RetainExcludedConditionalBlocks = false,
- llvm::Optional<StringRef> ModuleFormat = llvm::None,
+ llvm::Optional<StringRef> ModuleFormat = std::nullopt,
std::unique_ptr<ASTUnit> *ErrAST = nullptr,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- ArrayRef<RemappedFile> RemappedFiles = None,
+ ArrayRef<RemappedFile> RemappedFiles = std::nullopt,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
/// Free data that will be re-generated on the next parse.
}
auto Begin = ParsedSourceLocation::FromString(RangeSplit.first);
if (Begin.FileName.empty())
- return None;
+ return std::nullopt;
if (!HasEndLoc) {
EndLine = Begin.Line;
EndColumn = Begin.Column;
InputKind getKind() const { return Kind; }
bool isSystem() const { return IsSystem; }
- bool isEmpty() const { return File.empty() && Buffer == None; }
+ bool isEmpty() const { return File.empty() && Buffer == std::nullopt; }
bool isFile() const { return !isBuffer(); }
- bool isBuffer() const { return Buffer != None; }
+ bool isBuffer() const { return Buffer != std::nullopt; }
bool isPreprocessed() const { return Kind.isPreprocessed(); }
bool isHeader() const { return Kind.isHeader(); }
InputKind::HeaderUnitKind getHeaderUnitKind() const {
}
Optional<DirectoryEntryRef> getDirRef() const {
- return isNormalDir() ? Optional<DirectoryEntryRef>(u.Dir) : None;
+ return isNormalDir() ? Optional<DirectoryEntryRef>(u.Dir) : std::nullopt;
}
/// getFrameworkDir - Return the directory that this framework refers to.
}
Optional<DirectoryEntryRef> getFrameworkDirRef() const {
- return isFramework() ? Optional<DirectoryEntryRef>(u.Dir) : None;
+ return isFramework() ? Optional<DirectoryEntryRef>(u.Dir) : std::nullopt;
}
/// getHeaderMap - Return the directory that this entry refers to.
llvm::Optional<Module *> getCachedModuleLoad(const IdentifierInfo &II) {
auto I = CachedModuleLoads.find(&II);
if (I == CachedModuleLoads.end())
- return None;
+ return std::nullopt;
return I->second;
}
};
/// entity with index \p Index came from file \p FID.
virtual Optional<bool> isPreprocessedEntityInFileID(unsigned Index,
FileID FID) {
- return None;
+ return std::nullopt;
}
/// Read a preallocated skipped range from the external source.
getActiveModuleMacros(Preprocessor &PP, const IdentifierInfo *II) const {
if (auto *Info = getModuleInfo(PP, II))
return Info->ActiveModuleMacros;
- return None;
+ return std::nullopt;
}
MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
ArrayRef<ModuleMacro*> getOverriddenMacros() const {
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
return Info->OverriddenMacros;
- return None;
+ return std::nullopt;
}
void setOverriddenMacros(Preprocessor &PP,
static MacroAnnotations makeDeprecation(SourceLocation Loc,
std::string Msg) {
return MacroAnnotations{MacroAnnotationInfo{Loc, std::move(Msg)},
- llvm::None, llvm::None};
+ std::nullopt, std::nullopt};
}
static MacroAnnotations makeRestrictExpansion(SourceLocation Loc,
std::string Msg) {
return MacroAnnotations{
- llvm::None, MacroAnnotationInfo{Loc, std::move(Msg)}, llvm::None};
+ std::nullopt, MacroAnnotationInfo{Loc, std::move(Msg)}, std::nullopt};
}
static MacroAnnotations makeFinal(SourceLocation Loc) {
- return MacroAnnotations{llvm::None, llvm::None, Loc};
+ return MacroAnnotations{std::nullopt, std::nullopt, Loc};
}
};
auto I = LeafModuleMacros.find(II);
if (I != LeafModuleMacros.end())
return I->second;
- return None;
+ return std::nullopt;
}
/// Get the list of submodules that we're currently building.
void ParseTypeQualifierListOpt(
DeclSpec &DS, unsigned AttrReqs = AR_AllAttributesParsed,
bool AtomicAllowed = true, bool IdentifierRequired = false,
- Optional<llvm::function_ref<void()>> CodeCompletionHandler = None);
+ Optional<llvm::function_ref<void()>> CodeCompletionHandler =
+ std::nullopt);
void ParseDirectDeclarator(Declarator &D);
void ParseDecompositionDeclarator(Declarator &D);
void ParseParenDeclarator(Declarator &D);
OptionalFileEntryRefDegradesToFileEntryPtr getFile() const {
if (auto *P = Val.getPointer())
return FileEntryRef(*P);
- return None;
+ return std::nullopt;
}
bool isOverridden() const { return Val.getInt() == Overridden; }
bool isOutOfDate() const { return Val.getInt() == OutOfDate; }
return ArrayRef<dependency_directives_scan::Directive>(
Directives->value());
}
- return None;
+ return std::nullopt;
}
/// \returns The error.
/// occurred, dependency file contents otherwise.
llvm::Expected<std::string>
getDependencyFile(const std::vector<std::string> &CommandLine, StringRef CWD,
- llvm::Optional<StringRef> ModuleName = None);
+ llvm::Optional<StringRef> ModuleName = std::nullopt);
/// Collect the full module dependency graph for the input, ignoring any
/// modules which have already been seen. If \p ModuleName isn't empty, this
getFullDependencies(const std::vector<std::string> &CommandLine,
StringRef CWD, const llvm::StringSet<> &AlreadySeen,
LookupModuleOutputCallback LookupModuleOutput,
- llvm::Optional<StringRef> ModuleName = None);
+ llvm::Optional<StringRef> ModuleName = std::nullopt);
llvm::Expected<FullDependenciesResult> getFullDependenciesLegacyDriverCommand(
const std::vector<std::string> &CommandLine, StringRef CWD,
const llvm::StringSet<> &AlreadySeen,
LookupModuleOutputCallback LookupModuleOutput,
- llvm::Optional<StringRef> ModuleName = None);
+ llvm::Optional<StringRef> ModuleName = std::nullopt);
private:
DependencyScanningWorker Worker;
const std::vector<std::string> &CommandLine,
DependencyConsumer &DepConsumer,
DiagnosticConsumer &DiagConsumer,
- llvm::Optional<StringRef> ModuleName = None);
+ llvm::Optional<StringRef> ModuleName = std::nullopt);
/// \returns A \c StringError with the diagnostic output if clang errors
/// occurred, success otherwise.
- llvm::Error computeDependencies(StringRef WorkingDirectory,
- const std::vector<std::string> &CommandLine,
- DependencyConsumer &Consumer,
- llvm::Optional<StringRef> ModuleName = None);
+ llvm::Error
+ computeDependencies(StringRef WorkingDirectory,
+ const std::vector<std::string> &CommandLine,
+ DependencyConsumer &Consumer,
+ llvm::Optional<StringRef> ModuleName = std::nullopt);
bool shouldEagerLoadModules() const { return EagerLoadModules; }
template <> struct MappingTraits<Param> {
static void mapping(IO &IO, Param &P) {
IO.mapRequired("Position", P.Position);
- IO.mapOptional("Nullability", P.Nullability, llvm::None);
+ IO.mapOptional("Nullability", P.Nullability, std::nullopt);
IO.mapOptional("RetainCountConvention", P.RetainCountConvention);
IO.mapOptional("NoEscape", P.NoEscape);
IO.mapOptional("Type", P.Type, StringRef(""));
IO.mapRequired("MethodKind", M.Kind);
IO.mapOptional("Parameters", M.Params);
IO.mapOptional("Nullability", M.Nullability);
- IO.mapOptional("NullabilityOfRet", M.NullabilityOfRet, llvm::None);
+ IO.mapOptional("NullabilityOfRet", M.NullabilityOfRet, std::nullopt);
IO.mapOptional("RetainCountConvention", M.RetainCountConvention);
IO.mapOptional("Availability", M.Availability.Mode,
APIAvailability::Available);
static void mapping(IO &IO, Property &P) {
IO.mapRequired("Name", P.Name);
IO.mapOptional("PropertyKind", P.Kind);
- IO.mapOptional("Nullability", P.Nullability, llvm::None);
+ IO.mapOptional("Nullability", P.Nullability, std::nullopt);
IO.mapOptional("Availability", P.Availability.Mode,
APIAvailability::Available);
IO.mapOptional("AvailabilityMsg", P.Availability.Msg, StringRef(""));
IO.mapRequired("Name", F.Name);
IO.mapOptional("Parameters", F.Params);
IO.mapOptional("Nullability", F.Nullability);
- IO.mapOptional("NullabilityOfRet", F.NullabilityOfRet, llvm::None);
+ IO.mapOptional("NullabilityOfRet", F.NullabilityOfRet, std::nullopt);
IO.mapOptional("RetainCountConvention", F.RetainCountConvention);
IO.mapOptional("Availability", F.Availability.Mode,
APIAvailability::Available);
template <> struct MappingTraits<GlobalVariable> {
static void mapping(IO &IO, GlobalVariable &GV) {
IO.mapRequired("Name", GV.Name);
- IO.mapOptional("Nullability", GV.Nullability, llvm::None);
+ IO.mapOptional("Nullability", GV.Nullability, std::nullopt);
IO.mapOptional("Availability", GV.Availability.Mode,
APIAvailability::Available);
IO.mapOptional("AvailabilityMsg", GV.Availability.Msg, StringRef(""));
TopLevelItems TopLevel;
VersionedSeq SwiftVersions;
- llvm::Optional<bool> SwiftInferImportAsMember = {llvm::None};
+ llvm::Optional<bool> SwiftInferImportAsMember = {std::nullopt};
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() /*const*/;
bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
bool clearAllDiagnostics(SourceRange range) {
- return clearDiagnostic(None, range);
+ return clearDiagnostic(std::nullopt, range);
}
bool clearDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) {
unsigned IDs[] = { ID1, ID2 };
Consumers.push_back(WrapperFrontendAction::CreateASTConsumer(CI, InFile));
Consumers.push_back(std::make_unique<ObjCMigrateASTConsumer>(
MigrateDir, ObjCMigAction, Remapper, CompInst->getFileManager(), PPRec,
- CompInst->getPreprocessor(), false, None));
+ CompInst->getPreprocessor(), false, std::nullopt));
return std::make_unique<MultiplexConsumer>(std::move(Consumers));
}
llvm::Optional<TraversalKind>
MatchFinder::MatchCallback::getCheckTraversalKind() const {
- return llvm::None;
+ return std::nullopt;
}
} // end namespace ast_matchers
}
llvm::Optional<DynTypedMatcher> DynTypedMatcher::tryBind(StringRef ID) const {
- if (!AllowBind) return llvm::None;
+ if (!AllowBind)
+ return std::nullopt;
auto Result = *this;
Result.Implementation =
new IdDynMatcher(ID, std::move(Result.Implementation));
if (isTokenAtLoc(SM, LangOpts, MacroName, Loc))
return Loc;
}
- return llvm::None;
+ return std::nullopt;
}
std::shared_ptr<llvm::Regex> createAndVerifyRegex(StringRef Regex,
if (!Res.empty())
return Res.str();
}
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<std::string>
if (Value.isString())
return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
"attr::");
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<std::string>
if (Value.isString())
return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
"CK_");
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<std::string>
if (Value.isString())
return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
"OMPC_");
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<std::string>
if (Value.isString())
return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
"UETT_");
- return llvm::None;
+ return std::nullopt;
}
static constexpr std::pair<llvm::StringRef, llvm::Regex::RegexFlags>
if (Flag == StringFlag.first)
return StringFlag.second;
}
- return llvm::None;
+ return std::nullopt;
}
static llvm::Optional<llvm::StringRef>
if (Flag.edit_distance(StringFlag.first) < 3)
return StringFlag.first;
}
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<llvm::Regex::RegexFlags>
getRegexFlag(OrFlag.trim()))
Flag = Flag.value_or(llvm::Regex::NoFlags) | *NextFlag;
else
- return None;
+ return std::nullopt;
}
return Flag;
}
clang::ast_matchers::dynamic::internal::ArgTypeTraits<
llvm::Regex::RegexFlags>::getBestGuess(const VariantValue &Value) {
if (!Value.isString())
- return llvm::None;
+ return std::nullopt;
SmallVector<StringRef, 4> Split;
llvm::StringRef(Value.getString()).split(Split, '|', -1, false);
for (llvm::StringRef &Flag : Split) {
getCloseRegexMatch(Flag.trim()))
Flag = *BestGuess;
else
- return None;
+ return std::nullopt;
}
if (Split.empty())
- return None;
+ return std::nullopt;
return llvm::join(Split, " | ");
}
}
static llvm::Optional<std::string> getBestGuess(const VariantValue &) {
- return llvm::None;
+ return std::nullopt;
}
};
}
static llvm::Optional<std::string> getBestGuess(const VariantValue &) {
- return llvm::None;
+ return std::nullopt;
}
};
}
static llvm::Optional<std::string> getBestGuess(const VariantValue &) {
- return llvm::None;
+ return std::nullopt;
}
};
}
static llvm::Optional<std::string> getBestGuess(const VariantValue &) {
- return llvm::None;
+ return std::nullopt;
}
};
}
static llvm::Optional<std::string> getBestGuess(const VariantValue &) {
- return llvm::None;
+ return std::nullopt;
}
};
private:
static Optional<attr::Kind> getAttrKind(llvm::StringRef AttrKind) {
if (!AttrKind.consume_front("attr::"))
- return llvm::None;
+ return std::nullopt;
return llvm::StringSwitch<Optional<attr::Kind>>(AttrKind)
#define ATTR(X) .Case(#X, attr::X)
#include "clang/Basic/AttrList.inc"
- .Default(llvm::None);
+ .Default(std::nullopt);
}
public:
private:
static Optional<CastKind> getCastKind(llvm::StringRef AttrKind) {
if (!AttrKind.consume_front("CK_"))
- return llvm::None;
+ return std::nullopt;
return llvm::StringSwitch<Optional<CastKind>>(AttrKind)
#define CAST_OPERATION(Name) .Case(#Name, CK_##Name)
#include "clang/AST/OperationKinds.def"
- .Default(llvm::None);
+ .Default(std::nullopt);
}
public:
#define GEN_CLANG_CLAUSE_CLASS
#define CLAUSE_CLASS(Enum, Str, Class) .Case(#Enum, llvm::omp::Clause::Enum)
#include "llvm/Frontend/OpenMP/OMP.inc"
- .Default(llvm::None);
+ .Default(std::nullopt);
}
public:
static Optional<UnaryExprOrTypeTrait>
getUnaryOrTypeTraitKind(llvm::StringRef ClauseKind) {
if (!ClauseKind.consume_front("UETT_"))
- return llvm::None;
+ return std::nullopt;
return llvm::StringSwitch<Optional<UnaryExprOrTypeTrait>>(ClauseKind)
#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) .Case(#Name, UETT_##Name)
#define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) \
.Case(#Name, UETT_##Name)
#include "clang/Basic/TokenKinds.def"
- .Default(llvm::None);
+ .Default(std::nullopt);
}
public:
BuildReturnTypeVector<ReturnType>::build(RetTypes);
return std::make_unique<FixedArgCountMatcherDescriptor>(
matcherMarshall0<ReturnType>, reinterpret_cast<void (*)()>(Func),
- MatcherName, RetTypes, None);
+ MatcherName, RetTypes, std::nullopt);
}
/// 1-arg overload
Diagnostics *Error) {
VariantValue Value;
if (!parseExpression(Code, S, NamedValues, &Value, Error))
- return llvm::None;
+ return std::nullopt;
if (!Value.isMatcher()) {
Error->addError(SourceRange(), Error->ET_ParserNotAMatcher);
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<DynTypedMatcher> Result =
Value.getMatcher().getSingleMatcher();
// Abort if any of the inner matchers can't be converted to
// Matcher<T>.
if (!InnerMatcher.Value)
- return llvm::None;
+ return std::nullopt;
llvm::Optional<DynTypedMatcher> Inner =
InnerMatcher.Value->getTypedMatcher(*this);
if (!Inner)
- return llvm::None;
+ return std::nullopt;
DynMatchers.push_back(*Inner);
}
return DynTypedMatcher::constructVariadic(Op, NodeKind, DynMatchers);
bool Ignore;
if (Ops.canConstructFrom(Matcher, Ignore))
return Matcher;
- return llvm::None;
+ return std::nullopt;
}
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity) const override {
llvm::Optional<DynTypedMatcher> getSingleMatcher() const override {
if (Matchers.size() != 1)
- return llvm::None;
+ return std::nullopt;
return Matchers[0];
}
// We only succeed if we found exactly one, or if we found an exact match.
if (Found && (FoundIsExact || NumFound == 1))
return *Found;
- return llvm::None;
+ return std::nullopt;
}
bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity) const override {
: Op(Op), Args(std::move(Args)) {}
llvm::Optional<DynTypedMatcher> getSingleMatcher() const override {
- return llvm::None;
+ return std::nullopt;
}
std::string getTypeAsString() const override {
CrossTranslationUnitContext::getMacroExpansionContextForSourceLocation(
const clang::SourceLocation &ToLoc) const {
// FIXME: Implement: Record such a context for every imported ASTUnit; lookup.
- return llvm::None;
+ return std::nullopt;
}
bool CrossTranslationUnitContext::isImportedAsNew(const Decl *ToDecl) const {
sys::fs::file_status Status;
std::error_code EC = status(Path, Status);
if (EC)
- return None;
+ return std::nullopt;
return Status;
}
static llvm::Optional<SemaphorePipe> create() {
int InotifyPollingStopperFDs[2];
if (pipe2(InotifyPollingStopperFDs, O_CLOEXEC) == -1)
- return llvm::None;
+ return std::nullopt;
return SemaphorePipe(InotifyPollingStopperFDs);
}
};
TCArgs.clear();
// Redirect stdout/stderr to /dev/null.
- Redirects = {None, {""}, {""}};
+ Redirects = {std::nullopt, {""}, {""}};
// Temporary files added by diagnostics should be kept.
ForceKeepTempFiles = true;
.Case("cl", CLMode)
.Case("flang", FlangMode)
.Case("dxc", DXCMode)
- .Default(None))
+ .Default(std::nullopt))
Mode = *M;
else
Diag(diag::err_drv_unsupported_option_argument) << OptName << Value;
auto ExpCommand = std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(), CreateExportListExec,
CreateExportCmdArgs, Inputs, Output);
- ExpCommand->setRedirectFiles({std::nullopt, std::string(ExportList), None});
+ ExpCommand->setRedirectFiles(
+ {std::nullopt, std::string(ExportList), std::nullopt});
C.addCommand(std::move(ExpCommand));
CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
}
if (const auto *MacCatalystToMacOSMapping = SDKInfo->getVersionMapping(
DarwinSDKInfo::OSEnvPair::macCatalystToMacOSPair())) {
if (auto MacOSVersion = MacCatalystToMacOSMapping->map(
- OSVersion, NativeTargetVersion, None)) {
+ OSVersion, NativeTargetVersion, std::nullopt)) {
NativeTargetVersion = *MacOSVersion;
}
}
if (const auto *MacOStoMacCatalystMapping = SDKInfo->getVersionMapping(
DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) {
Optional<VersionTuple> SDKVersion = MacOStoMacCatalystMapping->map(
- SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(), None);
+ SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(),
+ std::nullopt);
EmitTargetSDKVersionArg(
SDKVersion ? *SDKVersion : minimumMacCatalystDeploymentTarget());
}
DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) {
if (Optional<VersionTuple> SDKVersion = MacOStoMacCatalystMapping->map(
SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(),
- None)) {
+ std::nullopt)) {
std::string Arg;
llvm::raw_string_ostream OS(Arg);
OS << "-darwin-target-variant-sdk-version=" << *SDKVersion;
DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) {
iOSSDKVersion = MacOStoMacCatalystMapping->map(
SDKInfo->getVersion().withoutBuild(),
- minimumMacCatalystDeploymentTarget(), None);
+ minimumMacCatalystDeploymentTarget(), std::nullopt);
}
}
CmdArgs.push_back(Args.MakeArgString(
public:
explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {}
void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args,
- ArrayRef<std::string> ExtraTripleAliases = None);
+ ArrayRef<std::string> ExtraTripleAliases = std::nullopt);
/// Check whether we detected a valid GCC install.
bool isValid() const { return IsValid; }
Rule.match(File, &Matches);
// Returned matches are always in stable order.
if (Matches.size() != 4)
- return None;
+ return std::nullopt;
return path::convert_to_slash(
(Matches[1].drop_front(Matches[1].rfind('/') + 1) + "/" +
}
// Couldn't determine a include name, use full path instead.
- return None;
+ return std::nullopt;
}
struct LocationFileChecker {
/// the semantic version representation of \p V.
Optional<Object> serializeSemanticVersion(const VersionTuple &V) {
if (V.empty())
- return None;
+ return std::nullopt;
Object Version;
Version["major"] = V.getMajor();
/// an \c Array containing the formatted availability information.
Optional<Array> serializeAvailability(const AvailabilitySet &Availabilities) {
if (Availabilities.isDefault())
- return None;
+ return std::nullopt;
Array AvailabilityArray;
/// formatted lines.
Optional<Object> serializeDocComment(const DocComment &Comment) {
if (Comment.empty())
- return None;
+ return std::nullopt;
Object DocComment;
Array LinesArray;
/// declaration fragments array.
Optional<Array> serializeDeclarationFragments(const DeclarationFragments &DF) {
if (DF.getFragments().empty())
- return None;
+ return std::nullopt;
Array Fragments;
for (const auto &F : DF.getFragments()) {
std::true_type) {
const auto &FS = Record.Signature;
if (FS.empty())
- return None;
+ return std::nullopt;
Object Signature;
serializeArray(Signature, "returns",
template <typename RecordTy>
Optional<Object> serializeFunctionSignatureMixinImpl(const RecordTy &Record,
std::false_type) {
- return None;
+ return std::nullopt;
}
/// Serialize the function signature field, as specified by the
Optional<Object>
SymbolGraphSerializer::serializeAPIRecord(const RecordTy &Record) const {
if (shouldSkip(Record))
- return None;
+ return std::nullopt;
Object Obj;
serializeObject(Obj, "identifier",
static llvm::Optional<StringRef> getRawStringDelimiter(StringRef TokenText) {
if (TokenText.size() < 5 // The smallest raw string possible is 'R"()"'.
|| !TokenText.startswith("R\"") || !TokenText.endswith("\"")) {
- return None;
+ return std::nullopt;
}
// A raw string starts with 'R"<delimiter>(' and delimiter is ascii and has
// 19 bytes.
size_t LParenPos = TokenText.substr(0, 19).find_first_of('(');
if (LParenPos == StringRef::npos)
- return None;
+ return std::nullopt;
StringRef Delimiter = TokenText.substr(2, LParenPos - 2);
// Check that the string ends in ')Delimiter"'.
size_t RParenPos = TokenText.size() - Delimiter.size() - 2;
if (TokenText[RParenPos] != ')')
- return None;
+ return std::nullopt;
if (!TokenText.substr(RParenPos + 1).startswith(Delimiter))
- return None;
+ return std::nullopt;
return Delimiter;
}
RawStringFormatStyleManager::getDelimiterStyle(StringRef Delimiter) const {
auto It = DelimiterStyle.find(Delimiter);
if (It == DelimiterStyle.end())
- return None;
+ return std::nullopt;
return It->second;
}
StringRef EnclosingFunction) const {
auto It = EnclosingFunctionStyle.find(EnclosingFunction);
if (It == EnclosingFunctionStyle.end())
- return None;
+ return std::nullopt;
return It->second;
}
ContinuationIndenter::getRawStringStyle(const FormatToken &Current,
const LineState &State) {
if (!Current.isStringLiteral())
- return None;
+ return std::nullopt;
auto Delimiter = getRawStringDelimiter(Current.TokenText);
if (!Delimiter)
- return None;
+ return std::nullopt;
auto RawStringStyle = RawStringFormats.getDelimiterStyle(*Delimiter);
if (!RawStringStyle && Delimiter->empty()) {
RawStringStyle = RawStringFormats.getEnclosingFunctionStyle(
getEnclosingFunctionName(Current));
}
if (!RawStringStyle)
- return None;
+ return std::nullopt;
RawStringStyle->ColumnLimit = getColumnLimit(State);
return RawStringStyle;
}
llvm::Optional<FormatStyle>
FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
if (!Styles)
- return None;
+ return std::nullopt;
auto It = Styles->find(Language);
if (It == Styles->end())
- return None;
+ return std::nullopt;
FormatStyle Style = It->second;
Style.StyleSet = *this;
return Style;
[&FileMgr](StringRef Filename) -> Optional<llvm::sys::fs::UniqueID> {
if (auto Status = FileMgr.getVirtualFileSystem().status(Filename))
return Status->getUniqueID();
- return None;
+ return std::nullopt;
};
auto hasSameUniqueID = [getUniqueID](StringRef LHS, StringRef RHS) {
else if (Filename == "module.private.modulemap")
llvm::sys::path::append(PublicFilename, "module.modulemap");
else
- return None;
+ return std::nullopt;
return FileMgr.getOptionalFileRef(PublicFilename);
}
DiagnosticsEngine &Diags) {
if (Args.hasArg(Opt))
return true;
- return None;
+ return std::nullopt;
}
static Optional<bool> normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
DiagnosticsEngine &) {
if (Args.hasArg(Opt))
return false;
- return None;
+ return std::nullopt;
}
/// The tblgen-erated code passes in a fifth parameter of an arbitrary type, but
DiagnosticsEngine &) -> Optional<T> {
if (Args.hasArg(Opt))
return Value;
- return None;
+ return std::nullopt;
};
}
if (const Arg *A = Args.getLastArg(Opt, OtherOpt)) {
return A->getOption().matches(Opt) ? Value : OtherValue;
}
- return None;
+ return std::nullopt;
};
}
if (Name == Table.Table[I].Name)
return Table.Table[I];
- return None;
+ return std::nullopt;
}
static Optional<SimpleEnumValue>
if (Value == Table.Table[I].Value)
return Table.Table[I];
- return None;
+ return std::nullopt;
}
static llvm::Optional<unsigned> normalizeSimpleEnum(OptSpecifier Opt,
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
- return None;
+ return std::nullopt;
StringRef ArgValue = Arg->getValue();
if (auto MaybeEnumVal = findValueTableByName(Table, ArgValue))
Diags.Report(diag::err_drv_invalid_value)
<< Arg->getAsString(Args) << ArgValue;
- return None;
+ return std::nullopt;
}
static void denormalizeSimpleEnumImpl(SmallVectorImpl<const char *> &Args,
DiagnosticsEngine &Diags) {
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
- return None;
+ return std::nullopt;
return std::string(Arg->getValue());
}
DiagnosticsEngine &Diags) {
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
- return None;
+ return std::nullopt;
IntTy Res;
if (StringRef(Arg->getValue()).getAsInteger(0, Res)) {
Diags.Report(diag::err_drv_invalid_int_value)
<< Arg->getAsString(Args) << Arg->getValue();
- return None;
+ return std::nullopt;
}
return Res;
}
DiagnosticsEngine &Diags) {
auto *Arg = Args.getLastArg(Opt);
if (!Arg)
- return None;
+ return std::nullopt;
return llvm::Triple::normalize(Arg->getValue());
}
static void initOption(AnalyzerOptions::ConfigTable &Config,
DiagnosticsEngine *Diags,
bool &OptionField, StringRef Name, bool DefaultVal) {
- auto PossiblyInvalidVal = llvm::StringSwitch<Optional<bool>>(
- getStringOption(Config, Name, (DefaultVal ? "true" : "false")))
- .Case("true", true)
- .Case("false", false)
- .Default(None);
+ auto PossiblyInvalidVal =
+ llvm::StringSwitch<Optional<bool>>(
+ getStringOption(Config, Name, (DefaultVal ? "true" : "false")))
+ .Case("true", true)
+ .Case("false", false)
+ .Default(std::nullopt);
if (!PossiblyInvalidVal) {
if (Diags)
DebugInfoVal = "unused-types";
break;
case codegenoptions::NoDebugInfo: // default value
- DebugInfoVal = None;
+ DebugInfoVal = std::nullopt;
break;
case codegenoptions::LocTrackingOnly: // implied value
- DebugInfoVal = None;
+ DebugInfoVal = std::nullopt;
break;
}
if (DebugInfoVal)
if (ActionOpt.second == Opt.getID())
return ActionOpt.first;
- return None;
+ return std::nullopt;
}
/// Maps frontend action to command line option.
if (ActionOpt.first == ProgramAction)
return OptSpecifier(ActionOpt.second);
- return None;
+ return std::nullopt;
}
static void GenerateFrontendArgs(const FrontendOptions &Opts,
auto End = Opts.UserEntries.end();
// Add -I..., -F..., and -index-header-map options in order.
- for (; It < End &&
- Matches(*It, {frontend::IndexHeaderMap, frontend::Angled}, None, true);
+ for (; It < End && Matches(*It, {frontend::IndexHeaderMap, frontend::Angled},
+ std::nullopt, true);
++It) {
OptSpecifier Opt = [It, Matches]() {
if (Matches(*It, frontend::IndexHeaderMap, true, true))
GenerateArg(Args, OPT_idirafter, It->Path, SA);
for (; It < End && Matches(*It, {frontend::Quoted}, false, true); ++It)
GenerateArg(Args, OPT_iquote, It->Path, SA);
- for (; It < End && Matches(*It, {frontend::System}, false, None); ++It)
+ for (; It < End && Matches(*It, {frontend::System}, false, std::nullopt);
+ ++It)
GenerateArg(Args, It->IgnoreSysRoot ? OPT_isystem : OPT_iwithsysroot,
It->Path, SA);
for (; It < End && Matches(*It, {frontend::System}, true, true); ++It)
void DiagnosticRenderer::emitBasicNote(StringRef Message) {
emitDiagnosticMessage(FullSourceLoc(), PresumedLoc(), DiagnosticsEngine::Note,
- Message, None, DiagOrStoredDiag());
+ Message, std::nullopt, DiagOrStoredDiag());
}
/// Prints an include stack when appropriate for a particular
Message << "expanded from macro '" << MacroName << "'";
emitDiagnostic(SpellingLoc, DiagnosticsEngine::Note, Message.str(),
- SpellingRanges, None);
+ SpellingRanges, std::nullopt);
}
/// Check that the macro argument location of Loc starts with ArgumentLoc.
return std::error_code();
// Resolve all lazy header directives to header files.
- ModMap.resolveHeaderDirectives(Module, /*File=*/llvm::None);
+ ModMap.resolveHeaderDirectives(Module, /*File=*/std::nullopt);
// If any headers are missing, we can't build this module. In most cases,
// diagnostics for this should have already been produced; we only get here
static llvm::Optional<std::pair<unsigned, unsigned>>
findLinesForRange(const CharSourceRange &R, FileID FID,
const SourceManager &SM) {
- if (!R.isValid()) return None;
+ if (!R.isValid())
+ return std::nullopt;
SourceLocation Begin = R.getBegin();
SourceLocation End = R.getEnd();
if (SM.getFileID(Begin) != FID || SM.getFileID(End) != FID)
- return None;
+ return std::nullopt;
return std::make_pair(SM.getExpansionLineNumber(Begin),
SM.getExpansionLineNumber(End));
static bool isTemplateImplicitInstantiation(const Decl *D);
bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
- ArrayRef<SymbolRelation> Relations = None);
+ ArrayRef<SymbolRelation> Relations = std::nullopt);
bool handleDecl(const Decl *D, SourceLocation Loc,
SymbolRoleSet Roles = SymbolRoleSet(),
- ArrayRef<SymbolRelation> Relations = None,
+ ArrayRef<SymbolRelation> Relations = std::nullopt,
const DeclContext *DC = nullptr);
bool handleReference(const NamedDecl *D, SourceLocation Loc,
- const NamedDecl *Parent,
- const DeclContext *DC,
+ const NamedDecl *Parent, const DeclContext *DC,
SymbolRoleSet Roles = SymbolRoleSet(),
- ArrayRef<SymbolRelation> Relations = None,
- const Expr *RefE = nullptr,
- const Decl *RefD = nullptr);
+ ArrayRef<SymbolRelation> Relations = std::nullopt,
+ const Expr *RefE = nullptr, const Decl *RefD = nullptr);
void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc,
const MacroInfo &MI);
bool indexDecl(const Decl *D);
void indexTagDecl(const TagDecl *D,
- ArrayRef<SymbolRelation> Relations = None);
+ ArrayRef<SymbolRelation> Relations = std::nullopt);
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
const DeclContext *DC = nullptr,
if (Tok.isNot(tok::raw_identifier)) {
if (!Tok.is(tok::eod))
skipLine(First, End);
- return None;
+ return std::nullopt;
}
bool NeedsCleaning = Tok.Flags & clang::Token::NeedsCleaning;
// Check for invalid index.
if (StrTabIdx >= FileBuffer->getBufferSize())
- return None;
+ return std::nullopt;
const char *Data = FileBuffer->getBufferStart() + StrTabIdx;
unsigned MaxLen = FileBuffer->getBufferSize() - StrTabIdx;
// Check whether the buffer is null-terminated.
if (Len == MaxLen && Data[Len - 1])
- return None;
+ return std::nullopt;
return StringRef(Data, Len);
}
Diags.Report(IncludeLoc, diag::err_cannot_open_file)
<< FileName << EC.message();
}
- return None;
+ return std::nullopt;
}
// If there is a module that corresponds to this header, suggest it.
if (!findUsableModuleForHeader(
&File->getFileEntry(), Dir ? Dir : File->getFileEntry().getDir(),
RequestingModule, SuggestedModule, IsSystemHeaderDir))
- return None;
+ return std::nullopt;
return *File;
}
SmallString<1024> Path;
StringRef Dest = HM->lookupFilename(Filename, Path);
if (Dest.empty())
- return None;
+ return std::nullopt;
IsInHeaderMap = true;
// function as part of the regular logic that applies to include search paths.
// The case where the target file **does not exist** is handled here:
HS.noteLookupUsage(HS.searchDirIdx(*this), IncludeLoc);
- return None;
+ return std::nullopt;
}
/// Given a framework directory, find the top-most framework directory.
// Framework names must have a '/' in the filename.
size_t SlashPos = Filename.find('/');
if (SlashPos == StringRef::npos)
- return None;
+ return std::nullopt;
// Find out if this is the home for the specified framework, by checking
// HeaderSearch. Possible answers are yes/no and unknown.
// If it is known and in some other directory, fail.
if (CacheEntry.Directory && CacheEntry.Directory != getFrameworkDirRef())
- return None;
+ return std::nullopt;
// Otherwise, construct the path to this framework dir.
// If the framework dir doesn't exist, we fail.
auto Dir = FileMgr.getDirectory(FrameworkName);
if (!Dir)
- return None;
+ return std::nullopt;
// Otherwise, if it does, remember that this is the right direntry for this
// framework.
if (!HS.findUsableModuleForFrameworkHeader(
&File->getFileEntry(), FrameworkPath, RequestingModule,
SuggestedModule, IsSystem))
- return None;
+ return std::nullopt;
} else {
if (!HS.findUsableModuleForHeader(&File->getFileEntry(), getDir(),
RequestingModule, SuggestedModule,
IsSystem))
- return None;
+ return std::nullopt;
}
}
if (File)
return *File;
- return None;
+ return std::nullopt;
}
void HeaderSearch::cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
// If this was an #include_next "/absolute/file", fail.
if (FromDir)
- return None;
+ return std::nullopt;
if (SearchPath)
SearchPath->clear();
// Otherwise, didn't find it. Remember we didn't find this.
CacheLookup.HitIt = search_dir_end();
- return None;
+ return std::nullopt;
}
/// LookupSubframeworkHeader - Look up a subframework for the specified
// FIXME: Should we permit '\' on Windows?
size_t SlashPos = Filename.find('/');
if (SlashPos == StringRef::npos)
- return None;
+ return std::nullopt;
// Look up the base framework name of the ContextFileEnt.
StringRef ContextName = ContextFileEnt->getName();
if (FrameworkPos == StringRef::npos ||
(ContextName[FrameworkPos + DotFrameworkLen] != '/' &&
ContextName[FrameworkPos + DotFrameworkLen] != '\\'))
- return None;
+ return std::nullopt;
SmallString<1024> FrameworkName(ContextName.data(), ContextName.data() +
FrameworkPos +
CacheLookup.first().size() == FrameworkName.size() &&
memcmp(CacheLookup.first().data(), &FrameworkName[0],
CacheLookup.first().size()) != 0)
- return None;
+ return std::nullopt;
// Cache subframework.
if (!CacheLookup.second.Directory) {
// If the framework dir doesn't exist, we fail.
auto Dir = FileMgr.getOptionalDirectoryRef(FrameworkName);
if (!Dir)
- return None;
+ return std::nullopt;
// Otherwise, if it does, remember that this is the right direntry for this
// framework.
File = FileMgr.getOptionalFileRef(HeadersFilename, /*OpenFile=*/true);
if (!File)
- return None;
+ return std::nullopt;
}
// This file is a system header or C++ unfriendly if the old file is.
if (!findUsableModuleForFrameworkHeader(&File->getFileEntry(), FrameworkName,
RequestingModule, SuggestedModule,
/*IsSystem*/ false))
- return None;
+ return std::nullopt;
return *File;
}
/// if used.
/// Returns true if the path exists, false if it was ignored.
bool AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework,
- Optional<unsigned> UserEntryIdx = None);
+ Optional<unsigned> UserEntryIdx = std::nullopt);
/// Add the specified path to the specified group list, without performing any
/// sysroot remapping.
/// Returns true if the path exists, false if it was ignored.
bool AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
bool isFramework,
- Optional<unsigned> UserEntryIdx = None);
+ Optional<unsigned> UserEntryIdx = std::nullopt);
/// Add the specified prefix to the system header prefix list.
void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
const LangOptions &LangOpts) {
if (Loc.isMacroID()) {
if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
- return None;
+ return std::nullopt;
}
Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
bool InvalidTemp = false;
StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
if (InvalidTemp)
- return None;
+ return std::nullopt;
const char *TokenBegin = File.data() + LocInfo.second;
if (!LangOpts.CPlusPlus && !LangOpts.C99) {
if (Diagnose)
Diag(SlashLoc, diag::warn_ucn_not_valid_in_c89);
- return llvm::None;
+ return std::nullopt;
}
const char *CurPtr = StartPtr + CharSize;
if (Diagnose)
Diag(BufferPtr, diag::warn_delimited_ucn_incomplete)
<< StringRef(KindLoc, 1);
- return llvm::None;
+ return std::nullopt;
}
if (CodePoint & 0xF000'0000) {
if (Diagnose)
Diag(KindLoc, diag::err_escape_too_large) << 0;
- return llvm::None;
+ return std::nullopt;
}
CodePoint <<= 4;
Diag(StartPtr, FoundEndDelimiter ? diag::warn_delimited_ucn_empty
: diag::warn_ucn_escape_no_digits)
<< StringRef(KindLoc, 1);
- return llvm::None;
+ return std::nullopt;
}
if (Delimited && Kind == 'U') {
if (Diagnose)
Diag(StartPtr, diag::err_hex_escape_no_digits) << StringRef(KindLoc, 1);
- return llvm::None;
+ return std::nullopt;
}
if (!Delimited && Count != NumHexDigits) {
<< FixItHint::CreateReplacement(URange, "u");
}
}
- return llvm::None;
+ return std::nullopt;
}
if (Delimited && PP) {
if (C != '{') {
if (Diagnose)
Diag(StartPtr, diag::warn_ucn_escape_incomplete);
- return llvm::None;
+ return std::nullopt;
}
CurPtr += CharSize;
const char *StartName = CurPtr;
Diag(StartPtr, FoundEndDelimiter ? diag::warn_delimited_ucn_empty
: diag::warn_delimited_ucn_incomplete)
<< StringRef(KindLoc, 1);
- return llvm::None;
+ return std::nullopt;
}
StringRef Name(Buffer.data(), Buffer.size());
// When finding a match using Unicode loose matching rules
// recover after having emitted a diagnostic.
if (!LooseMatch)
- return llvm::None;
+ return std::nullopt;
// We do not offer misspelled character names suggestions here
// as the set of what would be a valid suggestion depends on context,
// and we should not make invalid suggestions.
expectedToOptional(SourceMgr.getFileManager().getFileRef(Filename));
if (!File || (Header.Size && File->getSize() != *Header.Size) ||
(Header.ModTime && File->getModificationTime() != *Header.ModTime))
- return None;
+ return std::nullopt;
return *File;
};
<< Header.FileName << M->getFullModuleName();
NeedsFramework = true;
}
- return None;
+ return std::nullopt;
}
return NormalHdrFile;
if (RequestingModule) {
resolveUses(RequestingModule, /*Complain=*/false);
- resolveHeaderDirectives(RequestingModule, /*File=*/llvm::None);
+ resolveHeaderDirectives(RequestingModule, /*File=*/std::nullopt);
}
bool Excluded = false;
if (findOrCreateModuleForHeaderInUmbrellaDir(File))
return Headers.find(File)->second;
- return None;
+ return std::nullopt;
}
ArrayRef<ModuleMap::KnownHeader>
resolveHeaderDirectives(File);
auto It = Headers.find(File);
if (It == Headers.end())
- return None;
+ return std::nullopt;
return It->second;
}
Optional<FileEntryRef>
ModuleMap::getContainingModuleMapFile(const Module *Module) const {
if (Module->DefinitionLoc.isInvalid())
- return None;
+ return std::nullopt;
return SourceMgr.getFileEntryRefForID(
SourceMgr.getFileID(Module->DefinitionLoc));
if (SimilarStr) {
return SimilarStr->first;
} else {
- return None;
+ return std::nullopt;
}
}
}
// Otherwise, we really couldn't find the file.
- return None;
+ return std::nullopt;
}
//===----------------------------------------------------------------------===//
return File;
if (SuppressIncludeNotFoundError)
- return None;
+ return std::nullopt;
// If the file could not be located and it was included via angle
// brackets, we can attempt a lookup as though it were a quoted path to
<< CacheEntry.Directory->getName();
}
- return None;
+ return std::nullopt;
}
/// Handle either a #include-like directive or an import declaration that names
// Dump module macros.
llvm::DenseSet<ModuleMacro*> Active;
- for (auto *MM : State ? State->getActiveModuleMacros(*this, II) : None)
+ for (auto *MM :
+ State ? State->getActiveModuleMacros(*this, II) : std::nullopt)
Active.insert(MM);
llvm::DenseSet<ModuleMacro*> Visited;
llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf.begin(), Leaf.end());
// Recover as if it were an explicit specialization.
TemplateParameterLists FakedParamLists;
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
- 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
- LAngleLoc, nullptr));
+ 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc,
+ std::nullopt, LAngleLoc, nullptr));
ThisDecl =
Actions.ActOnTemplateDeclarator(getCurScope(), FakedParamLists, D);
// "template<>", so that we treat this construct as a class
// template specialization.
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
- 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
- LAngleLoc, nullptr));
+ 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc,
+ std::nullopt, LAngleLoc, nullptr));
TemplateParams = &FakedParamLists;
}
}
/*NumExceptions=*/0,
/*NoexceptExpr=*/nullptr,
/*ExceptionSpecTokens=*/nullptr,
- /*DeclsInPrototype=*/None, CaretLoc,
- CaretLoc, ParamInfo),
+ /*DeclsInPrototype=*/std::nullopt,
+ CaretLoc, CaretLoc, ParamInfo),
CaretLoc);
MaybeParseGNUAttributes(ParamInfo);
if (Tok.is(tok::code_completion)) {
cutOffParsing();
Actions.CodeCompleteAvailabilityPlatformName();
- return None;
+ return std::nullopt;
}
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_avail_query_expected_platform_name);
- return None;
+ return std::nullopt;
}
IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
VersionTuple Version = ParseVersionTuple(VersionRange);
if (Version.empty())
- return None;
+ return std::nullopt;
StringRef GivenPlatform = PlatformIdentifier->Ident->getName();
StringRef Platform =
Diag(PlatformIdentifier->Loc,
diag::err_avail_query_unrecognized_platform_name)
<< GivenPlatform;
- return None;
+ return std::nullopt;
}
return AvailabilitySpec(Version, Platform, PlatformIdentifier->Loc,
DynamicExceptions.size(),
NoexceptExpr.isUsable() ? NoexceptExpr.get() : nullptr,
/*ExceptionSpecTokens*/ nullptr,
- /*DeclsInPrototype=*/None, LParenLoc, FunLocalRangeEnd, D,
- TrailingReturnType, TrailingReturnTypeLoc, &DS),
+ /*DeclsInPrototype=*/std::nullopt, LParenLoc, FunLocalRangeEnd,
+ D, TrailingReturnType, TrailingReturnTypeLoc, &DS),
std::move(Attr), DeclEndLoc);
};
if (!getLangOpts().CPlusPlus)
Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
// Match the '}'.
- return Actions.ActOnInitList(LBraceLoc, None, ConsumeBrace());
+ return Actions.ActOnInitList(LBraceLoc, std::nullopt, ConsumeBrace());
}
// Enter an appropriate expression evaluation context for an initializer list.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc, None,
- false);
+ Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
+ std::nullopt, false);
else if (ReceiverType)
- Actions.CodeCompleteObjCClassMessage(getCurScope(), ReceiverType, None,
- false);
+ Actions.CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
+ std::nullopt, false);
else
Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
- None, false);
+ std::nullopt, false);
return ExprError();
}
// We have a valid expression. Collect it in a vector so we can
// build the argument list.
- ObjCDictionaryElement Element = {
- KeyExpr.get(), ValueExpr.get(), EllipsisLoc, None
- };
+ ObjCDictionaryElement Element = {KeyExpr.get(), ValueExpr.get(),
+ EllipsisLoc, std::nullopt};
Elements.push_back(Element);
if (!TryConsumeToken(tok::comma) && Tok.isNot(tok::r_brace))
BalancedDelimiterTracker T(P, tok::l_paren, tok::annot_pragma_openmp_end);
if (T.expectAndConsume(diag::err_expected_lparen_after,
getOpenMPClauseName(Kind).data()))
- return llvm::None;
+ return std::nullopt;
unsigned Type = getOpenMPSimpleClauseType(
Kind, Tok.isAnnotation() ? "" : P.getPreprocessor().getSpelling(Tok),
DKind == OMPD_target_exit_data) {
Actions.ActOnOpenMPRegionStart(DKind, getCurScope());
AssociatedStmt = (Sema::CompoundScopeRAII(Actions),
- Actions.ActOnCompoundStmt(Loc, Loc, llvm::None,
+ Actions.ActOnCompoundStmt(Loc, Loc, std::nullopt,
/*isStmtExpr=*/false));
AssociatedStmt = Actions.ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
}
.Case("reassociate", TokFPAnnotValue::Reassociate)
.Case("exceptions", TokFPAnnotValue::Exceptions)
.Case("eval_method", TokFPAnnotValue::EvalMethod)
- .Default(None);
+ .Default(std::nullopt);
if (!FlagKind) {
PP.Diag(Tok.getLocation(), diag::err_pragma_fp_invalid_option)
<< /*MissingOption=*/false << OptionInfo;
.Case("on", LangOptions::FPModeKind::FPM_On)
.Case("off", LangOptions::FPModeKind::FPM_Off)
.Case("fast", LangOptions::FPModeKind::FPM_Fast)
- .Default(llvm::None);
+ .Default(std::nullopt);
if (!AnnotValue->ContractValue) {
PP.Diag(Tok.getLocation(), diag::err_pragma_fp_invalid_argument)
<< PP.getSpelling(Tok) << OptionInfo->getName() << *FlagKind;
II->getName())
.Case("on", LangOptions::FPModeKind::FPM_On)
.Case("off", LangOptions::FPModeKind::FPM_Off)
- .Default(llvm::None);
+ .Default(std::nullopt);
if (!AnnotValue->ReassociateValue) {
PP.Diag(Tok.getLocation(), diag::err_pragma_fp_invalid_argument)
<< PP.getSpelling(Tok) << OptionInfo->getName() << *FlagKind;
.Case("ignore", LangOptions::FPE_Ignore)
.Case("maytrap", LangOptions::FPE_MayTrap)
.Case("strict", LangOptions::FPE_Strict)
- .Default(llvm::None);
+ .Default(std::nullopt);
if (!AnnotValue->ExceptionsValue) {
PP.Diag(Tok.getLocation(), diag::err_pragma_fp_invalid_argument)
<< PP.getSpelling(Tok) << OptionInfo->getName() << *FlagKind;
.Case("source", LangOptions::FPEvalMethodKind::FEM_Source)
.Case("double", LangOptions::FPEvalMethodKind::FEM_Double)
.Case("extended", LangOptions::FPEvalMethodKind::FEM_Extended)
- .Default(llvm::None);
+ .Default(std::nullopt);
if (!AnnotValue->EvalMethodValue) {
PP.Diag(Tok.getLocation(), diag::err_pragma_fp_invalid_argument)
<< PP.getSpelling(Tok) << OptionInfo->getName() << *FlagKind;
// If the function body could not be parsed, make a bogus compoundstmt.
if (FnBody.isInvalid()) {
Sema::CompoundScopeRAII CompoundScope(Actions);
- FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc, None, false);
+ FnBody =
+ Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc, std::nullopt, false);
}
BodyScope.Exit();
// compound statement as the body.
if (FnBody.isInvalid()) {
Sema::CompoundScopeRAII CompoundScope(Actions);
- FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc, None, false);
+ FnBody =
+ Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc, std::nullopt, false);
}
BodyScope.Exit();
// Recover as if it were an explicit specialization.
TemplateParameterLists FakedParamLists;
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
- 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
- LAngleLoc, nullptr));
+ 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc,
+ std::nullopt, LAngleLoc, nullptr));
return ParseFunctionDefinition(
DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
if (CurParsedObjCImpl) {
// Code-complete Objective-C methods even without leading '-'/'+' prefix.
Actions.CodeCompleteObjCMethodDecl(getCurScope(),
- /*IsInstanceMethod=*/None,
+ /*IsInstanceMethod=*/std::nullopt,
/*ReturnType=*/nullptr);
}
Actions.CodeCompleteOrdinaryName(
Content,
None,
} Kind;
- llvm::Optional<int64_t> Old = llvm::None;
- llvm::Optional<int64_t> New = llvm::None;
+ llvm::Optional<int64_t> Old = std::nullopt;
+ llvm::Optional<int64_t> New = std::nullopt;
};
auto HasInputFileChanged = [&]() {
if (StoredSize != File->getSize())
PP.getHeaderSearchInfo().lookupModule(F.ModuleName, F.ImportLoc);
auto &Map = PP.getHeaderSearchInfo().getModuleMap();
Optional<FileEntryRef> ModMap =
- M ? Map.getModuleMapFileForUniquing(M) : None;
+ M ? Map.getModuleMapFileForUniquing(M) : std::nullopt;
// Don't emit module relocation error if we have -fno-validate-pch
if (!bool(PP.getPreprocessorOpts().DisablePCHOrModuleValidation &
DisableValidationForModuleKind::Module) &&
!ModMap) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities)) {
- if (auto ASTFE = M ? M->getASTFile() : None) {
+ if (auto ASTFE = M ? M->getASTFile() : std::nullopt) {
// This module was defined by an imported (explicit) module.
Diag(diag::err_module_file_conflict) << F.ModuleName << F.FileName
<< ASTFE->getName();
#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
case TYPE_##CODE_ID: return Type::CLASS_ID;
#include "clang/Serialization/TypeBitCodes.def"
- default: return llvm::None;
+ default:
+ return std::nullopt;
}
}
llvm::sys::path::parent_path(MF.FileName),
FileName, MF.Signature);
}
- return None;
+ return std::nullopt;
}
ExternalASTSource::ExtKind ASTReader::hasExternalDefinitions(const Decl *FD) {
// headers list when emitting resolved headers in the first loop below.
// FIXME: It'd be preferable to avoid doing this if we were given
// sufficient stat information in the module map.
- HS.getModuleMap().resolveHeaderDirectives(M, /*File=*/llvm::None);
+ HS.getModuleMap().resolveHeaderDirectives(M, /*File=*/std::nullopt);
// If the file didn't exist, we can still create a module if we were given
// enough information in the module map.
return Common->PartialSpecializations;
}
ArrayRef<Decl> getPartialSpecializations(FunctionTemplateDecl::Common *) {
- return None;
+ return std::nullopt;
}
template<typename DeclTy>
bool ModuleManager::lookupModuleFile(StringRef FileName, off_t ExpectedSize,
time_t ExpectedModTime,
Optional<FileEntryRef> &File) {
- File = None;
+ File = std::nullopt;
if (FileName == "-")
return false;
}
// Illegal vscale result would be less than 1
if (Log2ScaleResult < 0)
- return llvm::None;
+ return std::nullopt;
return 1 << Log2ScaleResult;
}
uint32_t Log2EEW;
if (ComplexTT.second.getAsInteger(10, Log2EEW)) {
llvm_unreachable("Invalid Log2EEW value!");
- return None;
+ return std::nullopt;
}
switch (Log2EEW) {
case 3:
break;
default:
llvm_unreachable("Invalid Log2EEW value, should be [3-6]");
- return None;
+ return std::nullopt;
}
} else if (ComplexTT.first == "FixedSEW") {
uint32_t NewSEW;
if (ComplexTT.second.getAsInteger(10, NewSEW)) {
llvm_unreachable("Invalid FixedSEW value!");
- return None;
+ return std::nullopt;
}
switch (NewSEW) {
case 8:
break;
default:
llvm_unreachable("Invalid FixedSEW value, should be 8, 16, 32 or 64");
- return None;
+ return std::nullopt;
}
} else if (ComplexTT.first == "LFixedLog2LMUL") {
int32_t Log2LMUL;
if (ComplexTT.second.getAsInteger(10, Log2LMUL)) {
llvm_unreachable("Invalid LFixedLog2LMUL value!");
- return None;
+ return std::nullopt;
}
switch (Log2LMUL) {
case -3:
break;
default:
llvm_unreachable("Invalid LFixedLog2LMUL value, should be [-3, 3]");
- return None;
+ return std::nullopt;
}
} else if (ComplexTT.first == "SFixedLog2LMUL") {
int32_t Log2LMUL;
if (ComplexTT.second.getAsInteger(10, Log2LMUL)) {
llvm_unreachable("Invalid SFixedLog2LMUL value!");
- return None;
+ return std::nullopt;
}
switch (Log2LMUL) {
case -3:
break;
default:
llvm_unreachable("Invalid LFixedLog2LMUL value, should be [-3, 3]");
- return None;
+ return std::nullopt;
}
} else {
ArrayRef<PrototypeDescriptor> Prototype) {
// LMUL x NF must be less than or equal to 8.
if ((Log2LMUL >= 1) && (1 << Log2LMUL) * NF > 8)
- return llvm::None;
+ return std::nullopt;
RVVTypes Types;
for (const PrototypeDescriptor &Proto : Prototype) {
auto T = computeType(BT, Log2LMUL, Proto);
if (!T)
- return llvm::None;
+ return std::nullopt;
// Record legal type index
Types.push_back(T.value());
}
return &(It->second);
if (IllegalTypes.count(Idx))
- return llvm::None;
+ return std::nullopt;
// Compute type and record the result.
RVVType T(BT, Log2LMUL, Proto);
}
// Record illegal type index.
IllegalTypes.insert(Idx);
- return llvm::None;
+ return std::nullopt;
}
//===----------------------------------------------------------------------===//
if (ND->getDeclName().isIdentifier())
return ND->getQualifiedNameAsString();
}
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<StringRef> Node::getIdentifier() const {
if (ND->getDeclName().isIdentifier())
return ND->getName();
}
- return llvm::None;
+ return std::nullopt;
}
namespace {
StringRef WorkingDirectory, DependencyConsumer &Consumer,
llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS,
ScanningOutputFormat Format, bool OptimizeArgs, bool EagerLoadModules,
- bool DisableFree, llvm::Optional<StringRef> ModuleName = None)
+ bool DisableFree, llvm::Optional<StringRef> ModuleName = std::nullopt)
: WorkingDirectory(WorkingDirectory), Consumer(Consumer),
DepFS(std::move(DepFS)), Format(Format), OptimizeArgs(OptimizeArgs),
EagerLoadModules(EagerLoadModules), DisableFree(DisableFree),
if (llvm::ErrorOr<EntryRef> Entry =
LocalDepFS->getOrCreateFileSystemEntry(File.getName()))
return Entry->getDirectiveTokens();
- return None;
+ return std::nullopt;
};
}
llvm::Optional<StringRef> parseIWYUPragma(const char *Text) {
// Skip the comment start, // or /*.
if (Text[0] != '/' || (Text[1] != '/' && Text[1] != '*'))
- return llvm::None;
+ return std::nullopt;
bool BlockComment = Text[1] == '*';
Text += 2;
// Per spec, direcitves are whitespace- and case-sensitive.
constexpr llvm::StringLiteral IWYUPragma = " IWYU pragma: ";
if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size()))
- return llvm::None;
+ return std::nullopt;
Text += IWYUPragma.size();
const char *End = Text;
while (*End != 0 && *End != '\n')
// (second) raw_identifier name is checked.
bool checkAndConsumeDirectiveWithName(
Lexer &Lex, StringRef Name, Token &Tok,
- llvm::Optional<StringRef> RawIDName = llvm::None) {
+ llvm::Optional<StringRef> RawIDName = std::nullopt) {
bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
Tok.is(tok::raw_identifier) &&
Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&
for (const auto &Inc : It->second)
if ((IsAngled && StringRef(Inc.Name).startswith("<")) ||
(!IsAngled && StringRef(Inc.Name).startswith("\"")))
- return llvm::None;
+ return std::nullopt;
std::string Quoted =
std::string(llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName));
StringRef QuotedName = Quoted;
ensureInitialized();
auto It = HeaderIDs->find(Name);
if (It == HeaderIDs->end())
- return llvm::None;
+ return std::nullopt;
return Header(It->second);
}
llvm::StringRef Header::name() const { return HeaderNames[ID]; }
if (It != NSSymbols->end())
return Symbol(It->second);
}
- return llvm::None;
+ return std::nullopt;
}
Header Symbol::header() const { return Header(SymbolHeaderIDs[ID]); }
llvm::SmallVector<Header> Symbol::headers() const {
}
NSSymbolMap *Symbols = namespaceSymbols(cast_or_null<NamespaceDecl>(DC));
if (!Symbols)
- return llvm::None;
+ return std::nullopt;
llvm::StringRef Name = [&]() -> llvm::StringRef {
for (const auto *SymDC : llvm::reverse(IntermediateDecl)) {
return "";
}();
if (Name.empty())
- return llvm::None;
+ return std::nullopt;
auto It = Symbols->find(Name);
if (It == Symbols->end())
- return llvm::None;
+ return std::nullopt;
return Symbol(It->second);
}
Type = foldType(*Type);
// The contract is to store None instead of TY_INVALID.
if (Type == types::TY_INVALID)
- Type = llvm::None;
+ Type = std::nullopt;
}
// Produce a CompileCommand for \p filename, based on this one.
if (Opt.matches(driver::options::OPT_x))
return types::lookupTypeForTypeSpecifier(Arg.getValue());
}
- return None;
+ return std::nullopt;
}
// Try to interpret the argument as '-std='.
using namespace driver::options;
if (Arg.getOption().matches(ClangCLMode ? OPT__SLASH_std : OPT_std_EQ))
return LangStandard::getLangKind(Arg.getValue());
- return None;
+ return std::nullopt;
}
};
SelectedASTNode Result = std::move(SelectionStack.back());
SelectionStack.pop_back();
if (Result.Children.empty())
- return None;
+ return std::nullopt;
return std::move(Result);
}
const SelectedASTNode &ASTSelection) {
// Code range is selected when the selection range is not empty.
if (SelectionRange.getBegin() == SelectionRange.getEnd())
- return None;
+ return std::nullopt;
llvm::SmallVector<SelectedNodeWithParents, 4> ContainSelection;
findDeepestWithKind(ASTSelection, ContainSelection,
SourceSelectionKind::ContainsSelection);
// We are looking for a selection in one body of code, so let's focus on
// one matching result.
if (ContainSelection.size() != 1)
- return None;
+ return std::nullopt;
SelectedNodeWithParents &Selected = ContainSelection[0];
if (!Selected.Node.get().Node.get<Stmt>())
- return None;
+ return std::nullopt;
const Stmt *CodeRangeStmt = Selected.Node.get().Node.get<Stmt>();
if (!isa<CompoundStmt>(CodeRangeStmt)) {
Selected.canonicalize();
// Mapping an empty range is ambiguous in case of empty mappings at either end
// of the range, bail out in that case.
if (Expanded.empty())
- return llvm::None;
+ return std::nullopt;
const syntax::Token *First = &Expanded.front();
const syntax::Token *Last = &Expanded.back();
auto [FirstSpelled, FirstMapping] = spelledForExpandedToken(First);
FileID FID = SourceMgr->getFileID(FirstSpelled->location());
// FIXME: Handle multi-file changes by trying to map onto a common root.
if (FID != SourceMgr->getFileID(LastSpelled->location()))
- return llvm::None;
+ return std::nullopt;
const MarkedFile &File = Files.find(FID)->second;
SourceRange Range = spelledForExpandedSlow(
First->location(), Last->location(), Prev, Next, FID, *SourceMgr);
if (Range.isInvalid())
- return llvm::None;
+ return std::nullopt;
return getTokensCovering(File.SpelledTokens, Range, *SourceMgr);
}
unsigned FirstExpanded = Expanded.begin() - ExpandedTokens.data();
unsigned LastExpanded = Expanded.end() - ExpandedTokens.data();
if (FirstMapping && FirstExpanded != FirstMapping->BeginExpanded)
- return llvm::None;
+ return std::nullopt;
if (LastMapping && LastMapping->EndExpanded != LastExpanded)
- return llvm::None;
+ return std::nullopt;
return llvm::makeArrayRef(
FirstMapping ? File.SpelledTokens.data() + FirstMapping->BeginSpelled
: FirstSpelled,
return M.BeginSpelled < SpelledIndex;
});
if (M == File.Mappings.end() || M->BeginSpelled != SpelledIndex)
- return llvm::None;
+ return std::nullopt;
return makeExpansion(File, *M);
}
// In the simplest case, skips spelled tokens until finding one that produced
// the NextExpanded token, and creates an empty mapping for them.
// If Drain is provided, skips remaining tokens from that file instead.
- void discard(llvm::Optional<FileID> Drain = llvm::None) {
+ void discard(llvm::Optional<FileID> Drain = std::nullopt) {
SourceLocation Target =
Drain ? SM.getLocForEndOfFile(*Drain)
: SM.getExpansionLoc(
llvm::StringRef Key) {
auto it = Map.find(Key);
if (it == Map.end())
- return llvm::None;
+ return std::nullopt;
return it->second;
}
if (State.Input.empty() || State.Input.front() != c)
return makeParseError(State,
("expected char not found: " + llvm::Twine(c)).str());
- return makeParseProgress(advance(State, 1), llvm::None);
+ return makeParseProgress(advance(State, 1), std::nullopt);
}
// Parses an identitifer "token" -- handles preceding whitespace.
CharSourceRange Range = Lexer::makeFileCharRange(EditRange, SM, LangOpts);
bool IsInvalid = llvm::errorToBool(validateEditRange(Range, SM));
if (IsInvalid)
- return llvm::None;
+ return std::nullopt;
return Range;
}
const ASTContext &Context) {
StringRef Text = getText(E, Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
if (mayEverNeedParens(E))
return ("(" + Text + ")").str();
return Text.str();
StringRef Text =
getText(*Op->getSubExpr()->IgnoreParenImpCasts(), Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
return Text.str();
}
StringRef Text = getText(E, Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
// Add leading '*'.
if (needParensAfterUnaryOperator(E))
return ("*(" + Text + ")").str();
StringRef Text =
getText(*Op->getSubExpr()->IgnoreParenImpCasts(), Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
return Text.str();
}
// Add leading '&'.
StringRef Text = getText(E, Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
if (needParensAfterUnaryOperator(E)) {
return ("&(" + Text + ")").str();
}
const Expr *SubExpr = Op->getSubExpr()->IgnoreParenImpCasts();
StringRef DerefText = getText(*SubExpr, Context);
if (DerefText.empty())
- return llvm::None;
+ return std::nullopt;
if (needParensBeforeDotOrArrow(*SubExpr))
return ("(" + DerefText + ")->").str();
return (DerefText + "->").str();
// Add following '.'.
StringRef Text = getText(E, Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
if (needParensBeforeDotOrArrow(E)) {
return ("(" + Text + ").").str();
}
const Expr *SubExpr = Op->getSubExpr()->IgnoreParenImpCasts();
StringRef DerefText = getText(*SubExpr, Context);
if (DerefText.empty())
- return llvm::None;
+ return std::nullopt;
if (needParensBeforeDotOrArrow(*SubExpr))
return ("(" + DerefText + ").").str();
return (DerefText + ".").str();
// Add following '->'.
StringRef Text = getText(E, Context);
if (Text.empty())
- return llvm::None;
+ return std::nullopt;
if (needParensBeforeDotOrArrow(E))
return ("(" + Text + ")->").str();
return (Text + "->").str();
if (sys::fs::exists(Path))
return static_cast<std::string>(Path);
- return None;
+ return std::nullopt;
}
Optional<std::string> findFromSearchPaths(StringRef Name, StringRef Root,
for (StringRef Dir : SearchPaths)
if (Optional<std::string> File = findFile(Dir, Root, Name))
return File;
- return None;
+ return std::nullopt;
}
Optional<std::string> searchLibraryBaseName(StringRef Name, StringRef Root,
if (Optional<std::string> File = findFile(Dir, Root, "lib" + Name + ".a"))
return File;
}
- return None;
+ return std::nullopt;
}
/// Search for static libraries in the linker's library path given input like
Value = CLOpt.getValue();
return;
}
- Value = None;
+ Value = std::nullopt;
if (Opt.isRequired())
MissingRequiredOptions.push_back(&Opt);
}
if (!ErrOrFile) {
llvm::errs() << "error: -selection=test:" << Filename
<< " : could not open the given file";
- return None;
+ return std::nullopt;
}
StringRef Source = ErrOrFile.get()->getBuffer();
// Allow CHECK: comments to contain range= commands.
if (!RangeRegex.match(Comment, &Matches) || Comment.contains("CHECK")) {
if (DetectMistypedCommand())
- return None;
+ return std::nullopt;
continue;
}
unsigned Offset = Tok.getEndLoc().getRawEncoding();
SmallVector<StringRef, 4> EndLocMatches;
if (!EndLocRegex.match(Matches[3], &EndLocMatches)) {
if (DetectMistypedCommand())
- return None;
+ return std::nullopt;
continue;
}
unsigned EndLineOffset = 0, EndColumn = 0;
if (GroupedRanges.empty()) {
llvm::errs() << "error: -selection=test:" << Filename
<< ": no 'range' commands";
- return None;
+ return std::nullopt;
}
TestSelectionRangesInFile TestRanges = {Filename.str(), {}};
if (DiagName == Name)
return Diag;
}
- return None;
+ return std::nullopt;
}
int FindDiagnosticID::run(unsigned int argc, char **argv,
// the target machine will handle the mcpu printing
llvm::TargetOptions Options;
std::unique_ptr<llvm::TargetMachine> TheTargetMachine(
- TheTarget->createTargetMachine(TargetStr, "", "+cpuhelp", Options, None));
+ TheTarget->createTargetMachine(TargetStr, "", "+cpuhelp", Options,
+ std::nullopt));
return 0;
}
}
}
- return None;
+ return std::nullopt;
}
std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes);
.Case("crash", Driver::ReproLevel::OnCrash)
.Case("error", Driver::ReproLevel::OnError)
.Case("always", Driver::ReproLevel::Always)
- .Default(None);
+ .Default(std::nullopt);
if (!Level) {
llvm::errs() << "Unknown value for " << A->getSpelling() << ": '"
<< A->getValue() << "'\n";
if (RegionOfInterest.isValid()) {
SourceRange Range = getFullCursorExtent(Cursor, AU->getSourceManager());
if (Range.isInvalid())
- return None;
+ return std::nullopt;
switch (CompareRegionOfInterest(Range)) {
case RangeBefore:
// This declaration comes before the region of interest; skip it.
- return None;
+ return std::nullopt;
case RangeAfter:
// This declaration comes after the region of interest; we're done.
// we passed the region-of-interest.
if (auto *ivarD = dyn_cast<ObjCIvarDecl>(D)) {
if (ivarD->getSynthesize())
- return None;
+ return std::nullopt;
}
// FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol
const Optional<bool> V = shouldVisitCursor(Cursor);
if (!V)
- return None;
+ return std::nullopt;
if (!V.value())
return false;
if (Visit(Cursor, true))
return true;
- return None;
+ return std::nullopt;
}
bool CursorVisitor::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
LibclangInvocationReporter InvocationReporter(
*CXXIdx, LibclangInvocationReporter::OperationKind::ParseOperation,
- options, llvm::makeArrayRef(*Args), /*InvocationArgs=*/None,
+ options, llvm::makeArrayRef(*Args), /*InvocationArgs=*/std::nullopt,
unsaved_files);
std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCommandLine(
Args->data(), Args->data() + Args->size(),
return TemplateDecl->getTemplateArgs().asArray();
}
- return None;
+ return std::nullopt;
}
static Optional<QualType> TemplateArgumentToQualType(const TemplateArgument &A) {
if (A.getKind() == TemplateArgument::Type)
return A.getAsType();
- return None;
+ return std::nullopt;
}
static Optional<QualType>
return TemplateArgumentToQualType(A);
current++;
}
- return None;
+ return std::nullopt;
}
CXType clang_getCursorType(CXCursor C) {
std::make_unique<Rev>(Arg1.first.getElementSizeInBits()));
ST.addExpander("MaskExpand",
std::make_unique<MaskExpander>(Arg1.first.getNumElements()));
- ST.evaluate(DI->getArg(2), Elts, None);
+ ST.evaluate(DI->getArg(2), Elts, std::nullopt);
std::string S = "__builtin_shufflevector(" + Arg1.second + ", " + Arg2.second;
for (auto &E : Elts) {