const auto &Iter = CheckOptions.find((NamePrefix + LocalName).str());
if (Iter != CheckOptions.end())
return StringRef(Iter->getValue().Value);
- return None;
+ return std::nullopt;
}
static ClangTidyOptions::OptionMap::const_iterator
Context->getOptionsCollector());
if (Iter != CheckOptions.end())
return StringRef(Iter->getValue().Value);
- return None;
+ return std::nullopt;
}
static Optional<bool> getAsBool(StringRef Value,
long long Number;
if (!Value.getAsInteger(10, Number))
return Number != 0;
- return None;
+ return std::nullopt;
}
template <>
return Result;
diagnoseBadBooleanOption(NamePrefix + LocalName, *ValueOr);
}
- return None;
+ return std::nullopt;
}
template <>
return Result;
diagnoseBadBooleanOption(Iter->getKey(), Iter->getValue().Value);
}
- return None;
+ return std::nullopt;
}
void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
Context->getOptionsCollector())
: CheckOptions.find((NamePrefix + LocalName).str());
if (Iter == CheckOptions.end())
- return None;
+ return std::nullopt;
StringRef Value = Iter->getValue().Value;
StringRef Closest;
diagnoseBadEnumOption(Iter->getKey(), Iter->getValue().Value, Closest);
else
diagnoseBadEnumOption(Iter->getKey(), Iter->getValue().Value);
- return None;
+ return std::nullopt;
}
static constexpr llvm::StringLiteral ConfigWarning(
return Result;
diagnoseBadIntegerOption(NamePrefix + LocalName, *Value);
}
- return None;
+ return std::nullopt;
}
/// Read a named option from the ``Context`` and parse it as an
IsGlobal = true;
ValueOr = getLocalOrGlobal(LocalName);
if (!ValueOr)
- return None;
+ return std::nullopt;
}
T Result{};
if (!StringRef(*ValueOr).getAsInteger(10, Result))
return Result;
diagnoseBadIntegerOption(
IsGlobal ? Twine(LocalName) : NamePrefix + LocalName, *ValueOr);
- return None;
+ return std::nullopt;
}
/// Read a named option from the ``Context`` and parse it as an
if (llvm::Optional<int64_t> ValueOr =
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
return static_cast<T>(*ValueOr);
- return None;
+ return std::nullopt;
}
/// Read a named option from the ``Context`` and parse it as an
if (llvm::Optional<int64_t> ValueOr =
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
return static_cast<T>(*ValueOr);
- return None;
+ return std::nullopt;
}
/// Read a named option from the ``Context`` and parse it as an
llvm::Optional<ClangTidyProfiling::StorageParams>
ClangTidyContext::getProfileStorageParams() const {
if (ProfilePrefix.empty())
- return llvm::None;
+ return std::nullopt;
return ClangTidyProfiling::StorageParams(ProfilePrefix, CurrentFile);
}
Options.HeaderFilterRegex = "";
Options.SystemHeaders = false;
Options.FormatStyle = "none";
- Options.User = llvm::None;
+ Options.User = std::nullopt;
for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
if (!DirectoryStatus || !DirectoryStatus->isDirectory()) {
llvm::errs() << "Error reading configuration from " << Directory
<< ": directory doesn't exist.\n";
- return llvm::None;
+ return std::nullopt;
}
for (const ConfigFileHandler &ConfigHandler : ConfigHandlers) {
}
return OptionsSource(*ParsedOptions, std::string(ConfigFile));
}
- return llvm::None;
+ return std::nullopt;
}
/// Parses -line-filter option and stores it to the \c Options.
.Case("NOLINTNEXTLINE", NoLintType::NoLintNextLine)
.Case("NOLINTBEGIN", NoLintType::NoLintBegin)
.Case("NOLINTEND", NoLintType::NoLintEnd)
- .Default(None);
+ .Default(std::nullopt);
return Type;
}
.Case("Seconds", DurationScale::Seconds)
.Case("Minutes", DurationScale::Minutes)
.Case("Hours", DurationScale::Hours)
- .Default(llvm::None);
+ .Default(std::nullopt);
}
// Given either an integer or float literal, return its value.
break;
}
- return llvm::None;
+ return std::nullopt;
}
// Given the scale of a duration and a `Multiplier`, determine if `Multiplier`
OldScale = std::get<0>(*Result);
}
- return llvm::None;
+ return std::nullopt;
}
void DurationFactoryScaleCheck::registerMatchers(MatchFinder *Finder) {
double Value = FloatLiteral.getValueAsApproximateDouble();
if (std::fmod(Value, 1) == 0) {
if (Value >= static_cast<double>(1u << 31))
- return llvm::None;
+ return std::nullopt;
return llvm::APSInt::get(static_cast<int64_t>(Value));
}
- return llvm::None;
+ return std::nullopt;
}
const std::pair<llvm::StringRef, llvm::StringRef> &
return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
}
- return llvm::None;
+ return std::nullopt;
}
/// If `Node` is a call to the inverse of `Scale`, return that inverse's
return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
}
- return llvm::None;
+ return std::nullopt;
}
/// Returns the factory function name for a given `Scale`.
Node, *Result.Context)))
return tooling::fixit::getText(*MaybeCastArg, *Result.Context).str();
- return llvm::None;
+ return std::nullopt;
}
llvm::Optional<std::string>
if (llvm::Optional<llvm::APSInt> IntValue = truncateIfIntegral(*LitFloat))
return toString(*IntValue, /*radix=*/10);
- return llvm::None;
+ return std::nullopt;
}
std::string simplifyDurationFactoryArg(const MatchFinder::MatchResult &Result,
auto ScaleIter = ScaleMap.find(std::string(Name));
if (ScaleIter == ScaleMap.end())
- return llvm::None;
+ return std::nullopt;
return ScaleIter->second;
}
auto ScaleIter = ScaleMap.find(std::string(Name));
if (ScaleIter == ScaleMap.end())
- return llvm::None;
+ return std::nullopt;
return ScaleIter->second;
}
// Now replace the " with '.
std::string::size_type Pos = Result.find_first_of('"');
if (Pos == Result.npos)
- return llvm::None;
+ return std::nullopt;
Result[Pos] = '\'';
Pos = Result.find_last_of('"');
if (Pos == Result.npos)
- return llvm::None;
+ return std::nullopt;
Result[Pos] = '\'';
return Result;
}
const auto TryExpandAsInteger =
[](Preprocessor::macro_iterator It) -> Optional<unsigned> {
if (It == PP->macro_end())
- return llvm::None;
+ return std::nullopt;
const MacroInfo *MI = PP->getMacroInfo(It->first);
const Token &T = MI->tokens().back();
if (!T.isLiteral() || !T.getLiteralData())
- return llvm::None;
+ return std::nullopt;
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
llvm::APInt IntValue;
constexpr unsigned AutoSenseRadix = 0;
if (ValueStr.getAsInteger(AutoSenseRadix, IntValue))
- return llvm::None;
+ return std::nullopt;
return IntValue.getZExtValue();
};
auto MemcpyS = Match({"memcpy_s", 0, 2, 3, false});
// void *memchr(const void *src, int c, size_t count)
- auto Memchr = Match({"memchr", None, 0, 2, false});
+ auto Memchr = Match({"memchr", std::nullopt, 0, 2, false});
// void *memmove(void *dest, const void *src, size_t count)
auto Memmove = Match({"memmove", 0, 1, 2, false});
auto MemmoveS = Match({"memmove_s", 0, 2, 3, false});
// int strncmp(const char *str1, const char *str2, size_t count);
- auto StrncmpRHS = Match({"strncmp", None, 1, 2, true});
- auto StrncmpLHS = Match({"strncmp", None, 0, 2, true});
+ auto StrncmpRHS = Match({"strncmp", std::nullopt, 1, 2, true});
+ auto StrncmpLHS = Match({"strncmp", std::nullopt, 0, 2, true});
// size_t strxfrm(char *dest, const char *src, size_t count);
auto Strxfrm = Match({"strxfrm", 0, 1, 2, false});
// errno_t strerror_s(char *buffer, size_t bufferSize, int errnum);
- auto StrerrorS = Match({"strerror_s", 0, None, 1, false});
+ auto StrerrorS = Match({"strerror_s", 0, std::nullopt, 1, false});
auto AnyOfMatchers = anyOf(Memcpy, MemcpyS, Memmove, MemmoveS, StrncmpRHS,
StrncmpLHS, Strxfrm, StrerrorS);
getDoubleUnderscoreFixup(StringRef Name, const LangOptions &LangOpts) {
if (hasReservedDoubleUnderscore(Name, LangOpts))
return collapseConsecutive(Name, '_');
- return None;
+ return std::nullopt;
}
static bool startsWithUnderscoreCapital(StringRef Name) {
static Optional<std::string> getUnderscoreCapitalFixup(StringRef Name) {
if (startsWithUnderscoreCapital(Name))
return std::string(Name.drop_front(1));
- return None;
+ return std::nullopt;
}
static bool startsWithUnderscoreInGlobalNamespace(StringRef Name,
getUnderscoreGlobalNamespaceFixup(StringRef Name, bool IsInGlobalNamespace) {
if (startsWithUnderscoreInGlobalNamespace(Name, IsInGlobalNamespace))
return std::string(Name.drop_front(1));
- return None;
+ return std::nullopt;
}
static std::string getNonReservedFixup(std::string Name) {
ArrayRef<StringRef> AllowedIdentifiers) {
assert(!Name.empty());
if (llvm::is_contained(AllowedIdentifiers, Name))
- return None;
+ return std::nullopt;
// TODO: Check for names identical to language keywords, and other names
// specifically reserved by language standards, e.g. C++ 'zombie names' and C
startsWithUnderscoreCapital(Name) ||
startsWithUnderscoreInGlobalNamespace(Name, IsInGlobalNamespace)))
return FailureInfo{NonReservedTag, getNonReservedFixup(std::string(Name))};
- return None;
+ return std::nullopt;
}
Optional<RenamerClangTidyCheck::FailureInfo>
if (SizeExpr->EvaluateAsRValue(Result, Ctx))
return Ctx.toBits(
CharUnits::fromQuantity(Result.Val.getInt().getExtValue()));
- return None;
+ return std::nullopt;
}
void SuspiciousMemoryComparisonCheck::registerMatchers(MatchFinder *Finder) {
Expected<ControlFlowContext> Context =
ControlFlowContext::build(&FuncDecl, FuncDecl.getBody(), &ASTCtx);
if (!Context)
- return llvm::None;
+ return std::nullopt;
dataflow::DataflowAnalysisContext AnalysisContext(
std::make_unique<dataflow::WatchedLiteralsSolver>());
llvm::move(EltDiagnostics, std::back_inserter(Diagnostics));
});
if (!BlockToOutputState)
- return llvm::None;
+ return std::nullopt;
return Diagnostics;
}
getVirtualKeywordRange(const CXXDestructorDecl &Destructor,
const SourceManager &SM, const LangOptions &LangOpts) {
if (Destructor.getLocation().isMacroID())
- return None;
+ return std::nullopt;
SourceLocation VirtualBeginLoc = Destructor.getBeginLoc();
SourceLocation VirtualBeginSpellingLoc =
/// virtual is included.
Optional<Token> NextToken = Lexer::findNextToken(VirtualEndLoc, SM, LangOpts);
if (!NextToken)
- return None;
+ return std::nullopt;
SourceLocation StartOfNextToken = NextToken->getLocation();
return CharSourceRange::getCharRange(VirtualBeginLoc, StartOfNextToken);
return Mapping.second;
}
- return llvm::None;
+ return std::nullopt;
}
namespace {
.Case("io_state", "iostate")
.Case("open_mode", "openmode")
.Case("seek_dir", "seekdir")
- .Default(llvm::None);
+ .Default(std::nullopt);
}
void DeprecatedIosBaseAliasesCheck::registerMatchers(MatchFinder *Finder) {
// If the Token/Macro contains more than one type of tokens, we would need
// to split the macro in order to move parts to the trailing return type.
if (ContainsQualifiers + ContainsSpecifiers + ContainsSomethingElse > 1)
- return llvm::None;
+ return std::nullopt;
return CT;
}
if (!MI || MI->isFunctionLike()) {
// Cannot handle function style macros.
diag(F.getLocation(), Message);
- return llvm::None;
+ return std::nullopt;
}
}
ClassifiedTokens.push_back(*CT);
else {
diag(F.getLocation(), Message);
- return llvm::None;
+ return std::nullopt;
}
}
StringRef Ownership) {
size_t Index = Text.find(Ownership);
if (Index == StringRef::npos)
- return llvm::None;
+ return std::nullopt;
SourceLocation Begin = Range.getBegin().getLocWithOffset(Index);
SourceLocation End = Begin.getLocWithOffset(Ownership.size());
assert(VD && "VarDecl parameter must not be null");
// Don't provide fix-its for any parameter variables at this time.
if (isa<ParmVarDecl>(VD))
- return llvm::None;
+ return std::nullopt;
// Currently there is no way to directly get the source range for the
// __weak/__strong ObjC lifetime qualifiers, so it's necessary to string
if (Range.isInvalid()) {
// An invalid range likely means inside a macro, in which case don't supply
// a fix-it.
- return llvm::None;
+ return std::nullopt;
}
StringRef VarDeclText = Lexer::getSourceText(Range, SM, LangOpts);
// Now replace the " with '.
auto Pos = Result.find_first_of('"');
if (Pos == Result.npos)
- return llvm::None;
+ return std::nullopt;
Result[Pos] = '\'';
Pos = Result.find_last_of('"');
if (Pos == Result.npos)
- return llvm::None;
+ return std::nullopt;
Result[Pos] = '\'';
return Result;
}
bool Invalid;
const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
if (Invalid) {
- return llvm::None;
+ return std::nullopt;
}
size_t Offset = std::strcspn(TextAfter, "\n");
return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);
findConstToRemove(const FunctionDecl *Def,
const MatchFinder::MatchResult &Result) {
if (!Def->getReturnType().isLocalConstQualified())
- return None;
+ return std::nullopt;
// Get the begin location for the function name, including any qualifiers
// written in the source (for out-of-line declarations). A FunctionDecl's
*Result.SourceManager, Result.Context->getLangOpts());
if (FileRange.isInvalid())
- return None;
+ return std::nullopt;
return utils::lexer::getQualifyingToken(
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
const IdentifierNamingCheck::HungarianNotationOption &HNOption,
StyleKind SK, const SourceManager &SM, bool IgnoreFailedSplit) const {
if (SK == SK_Invalid || !NamingStyles[SK])
- return None;
+ return std::nullopt;
const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK];
if (Style.IgnoredRegexp.isValid() && Style.IgnoredRegexp.match(Name))
- return None;
+ return std::nullopt;
if (matchesStyle(Type, Name, Style, HNOption, ND))
- return None;
+ return std::nullopt;
std::string KindName =
fixupWithCase(Type, StyleNames[SK], ND, Style, HNOption,
<< llvm::formatv(": unable to split words for {0} '{1}'\n",
KindName, Name));
}
- return None;
+ return std::nullopt;
}
return RenamerClangTidyCheck::FailureInfo{std::move(KindName),
std::move(Fixup)};
SourceLocation Loc = Decl->getLocation();
const FileStyle &FileStyle = getStyleForFile(SM.getFilename(Loc));
if (!FileStyle.isActive())
- return llvm::None;
+ return std::nullopt;
return getFailureInfo(HungarianNotation.getDeclTypeName(Decl),
Decl->getName(), Decl, Loc, FileStyle.getStyles(),
SourceLocation Loc = MacroNameTok.getLocation();
const FileStyle &Style = getStyleForFile(SM.getFilename(Loc));
if (!Style.isActive())
- return llvm::None;
+ return std::nullopt;
return getFailureInfo("", MacroNameTok.getIdentifierInfo()->getName(),
nullptr, Loc, Style.getStyles(), Style.getHNOption(),
const LangOptions &LangOpts) {
std::size_t DeclCount = std::distance(DS->decl_begin(), DS->decl_end());
if (DeclCount < 2)
- return None;
+ return std::nullopt;
if (rangeContainsExpansionsOrDirectives(DS->getSourceRange(), SM, LangOpts))
- return None;
+ return std::nullopt;
// The initial type of the declaration and each declaration has it's own
// slice. This is necessary, because pointers and references bind only
const auto *FirstDecl = dyn_cast<VarDecl>(*DS->decl_begin());
if (FirstDecl == nullptr)
- return None;
+ return std::nullopt;
// FIXME: Member pointers are not transformed correctly right now, that's
// why they are treated as problematic here.
if (typeIsMemberPointer(FirstDecl->getType().IgnoreParens().getTypePtr()))
- return None;
+ return std::nullopt;
// Consider the following case: 'int * pointer, value = 42;'
// Created slices (inclusive) [ ][ ] [ ]
SourceRange DeclRange(DS->getBeginLoc(), Start);
if (DeclRange.isInvalid() || isMacroID(DeclRange))
- return None;
+ return std::nullopt;
// The first slice, that is prepended to every isolated declaration, is
// created.
// FIXME: Member pointers are not transformed correctly right now, that's
// why they are treated as problematic here.
if (typeIsMemberPointer(CurrentDecl->getType().IgnoreParens().getTypePtr()))
- return None;
+ return std::nullopt;
SourceLocation DeclEnd =
CurrentDecl->hasInit()
SourceRange VarNameRange(DeclBegin, DeclEnd);
if (VarNameRange.isInvalid() || isMacroID(VarNameRange))
- return None;
+ return std::nullopt;
Slices.emplace_back(VarNameRange);
DeclBegin = DeclEnd.getLocWithOffset(1);
LangOpts);
if (CharRange.isInvalid())
- return None;
+ return std::nullopt;
bool InvalidText = false;
StringRef Snippet =
Lexer::getSourceText(CharRange, SM, LangOpts, &InvalidText);
if (InvalidText)
- return None;
+ return std::nullopt;
Snippets.emplace_back(Snippet);
}
} else if (T->is(tok::coloncolon)) {
Result.append("::");
} else { // Any other kind of token is unexpected here.
- return llvm::None;
+ return std::nullopt;
}
}
}
Result.Context->getLangOpts());
if (FileRange.isInvalid())
- return llvm::None;
+ return std::nullopt;
tok::TokenKind Tok =
Qual == Qualifier::Const
if (TypeSpecifier.getBegin().isMacroID() ||
TypeSpecifier.getEnd().isMacroID())
- return llvm::None;
+ return std::nullopt;
return TypeSpecifier;
}
const Token &ConstToken) {
if (TypeSpecifier.getBegin().getLocWithOffset(-1) == ConstToken.getEndLoc()) {
TypeSpecifier.setBegin(ConstToken.getLocation());
- return llvm::None;
+ return std::nullopt;
}
if (TypeSpecifier.getEnd().getLocWithOffset(1) == ConstToken.getLocation()) {
TypeSpecifier.setEnd(ConstToken.getEndLoc());
- return llvm::None;
+ return std::nullopt;
}
return SourceRange(ConstToken.getLocation(), ConstToken.getEndLoc());
}
E = Arg->getEndLoc();
}
if (B.isInvalid() || E.isInvalid())
- return llvm::None;
+ return std::nullopt;
return SourceRange(B, E);
}
static Optional<bool> getAsBoolLiteral(const Expr *E, bool FilterMacro) {
if (const auto *Bool = dyn_cast<CXXBoolLiteralExpr>(E)) {
if (FilterMacro && Bool->getBeginLoc().isMacroID())
- return llvm::None;
+ return std::nullopt;
return Bool->getValue();
}
if (const auto *UnaryOp = dyn_cast<UnaryOperator>(E)) {
if (FilterMacro && UnaryOp->getBeginLoc().isMacroID())
- return None;
+ return std::nullopt;
if (UnaryOp->getOpcode() == UO_LNot)
if (Optional<bool> Res = getAsBoolLiteral(
UnaryOp->getSubExpr()->IgnoreImplicit(), FilterMacro))
return !*Res;
}
- return llvm::None;
+ return std::nullopt;
}
template <typename Node> struct NodeAndBool {
assert(Idx < HeuristicCount);
if (!Defaults[Idx].hasBounds())
- return None;
+ return std::nullopt;
switch (BK) {
case BoundKind::DissimilarBelow:
const SourceManager &SM) {
// Do nothing if the provided location is invalid.
if (Loc.isInvalid())
- return llvm::None;
+ return std::nullopt;
// Look where the location was *actually* written.
SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
if (SpellingLoc.isInvalid())
- return llvm::None;
+ return std::nullopt;
return SpellingLoc;
}
getMacroAwareLocation(Loc.getBegin(), SM);
llvm::Optional<SourceLocation> End = getMacroAwareLocation(Loc.getEnd(), SM);
if (!Begin || !End)
- return llvm::None;
+ return std::nullopt;
return SourceRange(*Begin, *End);
}
if (NewSuffix != NewSuffixes.end())
return NewSuffix->str();
// Nope, I guess we have to keep it as-is.
- return llvm::None;
+ return std::nullopt;
}
template <typename LiteralType>
llvm::Optional<SourceRange> Range =
getMacroAwareSourceRange(ReplacementDsc.LiteralLocation, SM);
if (!Range)
- return llvm::None;
+ return std::nullopt;
if (RangeCanBeFixed)
ReplacementDsc.LiteralLocation = *Range;
// Make sure the first character is actually a digit, instead of
// something else, like a non-type template parameter.
if (!std::isdigit(static_cast<unsigned char>(LiteralSourceText.front())))
- return llvm::None;
+ return std::nullopt;
size_t Skip = 0;
// We can't check whether the *Literal has any suffix or not without actually
// looking for the suffix. So it is totally possible that there is no suffix.
if (Skip == StringRef::npos)
- return llvm::None;
+ return std::nullopt;
// Move the cursor in the source range to the beginning of the suffix.
Range->setBegin(Range->getBegin().getLocWithOffset(Skip));
llvm::Optional<std::string> NewSuffix =
getNewSuffix(ReplacementDsc.OldSuffix, NewSuffixes);
if (!NewSuffix || ReplacementDsc.OldSuffix == *NewSuffix)
- return llvm::None; // The suffix was already the way it should be.
+ return std::nullopt; // The suffix was already the way it should be.
if (RangeCanBeFixed)
ReplacementDsc.FixIt = FixItHint::CreateReplacement(*Range, *NewSuffix);
getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions) {
StringRef Extension = llvm::sys::path::extension(FileName);
if (Extension.empty())
- return llvm::None;
+ return std::nullopt;
// Skip "." prefix.
if (!FileExtensions.count(Extension.substr(1)))
- return llvm::None;
+ return std::nullopt;
return Extension;
}
static Optional<SourceLocation>
skipLParensBackwards(SourceLocation Start, const ASTContext &Context) {
if (locDangerous(Start))
- return None;
+ return std::nullopt;
auto PreviousTokenLParen = [&Start, &Context]() {
Token T;
Context.getLangOpts());
if (locDangerous(Start))
- return None;
+ return std::nullopt;
return Start;
}
static Optional<FixItHint> fixIfNotDangerous(SourceLocation Loc,
StringRef Text) {
if (locDangerous(Loc))
- return None;
+ return std::nullopt;
return FixItHint::CreateInsertion(Loc, Text);
}
if (IgnoredParens)
return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier));
- return None;
+ return std::nullopt;
}
llvm_unreachable("Unknown QualifierPolicy enum");
}
DeclSpec::TQ Qualifier,
const ASTContext &Context) {
if (locDangerous(Var.getLocation()))
- return None;
+ return std::nullopt;
Optional<SourceLocation> IgnoredParens =
skipLParensBackwards(Var.getLocation(), Context);
if (IgnoredParens)
return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier));
- return None;
+ return std::nullopt;
}
static Optional<FixItHint>
Var.getLocation(), Context.getSourceManager(), Context.getLangOpts(),
tok::star);
if (locDangerous(BeforeStar))
- return None;
+ return std::nullopt;
Optional<SourceLocation> IgnoredParens =
skipLParensBackwards(BeforeStar, Context);
if (IgnoredParens)
return fixIfNotDangerous(*IgnoredParens,
buildQualifier(Qualifier, true));
- return None;
+ return std::nullopt;
}
}
return fixIfNotDangerous(BeforeStar, buildQualifier(Qualifier, true));
}
- return None;
+ return std::nullopt;
}
static Optional<FixItHint>
if (IgnoredParens)
return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier, true));
- return None;
+ return std::nullopt;
}
Optional<FixItHint> addQualifierToVarDecl(const VarDecl &Var,
QualTarget, QualPolicy, Context);
}
- return None;
+ return std::nullopt;
}
} // namespace fixit
} // namespace utils
IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
bool IsAngled = Header.consume_front("<");
if (IsAngled != Header.consume_back(">"))
- return llvm::None;
+ return std::nullopt;
// We assume the same Header will never be included both angled and not
// angled.
// In self contained diags mode we don't track what headers we have already
// inserted.
if (!SelfContainedDiags && !InsertedHeaders[FileID].insert(Header).second)
- return llvm::None;
+ return std::nullopt;
return getOrCreate(FileID).createIncludeInsertion(Header, IsAngled);
}
return FixItHint::CreateInsertion(Location.getBegin(), IncludeStmt);
}
if (FileName == IncludeEntry) {
- return llvm::None;
+ return std::nullopt;
}
}
// FileName comes after all include entries in bucket, insert it after
}
}
if (NonEmptyKind == IK_InvalidInclude) {
- return llvm::None;
+ return std::nullopt;
}
if (NonEmptyKind < IncludeKind) {
if (Tok.is(tok::less))
SawTemplate = true;
else if (Tok.isOneOf(tok::greater, tok::greatergreater))
- LastMatchAfterTemplate = None;
+ LastMatchAfterTemplate = std::nullopt;
else if (Tok.is(TK)) {
if (SawTemplate)
LastMatchAfterTemplate = Tok;
LastMatchBeforeTemplate = Tok;
}
}
- return LastMatchAfterTemplate != None ? LastMatchAfterTemplate
- : LastMatchBeforeTemplate;
+ return LastMatchAfterTemplate != std::nullopt ? LastMatchAfterTemplate
+ : LastMatchBeforeTemplate;
}
static bool breakAndReturnEnd(const Stmt &S) {
const std::vector<std::string> &Abbreviations) {
const FunctionDecl *Function = getSurroundingFunction(Context, Statement);
if (!Function || !Function->hasBody())
- return None;
+ return std::nullopt;
if (AddedAliases[Function].count(Namespace.str()) != 0)
- return None;
+ return std::nullopt;
// FIXME: Doesn't consider the order of declarations.
// If we accidentally pick an alias defined later in the function,
if (ExistingAlias != nullptr) {
AddedAliases[Function][Namespace.str()] = ExistingAlias->getName().str();
- return None;
+ return std::nullopt;
}
for (const auto &Abbreviation : Abbreviations) {
return FixItHint::CreateInsertion(Loc, Declaration);
}
- return None;
+ return std::nullopt;
}
std::string NamespaceAliaser::getNamespaceName(ASTContext &Context,
if (*Search) {
if (Found)
return NameLookup(
- llvm::None); // Multiple decls found in different base classes.
+ std::nullopt); // Multiple decls found in different base classes.
Found = *Search;
continue;
}
} else
- return NameLookup(llvm::None); // Propagate multiple resolution back up.
+ return NameLookup(std::nullopt); // Propagate multiple resolution back up.
}
return NameLookup(Found); // If nullptr, decl wasn't found.
}
llvm::Optional<bool> isExpensiveToCopy(QualType Type,
const ASTContext &Context) {
if (Type->isDependentType() || Type->isIncompleteType())
- return llvm::None;
+ return std::nullopt;
return !Type.isTriviallyCopyableType(Context) &&
!classHasTrivialCopyAndDestroy(Type) &&
!hasDeletedCopyConstructor(Type) &&
StringRef UnqualifiedName = getUnqualifiedName(QualifiedName);
const FunctionDecl *Function = getSurroundingFunction(Context, Statement);
if (!Function)
- return None;
+ return std::nullopt;
if (AddedUsing.count(std::make_pair(Function, QualifiedName.str())) != 0)
- return None;
+ return std::nullopt;
SourceLocation InsertLoc = Lexer::getLocForEndOfToken(
Function->getBody()->getBeginLoc(), 0, SourceMgr, Context.getLangOpts());
// Only use using declarations in the main file, not in includes.
if (SourceMgr.getFileID(InsertLoc) != SourceMgr.getMainFileID())
- return None;
+ return std::nullopt;
// FIXME: This declaration could be masked. Investigate if
// there is a way to avoid using Sema.
.empty();
if (AlreadyHasUsingDecl) {
AddedUsing.emplace(NameInFunction(Function, QualifiedName.str()));
- return None;
+ return std::nullopt;
}
// Find conflicting declarations and references.
auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
!match(findAll(declRefExpr(to(ConflictingDecl))), *Function, Context)
.empty();
if (HasConflictingDeclaration || HasConflictingDeclRef)
- return None;
+ return std::nullopt;
std::string Declaration =
(llvm::Twine("\nusing ") + QualifiedName + ";").str();