mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 01:46:06 +00:00
Use None rather than Optional<T>() where possible.
llvm-svn: 175705
This commit is contained in:
parent
c4071fe13d
commit
7a30dc53c5
@ -3373,7 +3373,7 @@ public:
|
||||
if (NumExpansions)
|
||||
return NumExpansions - 1;
|
||||
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
}
|
||||
|
||||
SourceLocation getLocStart() const LLVM_READONLY {
|
||||
|
@ -300,8 +300,7 @@ public:
|
||||
ObjCDictionaryElement getKeyValueElement(unsigned Index) const {
|
||||
assert((Index < NumElements) && "Arg access out of range!");
|
||||
const KeyValuePair &KV = getKeyValues()[Index];
|
||||
ObjCDictionaryElement Result = { KV.Key, KV.Value, SourceLocation(),
|
||||
Optional<unsigned>() };
|
||||
ObjCDictionaryElement Result = { KV.Key, KV.Value, SourceLocation(), None };
|
||||
if (HasPackExpansions) {
|
||||
const ExpansionData &Expansion = getExpansionData()[Index];
|
||||
Result.EllipsisLoc = Expansion.EllipsisLoc;
|
||||
|
@ -4155,7 +4155,7 @@ public:
|
||||
if (NumExpansions)
|
||||
return NumExpansions - 1;
|
||||
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
}
|
||||
|
||||
bool isSugared() const { return false; }
|
||||
|
@ -16,9 +16,13 @@
|
||||
#ifndef CLANG_BASIC_LLVM_H
|
||||
#define CLANG_BASIC_LLVM_H
|
||||
|
||||
// This should be the only #include, force #includes of all the others on
|
||||
// clients.
|
||||
// Do not proliferate #includes here, require clients to #include their
|
||||
// dependencies.
|
||||
// Casting.h has complex templates that cannot be easily forward declared.
|
||||
#include "llvm/Support/Casting.h"
|
||||
// None.h includes an enumerant that is desired & cannot be forward declared
|
||||
// without a definition of NoneType.
|
||||
#include "llvm/ADT/None.h"
|
||||
|
||||
namespace llvm {
|
||||
// ADT's.
|
||||
@ -54,6 +58,7 @@ namespace clang {
|
||||
using llvm::cast_or_null;
|
||||
|
||||
// ADT's.
|
||||
using llvm::None;
|
||||
using llvm::Optional;
|
||||
using llvm::StringRef;
|
||||
using llvm::Twine;
|
||||
|
@ -57,14 +57,14 @@ public:
|
||||
/// \brief Retrieve the minor version number, if provided.
|
||||
Optional<unsigned> getMinor() const {
|
||||
if (!HasMinor)
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
return Minor;
|
||||
}
|
||||
|
||||
/// \brief Retrieve the subminor version number, if provided.
|
||||
Optional<unsigned> getSubminor() const {
|
||||
if (!HasSubminor)
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
return Subminor;
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ namespace clang {
|
||||
/// entity with index \p Index came from file \p FID.
|
||||
virtual Optional<bool> isPreprocessedEntityInFileID(unsigned Index,
|
||||
FileID FID) {
|
||||
return Optional<bool>();
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
template<typename T>
|
||||
Optional<T> getAs() const {
|
||||
if (!T::isKind(*this))
|
||||
return Optional<T>();
|
||||
return None;
|
||||
T t;
|
||||
SVal& sv = t;
|
||||
sv = *this;
|
||||
|
@ -908,7 +908,7 @@ static Optional<unsigned> findAnonymousStructOrUnionIndex(RecordDecl *Anon) {
|
||||
|
||||
RecordDecl *Owner = dyn_cast<RecordDecl>(Anon->getDeclContext());
|
||||
if (!Owner)
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
|
||||
unsigned Index = 0;
|
||||
for (DeclContext::decl_iterator D = Owner->noload_decls_begin(),
|
||||
|
@ -180,7 +180,7 @@ static Optional<Visibility> getVisibilityOf(const NamedDecl *D,
|
||||
return DefaultVisibility;
|
||||
}
|
||||
|
||||
return Optional<Visibility>();
|
||||
return None;
|
||||
}
|
||||
|
||||
static LinkageInfo getLVForType(QualType T) {
|
||||
@ -893,7 +893,7 @@ NamedDecl::getExplicitVisibility(ExplicitVisibilityKind kind) const {
|
||||
return getVisibilityOf(InstantiatedFrom, kind);
|
||||
}
|
||||
|
||||
return Optional<Visibility>();
|
||||
return None;
|
||||
}
|
||||
// Use the most recent declaration of a function, and also handle
|
||||
// function template specializations.
|
||||
@ -914,7 +914,7 @@ NamedDecl::getExplicitVisibility(ExplicitVisibilityKind kind) const {
|
||||
if (InstantiatedFrom)
|
||||
return getVisibilityOf(InstantiatedFrom, kind);
|
||||
|
||||
return Optional<Visibility>();
|
||||
return None;
|
||||
}
|
||||
|
||||
// Otherwise, just check the declaration itself first.
|
||||
@ -941,7 +941,7 @@ NamedDecl::getExplicitVisibility(ExplicitVisibilityKind kind) const {
|
||||
return getVisibilityOf(InstantiatedFrom, kind);
|
||||
}
|
||||
|
||||
return Optional<Visibility>();
|
||||
return None;
|
||||
}
|
||||
|
||||
static LinkageInfo getLVForLocalDecl(const NamedDecl *D,
|
||||
|
@ -184,7 +184,7 @@ static void GenerateInjectedTemplateArgs(ASTContext &Context,
|
||||
if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*Param)) {
|
||||
QualType ArgType = Context.getTypeDeclType(TTP);
|
||||
if (TTP->isParameterPack())
|
||||
ArgType = Context.getPackExpansionType(ArgType, Optional<unsigned>());
|
||||
ArgType = Context.getPackExpansionType(ArgType, None);
|
||||
|
||||
Arg = TemplateArgument(ArgType);
|
||||
} else if (NonTypeTemplateParmDecl *NTTP =
|
||||
@ -195,8 +195,8 @@ static void GenerateInjectedTemplateArgs(ASTContext &Context,
|
||||
NTTP->getLocation());
|
||||
|
||||
if (NTTP->isParameterPack())
|
||||
E = new (Context) PackExpansionExpr(
|
||||
Context.DependentTy, E, NTTP->getLocation(), Optional<unsigned>());
|
||||
E = new (Context) PackExpansionExpr(Context.DependentTy, E,
|
||||
NTTP->getLocation(), None);
|
||||
Arg = TemplateArgument(E);
|
||||
} else {
|
||||
TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*Param);
|
||||
|
@ -75,7 +75,7 @@ NSAPI::getNSStringMethodKind(Selector Sel) const {
|
||||
return MK;
|
||||
}
|
||||
|
||||
return Optional<NSStringMethodKind>();
|
||||
return None;
|
||||
}
|
||||
|
||||
Selector NSAPI::getNSArraySelector(NSArrayMethodKind MK) const {
|
||||
@ -133,7 +133,7 @@ Optional<NSAPI::NSArrayMethodKind> NSAPI::getNSArrayMethodKind(Selector Sel) {
|
||||
return MK;
|
||||
}
|
||||
|
||||
return Optional<NSArrayMethodKind>();
|
||||
return None;
|
||||
}
|
||||
|
||||
Selector NSAPI::getNSDictionarySelector(
|
||||
@ -219,7 +219,7 @@ NSAPI::getNSDictionaryMethodKind(Selector Sel) {
|
||||
return MK;
|
||||
}
|
||||
|
||||
return Optional<NSDictionaryMethodKind>();
|
||||
return None;
|
||||
}
|
||||
|
||||
Selector NSAPI::getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK,
|
||||
@ -282,14 +282,14 @@ NSAPI::getNSNumberLiteralMethodKind(Selector Sel) const {
|
||||
return MK;
|
||||
}
|
||||
|
||||
return Optional<NSNumberLiteralMethodKind>();
|
||||
return None;
|
||||
}
|
||||
|
||||
Optional<NSAPI::NSNumberLiteralMethodKind>
|
||||
NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
|
||||
const BuiltinType *BT = T->getAs<BuiltinType>();
|
||||
if (!BT)
|
||||
return Optional<NSAPI::NSNumberLiteralMethodKind>();
|
||||
return None;
|
||||
|
||||
const TypedefType *TDT = T->getAs<TypedefType>();
|
||||
if (TDT) {
|
||||
@ -363,7 +363,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
|
||||
break;
|
||||
}
|
||||
|
||||
return Optional<NSAPI::NSNumberLiteralMethodKind>();
|
||||
return None;
|
||||
}
|
||||
|
||||
/// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
|
||||
|
@ -229,7 +229,7 @@ Optional<unsigned> TemplateArgument::getNumTemplateExpansions() const {
|
||||
if (TemplateArg.NumExpansions)
|
||||
return TemplateArg.NumExpansions - 1;
|
||||
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
}
|
||||
|
||||
void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
|
||||
|
@ -533,7 +533,7 @@ ConversionSpecifier::getStandardSpecifier() const {
|
||||
|
||||
switch (getKind()) {
|
||||
default:
|
||||
return Optional<ConversionSpecifier>();
|
||||
return None;
|
||||
case DArg:
|
||||
NewKind = dArg;
|
||||
break;
|
||||
@ -766,7 +766,7 @@ Optional<LengthModifier> FormatSpecifier::getCorrectedLengthModifier() const {
|
||||
}
|
||||
}
|
||||
|
||||
return Optional<LengthModifier>();
|
||||
return None;
|
||||
}
|
||||
|
||||
bool FormatSpecifier::namedTypeToLengthModifier(QualType QT,
|
||||
|
@ -77,7 +77,7 @@ void DeclToIndex::computeMap(const DeclContext &dc) {
|
||||
Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) const {
|
||||
llvm::DenseMap<const VarDecl *, unsigned>::const_iterator I = map.find(d);
|
||||
if (I == map.end())
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
return I->second;
|
||||
}
|
||||
|
||||
|
@ -1462,11 +1462,11 @@ unsigned SourceManager::getFileIDSize(FileID FID) const {
|
||||
/// in non-performance-critical code.
|
||||
static Optional<ino_t> getActualFileInode(const FileEntry *File) {
|
||||
if (!File)
|
||||
return Optional<ino_t>();
|
||||
return None;
|
||||
|
||||
struct stat StatBuf;
|
||||
if (::stat(File->getName(), &StatBuf))
|
||||
return Optional<ino_t>();
|
||||
return None;
|
||||
|
||||
return StatBuf.st_ino;
|
||||
}
|
||||
|
@ -2730,7 +2730,7 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) {
|
||||
// We have a valid expression. Collect it in a vector so we can
|
||||
// build the argument list.
|
||||
ObjCDictionaryElement Element = {
|
||||
KeyExpr.get(), ValueExpr.get(), EllipsisLoc, Optional<unsigned>()
|
||||
KeyExpr.get(), ValueExpr.get(), EllipsisLoc, None
|
||||
};
|
||||
Elements.push_back(Element);
|
||||
|
||||
|
@ -3036,7 +3036,7 @@ static Optional<unsigned> getExpandedPackSize(NamedDecl *Param) {
|
||||
return TTP->getNumExpansionTemplateParameters();
|
||||
}
|
||||
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
}
|
||||
|
||||
/// \brief Check that the given template argument list is well-formed
|
||||
|
@ -628,7 +628,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
|
||||
case ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation:
|
||||
case ActiveTemplateInstantiation::ExceptionSpecInstantiation:
|
||||
// This is a template instantiation, so there is no SFINAE.
|
||||
return Optional<TemplateDeductionInfo *>();
|
||||
return None;
|
||||
|
||||
case ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation:
|
||||
case ActiveTemplateInstantiation::PriorTemplateArgumentSubstitution:
|
||||
@ -647,7 +647,7 @@ Optional<TemplateDeductionInfo *> Sema::isSFINAEContext() const {
|
||||
}
|
||||
}
|
||||
|
||||
return Optional<TemplateDeductionInfo *>();
|
||||
return None;
|
||||
}
|
||||
|
||||
/// \brief Retrieve the depth and index of a parameter pack.
|
||||
|
@ -1638,9 +1638,8 @@ Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
|
||||
}
|
||||
|
||||
ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
|
||||
return SemaRef.SubstParmVarDecl(D, TemplateArgs, /*indexAdjustment*/ 0,
|
||||
Optional<unsigned>(),
|
||||
/*ExpectParameterPack=*/false);
|
||||
return SemaRef.SubstParmVarDecl(D, TemplateArgs, /*indexAdjustment*/ 0, None,
|
||||
/*ExpectParameterPack=*/ false);
|
||||
}
|
||||
|
||||
Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
|
||||
|
@ -443,8 +443,7 @@ TypeResult Sema::ActOnPackExpansion(ParsedType Type,
|
||||
if (!TSInfo)
|
||||
return true;
|
||||
|
||||
TypeSourceInfo *TSResult =
|
||||
CheckPackExpansion(TSInfo, EllipsisLoc, Optional<unsigned>());
|
||||
TypeSourceInfo *TSResult = CheckPackExpansion(TSInfo, EllipsisLoc, None);
|
||||
if (!TSResult)
|
||||
return true;
|
||||
|
||||
@ -490,7 +489,7 @@ QualType Sema::CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
|
||||
}
|
||||
|
||||
ExprResult Sema::ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc) {
|
||||
return CheckPackExpansion(Pattern, EllipsisLoc, Optional<unsigned>());
|
||||
return CheckPackExpansion(Pattern, EllipsisLoc, None);
|
||||
}
|
||||
|
||||
ExprResult Sema::CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
|
||||
@ -662,7 +661,7 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T,
|
||||
if (Instantiation->is<Decl*>())
|
||||
// The pattern refers to an unexpanded pack. We're not ready to expand
|
||||
// this pack yet.
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
|
||||
unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
|
||||
assert((!Result || *Result == Size) && "inconsistent pack sizes");
|
||||
@ -676,7 +675,7 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T,
|
||||
!TemplateArgs.hasTemplateArgument(Depth, Index))
|
||||
// The pattern refers to an unknown template argument. We're not ready to
|
||||
// expand this pack yet.
|
||||
return Optional<unsigned>();
|
||||
return None;
|
||||
|
||||
// Determine the size of the argument pack.
|
||||
unsigned Size = TemplateArgs(Depth, Index).pack_size();
|
||||
|
@ -2889,7 +2889,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
|
||||
<< T << D.getSourceRange();
|
||||
D.setEllipsisLoc(SourceLocation());
|
||||
} else {
|
||||
T = Context.getPackExpansionType(T, Optional<unsigned>());
|
||||
T = Context.getPackExpansionType(T, None);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2903,7 +2903,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
|
||||
// parameter packs in the type of the non-type template parameter, then
|
||||
// it expands those parameter packs.
|
||||
if (T->containsUnexpandedParameterPack())
|
||||
T = Context.getPackExpansionType(T, Optional<unsigned>());
|
||||
T = Context.getPackExpansionType(T, None);
|
||||
else
|
||||
S.Diag(D.getEllipsisLoc(),
|
||||
LangOpts.CPlusPlus11
|
||||
|
@ -4098,8 +4098,7 @@ bool TreeTransform<Derived>::
|
||||
/*ExpectParameterPack=*/true);
|
||||
} else {
|
||||
NewParm = getDerived().TransformFunctionTypeParam(
|
||||
OldParm, indexAdjustment, Optional<unsigned>(),
|
||||
/*ExpectParameterPack=*/ false);
|
||||
OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
|
||||
}
|
||||
|
||||
if (!NewParm)
|
||||
@ -8565,7 +8564,7 @@ TreeTransform<Derived>::TransformObjCDictionaryLiteral(
|
||||
ArgChanged = true;
|
||||
|
||||
ObjCDictionaryElement Element = {
|
||||
Key.get(), Value.get(), SourceLocation(), Optional<unsigned>()
|
||||
Key.get(), Value.get(), SourceLocation(), None
|
||||
};
|
||||
Elements.push_back(Element);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ static Optional<uint64_t> GetCFNumberSize(ASTContext &Ctx, uint64_t i) {
|
||||
case kCFNumberCGFloatType:
|
||||
// FIXME: We need a way to map from names to Type*.
|
||||
default:
|
||||
return Optional<uint64_t>();
|
||||
return None;
|
||||
}
|
||||
|
||||
return Ctx.getTypeSize(T);
|
||||
|
@ -225,7 +225,7 @@ compareControlFlow(const PathDiagnosticControlFlowPiece &X,
|
||||
FullSourceLoc YEL = Y.getEndLocation().asLocation();
|
||||
if (XEL != YEL)
|
||||
return XEL.isBeforeInTranslationUnitThan(YEL);
|
||||
return Optional<bool>();
|
||||
return None;
|
||||
}
|
||||
|
||||
static Optional<bool> compareMacro(const PathDiagnosticMacroPiece &X,
|
||||
@ -283,7 +283,7 @@ static Optional<bool> comparePiece(const PathDiagnosticPiece &X,
|
||||
return compareControlFlow(cast<PathDiagnosticControlFlowPiece>(X),
|
||||
cast<PathDiagnosticControlFlowPiece>(Y));
|
||||
case clang::ento::PathDiagnosticPiece::Event:
|
||||
return Optional<bool>();
|
||||
return None;
|
||||
case clang::ento::PathDiagnosticPiece::Macro:
|
||||
return compareMacro(cast<PathDiagnosticMacroPiece>(X),
|
||||
cast<PathDiagnosticMacroPiece>(Y));
|
||||
@ -302,7 +302,7 @@ static Optional<bool> comparePath(const PathPieces &X, const PathPieces &Y) {
|
||||
if (b.hasValue())
|
||||
return b.getValue();
|
||||
}
|
||||
return Optional<bool>();
|
||||
return None;
|
||||
}
|
||||
|
||||
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y) {
|
||||
|
@ -227,7 +227,7 @@ typedef const RegionBindingsRef& RegionBindingsConstRef;
|
||||
Optional<SVal> RegionBindingsRef::getDirectBinding(const MemRegion *R) const {
|
||||
if (const SVal *V = lookup(R, BindingKey::Direct))
|
||||
return *V;
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
}
|
||||
|
||||
Optional<SVal> RegionBindingsRef::getDefaultBinding(const MemRegion *R) const {
|
||||
@ -237,7 +237,7 @@ Optional<SVal> RegionBindingsRef::getDefaultBinding(const MemRegion *R) const {
|
||||
return UnknownVal();
|
||||
if (const SVal *V = lookup(R, BindingKey::Default))
|
||||
return *V;
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
}
|
||||
|
||||
RegionBindingsRef RegionBindingsRef::addBinding(BindingKey K, SVal V) const {
|
||||
@ -1448,12 +1448,12 @@ RegionStoreManager::getBindingForDerivedDefaultValue(RegionBindingsConstRef B,
|
||||
|
||||
// Lazy bindings are handled later.
|
||||
if (val.getAs<nonloc::LazyCompoundVal>())
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
|
||||
llvm_unreachable("Unknown default value");
|
||||
}
|
||||
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
}
|
||||
|
||||
SVal RegionStoreManager::getLazyBinding(const SubRegion *LazyBindingRegion,
|
||||
@ -1574,11 +1574,11 @@ SVal RegionStoreManager::getBindingForObjCIvar(RegionBindingsConstRef B,
|
||||
static Optional<SVal> getConstValue(SValBuilder &SVB, const VarDecl *VD) {
|
||||
ASTContext &Ctx = SVB.getContext();
|
||||
if (!VD->getType().isConstQualified())
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
|
||||
const Expr *Init = VD->getInit();
|
||||
if (!Init)
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
|
||||
llvm::APSInt Result;
|
||||
if (Init->EvaluateAsInt(Result, Ctx))
|
||||
@ -1588,7 +1588,7 @@ static Optional<SVal> getConstValue(SValBuilder &SVB, const VarDecl *VD) {
|
||||
return SVB.makeNull();
|
||||
|
||||
// FIXME: Handle other possible constant expressions.
|
||||
return Optional<SVal>();
|
||||
return None;
|
||||
}
|
||||
|
||||
SVal RegionStoreManager::getBindingForVar(RegionBindingsConstRef B,
|
||||
|
@ -561,12 +561,12 @@ Optional<bool> CursorVisitor::shouldVisitCursor(CXCursor Cursor) {
|
||||
if (RegionOfInterest.isValid()) {
|
||||
SourceRange Range = getFullCursorExtent(Cursor, AU->getSourceManager());
|
||||
if (Range.isInvalid())
|
||||
return Optional<bool>();
|
||||
return None;
|
||||
|
||||
switch (CompareRegionOfInterest(Range)) {
|
||||
case RangeBefore:
|
||||
// This declaration comes before the region of interest; skip it.
|
||||
return Optional<bool>();
|
||||
return None;
|
||||
|
||||
case RangeAfter:
|
||||
// This declaration comes after the region of interest; we're done.
|
||||
|
Loading…
x
Reference in New Issue
Block a user