Use None rather than Optional<T>() where possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175705 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index 98ef237..bdf2bbc 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -908,7 +908,7 @@
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(),
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 3ce2f44..3124261 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -180,7 +180,7 @@
return DefaultVisibility;
}
- return Optional<Visibility>();
+ return None;
}
static LinkageInfo getLVForType(QualType T) {
@@ -893,7 +893,7 @@
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 @@
if (InstantiatedFrom)
return getVisibilityOf(InstantiatedFrom, kind);
- return Optional<Visibility>();
+ return None;
}
// Otherwise, just check the declaration itself first.
@@ -941,7 +941,7 @@
return getVisibilityOf(InstantiatedFrom, kind);
}
- return Optional<Visibility>();
+ return None;
}
static LinkageInfo getLVForLocalDecl(const NamedDecl *D,
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index 49ef5a3..5e25536 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -184,7 +184,7 @@
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 @@
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);
diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp
index b06769e..a862630 100644
--- a/lib/AST/NSAPI.cpp
+++ b/lib/AST/NSAPI.cpp
@@ -75,7 +75,7 @@
return MK;
}
- return Optional<NSStringMethodKind>();
+ return None;
}
Selector NSAPI::getNSArraySelector(NSArrayMethodKind MK) const {
@@ -133,7 +133,7 @@
return MK;
}
- return Optional<NSArrayMethodKind>();
+ return None;
}
Selector NSAPI::getNSDictionarySelector(
@@ -219,7 +219,7 @@
return MK;
}
- return Optional<NSDictionaryMethodKind>();
+ return None;
}
Selector NSAPI::getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK,
@@ -282,14 +282,14 @@
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 @@
break;
}
- return Optional<NSAPI::NSNumberLiteralMethodKind>();
+ return None;
}
/// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index 520ca25..2b50681 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -229,7 +229,7 @@
if (TemplateArg.NumExpansions)
return TemplateArg.NumExpansions - 1;
- return Optional<unsigned>();
+ return None;
}
void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index 10bb9f3..ad0dce4 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -533,7 +533,7 @@
switch (getKind()) {
default:
- return Optional<ConversionSpecifier>();
+ return None;
case DArg:
NewKind = dArg;
break;
@@ -766,7 +766,7 @@
}
}
- return Optional<LengthModifier>();
+ return None;
}
bool FormatSpecifier::namedTypeToLengthModifier(QualType QT,
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index cf2533c..13af435 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -77,7 +77,7 @@
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;
}
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 550e82c..901d3a6 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -1462,11 +1462,11 @@
/// 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;
}
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 27eeb05..ddb6a70 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -2730,7 +2730,7 @@
// 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);
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index c3e3149..61fd826 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -3036,7 +3036,7 @@
return TTP->getNumExpansionTemplateParameters();
}
- return Optional<unsigned>();
+ return None;
}
/// \brief Check that the given template argument list is well-formed
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index bbf2a98..c8f0372 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -628,7 +628,7 @@
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 @@
}
}
- return Optional<TemplateDeductionInfo *>();
+ return None;
}
/// \brief Retrieve the depth and index of a parameter pack.
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index b971a04..1515a35 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1638,9 +1638,8 @@
}
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(
diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp
index 2cff7aa..c0ad2be 100644
--- a/lib/Sema/SemaTemplateVariadic.cpp
+++ b/lib/Sema/SemaTemplateVariadic.cpp
@@ -443,8 +443,7 @@
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 @@
}
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 @@
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 @@
!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();
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index d4d42cd..209699f 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -2889,7 +2889,7 @@
<< T << D.getSourceRange();
D.setEllipsisLoc(SourceLocation());
} else {
- T = Context.getPackExpansionType(T, Optional<unsigned>());
+ T = Context.getPackExpansionType(T, None);
}
break;
@@ -2903,7 +2903,7 @@
// 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
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 0832a24..438d06a 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -4098,8 +4098,7 @@
/*ExpectParameterPack=*/true);
} else {
NewParm = getDerived().TransformFunctionTypeParam(
- OldParm, indexAdjustment, Optional<unsigned>(),
- /*ExpectParameterPack=*/ false);
+ OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
}
if (!NewParm)
@@ -8565,7 +8564,7 @@
ArgChanged = true;
ObjCDictionaryElement Element = {
- Key.get(), Value.get(), SourceLocation(), Optional<unsigned>()
+ Key.get(), Value.get(), SourceLocation(), None
};
Elements.push_back(Element);
}
diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
index ae33a8a..85b9305 100644
--- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -217,7 +217,7 @@
case kCFNumberCGFloatType:
// FIXME: We need a way to map from names to Type*.
default:
- return Optional<uint64_t>();
+ return None;
}
return Ctx.getTypeSize(T);
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index bbf2db3..69a4e27 100644
--- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -225,7 +225,7 @@
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 @@
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 @@
if (b.hasValue())
return b.getValue();
}
- return Optional<bool>();
+ return None;
}
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y) {
diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp
index 3bd624b..09bbcef 100644
--- a/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -227,7 +227,7 @@
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 @@
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 @@
// 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 @@
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 @@
return SVB.makeNull();
// FIXME: Handle other possible constant expressions.
- return Optional<SVal>();
+ return None;
}
SVal RegionStoreManager::getBindingForVar(RegionBindingsConstRef B,