summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-05-26 06:22:03 +0000
committerCraig Topper <craig.topper@gmail.com>2014-05-26 06:22:03 +0000
commitc3ec149bb238ce4640ebaa8b499807264c15276f (patch)
tree7ccc6685888fe48e68fbc723df92c37048e13273 /clang/lib/Sema/SemaExpr.cpp
parent236bde3d6f589dd7011d052aea4d98f610efb419 (diff)
downloadbcm5719-llvm-c3ec149bb238ce4640ebaa8b499807264c15276f.tar.gz
bcm5719-llvm-c3ec149bb238ce4640ebaa8b499807264c15276f.zip
[C++11] Use 'nullptr'. Sema edition.
llvm-svn: 209613
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp183
1 files changed, 94 insertions, 89 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 33eea164a12..a9f11970c95 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -94,11 +94,11 @@ static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S,
Result = TheEnumDecl->getAvailability(&Message);
}
- const ObjCPropertyDecl *ObjCPDecl = 0;
+ const ObjCPropertyDecl *ObjCPDecl = nullptr;
if (Result == AR_Deprecated || Result == AR_Unavailable) {
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) {
- AvailabilityResult PDeclResult = PD->getAvailability(0);
+ AvailabilityResult PDeclResult = PD->getAvailability(nullptr);
if (PDeclResult == Result)
ObjCPDecl = PD;
}
@@ -342,7 +342,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
calleeType = CT_Function;
} else if (isa<VarDecl>(D)) {
QualType type = cast<ValueDecl>(D)->getType();
- const FunctionType *fn = 0;
+ const FunctionType *fn = nullptr;
if (const PointerType *ptr = type->getAs<PointerType>()) {
fn = ptr->getPointeeType()->getAs<FunctionType>();
if (!fn) return;
@@ -497,7 +497,7 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
BaseType = BaseType->getPointeeType();
if (const ObjCObjectType *OTy = BaseType->getAs<ObjCObjectType>())
if (ObjCInterfaceDecl *IDecl = OTy->getInterface()) {
- ObjCInterfaceDecl *ClassDeclared = 0;
+ ObjCInterfaceDecl *ClassDeclared = nullptr;
ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
if (!ClassDeclared->getSuperClass()
&& (*ClassDeclared->ivar_begin()) == IV) {
@@ -590,8 +590,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
}
else if (const ObjCIvarRefExpr *OIRE =
dyn_cast<ObjCIvarRefExpr>(E->IgnoreParenCasts()))
- DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/0);
-
+ DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/nullptr);
+
// C++ [conv.lval]p1:
// [...] If T is a non-class type, the type of the prvalue is the
// cv-unqualified version of T. Otherwise, the type of the
@@ -613,7 +613,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
ExprNeedsCleanups = true;
ExprResult Res = Owned(ImplicitCastExpr::Create(Context, T, CK_LValueToRValue,
- E, 0, VK_RValue));
+ E, nullptr, VK_RValue));
// C11 6.3.2.1p2:
// ... if the lvalue has atomic type, the value has the non-atomic version
@@ -621,7 +621,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
if (const AtomicType *Atomic = T->getAs<AtomicType>()) {
T = Atomic->getValueType().getUnqualifiedType();
Res = Owned(ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic,
- Res.get(), 0, VK_RValue));
+ Res.get(), nullptr, VK_RValue));
}
return Res;
@@ -806,7 +806,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) {
switch (VAK) {
case VAK_ValidInCXX11:
DiagRuntimeBehavior(
- E->getLocStart(), 0,
+ E->getLocStart(), nullptr,
PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
<< Ty << CT);
// Fall through.
@@ -814,7 +814,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) {
if (Ty->isRecordType()) {
// This is unlikely to be what the user intended. If the class has a
// 'c_str' member function, the user probably meant to call that.
- DiagRuntimeBehavior(E->getLocStart(), 0,
+ DiagRuntimeBehavior(E->getLocStart(), nullptr,
PDiag(diag::warn_pass_class_arg_to_vararg)
<< Ty << CT << hasCStrMethod(E) << ".c_str()");
}
@@ -822,7 +822,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) {
case VAK_Undefined:
DiagRuntimeBehavior(
- E->getLocStart(), 0,
+ E->getLocStart(), nullptr,
PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
<< getLangOpts().CPlusPlus11 << Ty << CT);
break;
@@ -830,7 +830,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) {
case VAK_Invalid:
if (Ty->isObjCObjectType())
DiagRuntimeBehavior(
- E->getLocStart(), 0,
+ E->getLocStart(), nullptr,
PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
<< Ty << CT);
else
@@ -1302,7 +1302,7 @@ Sema::ActOnGenericSelectionExpr(SourceLocation KeyLoc,
if (ArgTypes[i])
(void) GetTypeFromParser(ArgTypes[i], &Types[i]);
else
- Types[i] = 0;
+ Types[i] = nullptr;
}
ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
@@ -1715,7 +1715,7 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
TemplateArgs = &Buffer;
} else {
NameInfo = GetNameFromUnqualifiedId(Id);
- TemplateArgs = 0;
+ TemplateArgs = nullptr;
}
}
@@ -1742,7 +1742,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
// original lookup would not have found something because it was a
// dependent name.
DeclContext *DC = (SS.isEmpty() && !CallsUndergoingInstantiation.empty())
- ? CurContext : 0;
+ ? CurContext : nullptr;
while (DC) {
if (isa<CXXRecordDecl>(DC)) {
LookupQualifiedName(R, DC);
@@ -1800,9 +1800,9 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
CXXDependentScopeMemberExpr::Create(
Context, DepThis, DepThisType, true, SourceLocation(),
SS.getWithLocInContext(Context),
- ULE->getTemplateKeywordLoc(), 0,
+ ULE->getTemplateKeywordLoc(), nullptr,
R.getLookupNameInfo(),
- ULE->hasExplicitTemplateArgs() ? &TList : 0);
+ ULE->hasExplicitTemplateArgs() ? &TList : nullptr);
CallsUndergoingInstantiation.back()->setCallee(DepExpr);
} else {
Diag(R.getNameLoc(), diagnostic) << Name;
@@ -2059,9 +2059,9 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
QualType ThisType = MD->getThisType(Context);
// Since the 'this' expression is synthesized, we don't need to
// perform the double-lookup check.
- NamedDecl *FirstQualifierInScope = 0;
+ NamedDecl *FirstQualifierInScope = nullptr;
return Owned(CXXDependentScopeMemberExpr::Create(
- Context, /*This=*/0, ThisType, /*IsArrow=*/true,
+ Context, /*This=*/nullptr, ThisType, /*IsArrow=*/true,
/*Op=*/SourceLocation(), SS.getWithLocInContext(Context),
TemplateKWLoc, FirstQualifierInScope, NameInfo, TemplateArgs));
}
@@ -2168,7 +2168,7 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
DeclContext *DC = computeDeclContext(SS, false);
if (!DC)
return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(),
- NameInfo, /*TemplateArgs=*/0);
+ NameInfo, /*TemplateArgs=*/nullptr);
if (RequireCompleteDeclContext(SS, DC))
return ExprError();
@@ -2181,7 +2181,7 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation)
return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(),
- NameInfo, /*TemplateArgs=*/0);
+ NameInfo, /*TemplateArgs=*/nullptr);
if (R.empty()) {
Diag(NameInfo.getLoc(), diag::err_no_member)
@@ -2196,7 +2196,7 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
if (!R.empty() && (*R.begin())->isCXXClassMember() && !IsAddressOfOperand)
return BuildPossibleImplicitMemberExpr(SS,
/*TemplateKWLoc=*/SourceLocation(),
- R, /*TemplateArgs=*/0);
+ R, /*TemplateArgs=*/nullptr);
return BuildDeclarationNameExpr(SS, R, /* ADL */ false);
}
@@ -2238,11 +2238,11 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
else
LookForIvars = (Lookup.isSingleResult() &&
Lookup.getFoundDecl()->isDefinedOutsideFunctionOrMethod());
- ObjCInterfaceDecl *IFace = 0;
+ ObjCInterfaceDecl *IFace = nullptr;
if (LookForIvars) {
IFace = CurMethod->getClassInterface();
ObjCInterfaceDecl *ClassDeclared;
- ObjCIvarDecl *IV = 0;
+ ObjCIvarDecl *IV = nullptr;
if (IFace && (IV = IFace->lookupInstanceVariable(II, ClassDeclared))) {
// Diagnose using an ivar in a class method.
if (IsClassMethod)
@@ -2338,7 +2338,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
}
}
// Sentinel value saying that we didn't do anything special.
- return Owned((Expr*) 0);
+ return Owned((Expr*) nullptr);
}
/// \brief Cast a base object to a member's actual type.
@@ -2831,7 +2831,7 @@ ExprResult Sema::BuildDeclarationNameExpr(
ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
PredefinedExpr::IdentType IT) {
// Pick the current block, lambda, captured statement or function.
- Decl *currentDecl = 0;
+ Decl *currentDecl = nullptr;
if (const BlockScopeInfo *BSI = getCurBlock())
currentDecl = BSI->TheDecl;
else if (const LambdaScopeInfo *LSI = getCurLambda())
@@ -3232,7 +3232,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
}
ExprResult Sema::ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E) {
- assert((E != 0) && "ActOnParenExpr() missing expr");
+ assert(E && "ActOnParenExpr() missing expr");
return Owned(new (Context) ParenExpr(L, R, E));
}
@@ -3452,7 +3452,7 @@ static bool CheckAlignOfExpr(Sema &S, Expr *E) {
return true;
}
- ValueDecl *D = 0;
+ ValueDecl *D = nullptr;
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
D = DRE->getDecl();
} else if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
@@ -3587,7 +3587,7 @@ Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
UnaryExprOrTypeTrait ExprKind, bool IsType,
void *TyOrEx, const SourceRange &ArgRange) {
// If error parsing type, ignore.
- if (TyOrEx == 0) return ExprError();
+ if (!TyOrEx) return ExprError();
if (IsType) {
TypeSourceInfo *TInfo;
@@ -3768,7 +3768,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
// Use custom logic if this should be the pseudo-object subscript
// expression.
if (!LangOpts.isSubscriptPointerArithmetic())
- return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr, 0, 0);
+ return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr, nullptr,
+ nullptr);
ResultType = PTy->getPointeeType();
} else if (const PointerType *PTy = RHSTy->getAs<PointerType>()) {
@@ -3886,7 +3887,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
// Instantiate the expression.
MultiLevelTemplateArgumentList MutiLevelArgList
- = getTemplateInstantiationArgs(FD, 0, /*RelativeToPrimary=*/true);
+ = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
InstantiatingTemplate Inst(*this, CallLoc, Param,
MutiLevelArgList.getInnermost());
@@ -4004,7 +4005,7 @@ static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn,
if (TypoCorrection Corrected = S.CorrectTypo(
DeclarationNameInfo(FuncName, NameLoc), Sema::LookupOrdinaryName,
- S.getScopeForContext(S.CurContext), NULL, CCC,
+ S.getScopeForContext(S.CurContext), nullptr, CCC,
Sema::CTK_ErrorRecovery)) {
if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
if (Corrected.isOverloaded()) {
@@ -4480,7 +4481,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
Expr *NakedFn = Fn->IgnoreParens();
- NamedDecl *NDecl = 0;
+ NamedDecl *NDecl = nullptr;
if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn))
if (UnOp->getOpcode() == UO_AddrOf)
NakedFn = UnOp->getSubExpr()->IgnoreParens();
@@ -4522,7 +4523,7 @@ Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc,
ConfigDecl, false, ConfigQTy, VK_LValue, LLLLoc);
MarkFunctionReferenced(LLLLoc, ConfigDecl);
- return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, 0,
+ return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, nullptr,
/*IsExecConfig=*/true);
}
@@ -4612,7 +4613,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
// C99 6.5.2.2p1 - "The expression that denotes the called function shall
// have type pointer to function".
FuncT = PT->getPointeeType()->getAs<FunctionType>();
- if (FuncT == 0)
+ if (!FuncT)
return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function)
<< Fn->getType() << Fn->getSourceRange());
} else if (const BlockPointerType *BPT =
@@ -4671,7 +4672,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
if (FDecl) {
// Check if we have too few/too many template arguments, based
// on our knowledge of the function definition.
- const FunctionDecl *Def = 0;
+ const FunctionDecl *Def = nullptr;
if (FDecl->hasBody(Def) && Args.size() != Def->param_size()) {
Proto = Def->getType()->getAs<FunctionProtoType>();
if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->param_size()))
@@ -4793,7 +4794,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
return ExprError();
LiteralExpr = Result.get();
- bool isFileScope = getCurFunctionOrMethodDecl() == 0;
+ bool isFileScope = getCurFunctionOrMethodDecl() == nullptr;
if (isFileScope &&
!LiteralExpr->isTypeDependent() &&
!LiteralExpr->isValueDependent() &&
@@ -4846,7 +4847,7 @@ static void maybeExtendBlockObject(Sema &S, ExprResult &E) {
E = ImplicitCastExpr::Create(S.Context, E.get()->getType(),
CK_ARCExtendBlockObject, E.get(),
- /*base path*/ 0, VK_RValue);
+ /*base path*/ nullptr, VK_RValue);
S.ExprNeedsCleanups = true;
}
@@ -5141,7 +5142,7 @@ ExprResult
Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
Declarator &D, ParsedType &Ty,
SourceLocation RParenLoc, Expr *CastExpr) {
- assert(!D.isInvalidType() && (CastExpr != 0) &&
+ assert(!D.isInvalidType() && (CastExpr != nullptr) &&
"ActOnCastExpr(): missing type or expr");
TypeSourceInfo *castTInfo = GetTypeForDeclaratorCast(D, CastExpr->getType());
@@ -5962,9 +5963,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
Expr *RHSExpr) {
// If this is the gnu "x ?: y" extension, analyze the types as though the LHS
// was the condition.
- OpaqueValueExpr *opaqueValue = 0;
- Expr *commonExpr = 0;
- if (LHSExpr == 0) {
+ OpaqueValueExpr *opaqueValue = nullptr;
+ Expr *commonExpr = nullptr;
+ if (!LHSExpr) {
commonExpr = CondExpr;
// Lower out placeholder types first. This is important so that we don't
// try to capture a placeholder. This happens in few cases in C++; such
@@ -6540,7 +6541,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType,
// The field to initialize within the transparent union.
RecordDecl *UD = UT->getDecl();
- FieldDecl *InitField = 0;
+ FieldDecl *InitField = nullptr;
// It's compatible if the expression matches any of the fields.
for (auto *it : UD->fields()) {
if (it->getType()->isPointerType()) {
@@ -6776,8 +6777,9 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
return LHSType;
}
if (!LHSVecType && isa<ExtVectorType>(RHSVecType)) {
- if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? 0 : &LHS), LHSType,
- RHSVecType->getElementType(), RHSType))
+ if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS),
+ LHSType, RHSVecType->getElementType(),
+ RHSType))
return RHSType;
}
@@ -7257,7 +7259,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
return QualType();
// Check array bounds for pointer arithemtic
- CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/0,
+ CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/nullptr,
/*AllowOnePastEnd*/true, /*IndexNegated*/true);
if (CompLHSTy) *CompLHSTy = LHS.get()->getType();
@@ -7507,7 +7509,7 @@ static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc,
(LHSType->isMemberPointerType() && RHSType->isMemberPointerType()));
bool NonStandardCompositeType = false;
- bool *BoolPtr = S.isSFINAEContext() ? 0 : &NonStandardCompositeType;
+ bool *BoolPtr = S.isSFINAEContext() ? nullptr : &NonStandardCompositeType;
QualType T = S.FindCompositePointerType(Loc, LHS, RHS, BoolPtr);
if (T.isNull()) {
diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/true);
@@ -7744,7 +7746,7 @@ static ValueDecl *getCompareDecl(Expr *E) {
if (Mem->isImplicitAccess())
return Mem->getMemberDecl();
}
- return 0;
+ return nullptr;
}
// C99 6.5.8, C++ [expr.rel]
@@ -7787,7 +7789,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
ValueDecl *DL = getCompareDecl(LHSStripped);
ValueDecl *DR = getCompareDecl(RHSStripped);
if (DL && DR && DL == DR && !IsWithinTemplateSpecialization(DL)) {
- DiagRuntimeBehavior(Loc, 0, PDiag(diag::warn_comparison_always)
+ DiagRuntimeBehavior(Loc, nullptr, PDiag(diag::warn_comparison_always)
<< 0 // self-
<< (Opc == BO_EQ
|| Opc == BO_LE
@@ -7809,7 +7811,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
always_evals_to = 2; // e.g. array1 <= array2
break;
}
- DiagRuntimeBehavior(Loc, 0, PDiag(diag::warn_comparison_always)
+ DiagRuntimeBehavior(Loc, nullptr, PDiag(diag::warn_comparison_always)
<< 1 // array
<< always_evals_to);
}
@@ -7821,8 +7823,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
// Warn about comparisons against a string constant (unless the other
// operand is null), the user probably wants strcmp.
- Expr *literalString = 0;
- Expr *literalStringStripped = 0;
+ Expr *literalString = nullptr;
+ Expr *literalStringStripped = nullptr;
if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
!RHSStripped->isNullPointerConstant(Context,
Expr::NPC_ValueDependentIsNull)) {
@@ -7837,7 +7839,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
}
if (literalString) {
- DiagRuntimeBehavior(Loc, 0,
+ DiagRuntimeBehavior(Loc, nullptr,
PDiag(diag::warn_stringcompare)
<< isa<ObjCEncodeExpr>(literalStringStripped)
<< literalString->getSourceRange());
@@ -8182,7 +8184,7 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
if (DeclRefExpr* DRR
= dyn_cast<DeclRefExpr>(RHS.get()->IgnoreParenImpCasts()))
if (DRL->getDecl() == DRR->getDecl())
- DiagRuntimeBehavior(Loc, 0,
+ DiagRuntimeBehavior(Loc, nullptr,
PDiag(diag::warn_comparison_always)
<< 0 // self-
<< 2 // "a constant"
@@ -8339,7 +8341,7 @@ static bool IsReadonlyMessage(Expr *E, Sema &S) {
ObjCMessageExpr *Base =
dyn_cast<ObjCMessageExpr>(ME->getBase()->IgnoreParenImpCasts());
if (!Base) return false;
- return Base->getMethodDecl() != 0;
+ return Base->getMethodDecl() != nullptr;
}
/// Is the given expression (which must be 'const') a reference to a
@@ -8362,7 +8364,7 @@ static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E) {
assert(var->hasLocalStorage() && "capture added 'const' to non-local?");
// Decide whether the first capture was for a block or a lambda.
- DeclContext *DC = S.CurContext, *Prev = 0;
+ DeclContext *DC = S.CurContext, *Prev = nullptr;
while (DC != var->getDeclContext()) {
Prev = DC;
DC = DC->getParent();
@@ -8742,7 +8744,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
// the base's value, so the object the base refers to is
// irrelevant.
if (cast<MemberExpr>(E)->isArrow())
- return 0;
+ return nullptr;
// Otherwise, the expression refers to a part of the base
return getPrimaryDecl(cast<MemberExpr>(E)->getBase());
case Stmt::ArraySubscriptExprClass: {
@@ -8753,7 +8755,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
if (ICE->getSubExpr()->getType()->isArrayType())
return getPrimaryDecl(ICE->getSubExpr());
}
- return 0;
+ return nullptr;
}
case Stmt::UnaryOperatorClass: {
UnaryOperator *UO = cast<UnaryOperator>(E);
@@ -8764,7 +8766,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
case UO_Extension:
return getPrimaryDecl(UO->getSubExpr());
default:
- return 0;
+ return nullptr;
}
}
case Stmt::ParenExprClass:
@@ -8774,7 +8776,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
// the sub-expression; otherwise, the result here doesn't matter.
return getPrimaryDecl(cast<ImplicitCastExpr>(E)->getSubExpr());
default:
- return 0;
+ return nullptr;
}
}
@@ -9159,7 +9161,7 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R,
if (!S.getLangOpts().ObjC1)
return;
- const Expr *ObjCPointerExpr = 0, *OtherExpr = 0;
+ const Expr *ObjCPointerExpr = nullptr, *OtherExpr = nullptr;
const Expr *LHS = L.get();
const Expr *RHS = R.get();
@@ -9583,8 +9585,8 @@ ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
tok::TokenKind Kind,
Expr *LHSExpr, Expr *RHSExpr) {
BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Kind);
- assert((LHSExpr != 0) && "ActOnBinOp(): missing left expression");
- assert((RHSExpr != 0) && "ActOnBinOp(): missing right expression");
+ assert(LHSExpr && "ActOnBinOp(): missing left expression");
+ assert(RHSExpr && "ActOnBinOp(): missing right expression");
// Emit warnings for tricky precedence issues, e.g. "bitfield & 0x4 == 0"
DiagnoseBinOpPrecedence(*this, Opc, TokLoc, LHSExpr, RHSExpr);
@@ -9963,11 +9965,11 @@ ExprResult Sema::ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
static Expr *maybeRebuildARCConsumingStmt(Stmt *Statement) {
// Should always be wrapped with one of these.
ExprWithCleanups *cleanups = dyn_cast<ExprWithCleanups>(Statement);
- if (!cleanups) return 0;
+ if (!cleanups) return nullptr;
ImplicitCastExpr *cast = dyn_cast<ImplicitCastExpr>(cleanups->getSubExpr());
if (!cast || cast->getCastKind() != CK_ARCConsumeObject)
- return 0;
+ return nullptr;
// Splice out the cast. This shouldn't modify any interesting
// features of the statement.
@@ -10002,7 +10004,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
PopExpressionEvaluationContext();
bool isFileScope
- = (getCurFunctionOrMethodDecl() == 0) && (getCurBlock() == 0);
+ = (getCurFunctionOrMethodDecl() == nullptr) && (getCurBlock() == nullptr);
if (isFileScope)
return ExprError(Diag(LPLoc, diag::err_stmtexpr_file_scope));
@@ -10016,7 +10018,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
bool StmtExprMayBindToTemp = false;
if (!Compound->body_empty()) {
Stmt *LastStmt = Compound->body_back();
- LabelStmt *LastLabelStmt = 0;
+ LabelStmt *LastLabelStmt = nullptr;
// If LastStmt is a label, skip down through into the body.
while (LabelStmt *Label = dyn_cast<LabelStmt>(LastStmt)) {
LastLabelStmt = Label;
@@ -10052,7 +10054,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
if (LastExpr.isInvalid())
return ExprError();
- if (LastExpr.get() != 0) {
+ if (LastExpr.get() != nullptr) {
if (!LastLabelStmt)
Compound->setLastStmt(LastExpr.take());
else
@@ -10174,7 +10176,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
: diag::warn_offsetof_non_pod_type;
if (!IsSafe && !DidWarnAboutNonPOD &&
- DiagRuntimeBehavior(BuiltinLoc, 0,
+ DiagRuntimeBehavior(BuiltinLoc, nullptr,
PDiag(DiagID)
<< SourceRange(CompPtr[0].LocStart, OC.LocEnd)
<< CurrentType))
@@ -10185,7 +10187,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
LookupResult R(*this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
LookupQualifiedName(R, RD);
FieldDecl *MemberDecl = R.getAsSingle<FieldDecl>();
- IndirectFieldDecl *IndirectMemberDecl = 0;
+ IndirectFieldDecl *IndirectMemberDecl = nullptr;
if (!MemberDecl) {
if ((IndirectMemberDecl = R.getAsSingle<IndirectFieldDecl>()))
MemberDecl = IndirectMemberDecl->getAnonField();
@@ -10340,7 +10342,8 @@ void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope) {
void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
Scope *CurScope) {
- assert(ParamInfo.getIdentifier()==0 && "block-id should have no identifier!");
+ assert(ParamInfo.getIdentifier() == nullptr &&
+ "block-id should have no identifier!");
assert(ParamInfo.getContext() == Declarator::BlockLiteralContext);
BlockScopeInfo *CurBlock = getCurBlock();
@@ -10411,7 +10414,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
if (ExplicitSignature) {
for (unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
ParmVarDecl *Param = ExplicitSignature.getParam(I);
- if (Param->getIdentifier() == 0 &&
+ if (Param->getIdentifier() == nullptr &&
!Param->isImplicit() &&
!Param->isInvalidDecl() &&
!getLangOpts().CPlusPlus)
@@ -11081,7 +11084,7 @@ namespace {
// FIXME: This does the right thing, but maybe we need a more general
// fix to TreeTransform?
StmtResult TransformLabelStmt(LabelStmt *S) {
- S->getDecl()->setStmt(0);
+ S->getDecl()->setStmt(nullptr);
return BaseTransform::TransformLabelStmt(S);
}
@@ -11509,7 +11512,7 @@ static DeclContext *getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *
if (Diagnose)
diagnoseUncapturableValueReference(S, Loc, Var, DC);
}
- return 0;
+ return nullptr;
}
// Certain capturing entities (lambdas, blocks etc.) are not allowed to capture
@@ -11586,7 +11589,7 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var,
QualType &DeclRefType,
const bool Nested,
Sema &S) {
- Expr *CopyExpr = 0;
+ Expr *CopyExpr = nullptr;
bool ByRef = false;
// Blocks are not allowed to capture arrays.
@@ -11683,7 +11686,7 @@ static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI,
bool ByRef = true;
// Using an LValue reference type is consistent with Lambdas (see below).
CaptureType = S.Context.getLValueReferenceType(DeclRefType);
- Expr *CopyExpr = 0;
+ Expr *CopyExpr = nullptr;
if (BuildAndDiagnose) {
// The current implementation assumes that all variables are captured
// by references. Since there is no capture by copy, no expression
@@ -11691,9 +11694,9 @@ static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI,
RecordDecl *RD = RSI->TheRecordDecl;
FieldDecl *Field
- = FieldDecl::Create(S.Context, RD, Loc, Loc, 0, CaptureType,
+ = FieldDecl::Create(S.Context, RD, Loc, Loc, nullptr, CaptureType,
S.Context.getTrivialTypeSourceInfo(CaptureType, Loc),
- 0, false, ICIS_NoInit);
+ nullptr, false, ICIS_NoInit);
Field->setImplicit(true);
Field->setAccess(AS_private);
RD->addDecl(Field);
@@ -11725,9 +11728,9 @@ static ExprResult addAsFieldToClosureType(Sema &S,
// Build the non-static data member.
FieldDecl *Field
- = FieldDecl::Create(S.Context, Lambda, Loc, Loc, 0, FieldType,
+ = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType,
S.Context.getTrivialTypeSourceInfo(FieldType, Loc),
- 0, false, ICIS_NoInit);
+ nullptr, false, ICIS_NoInit);
Field->setImplicit(true);
Field->setAccess(AS_private);
Lambda->addDecl(Field);
@@ -11765,7 +11768,7 @@ static ExprResult addAsFieldToClosureType(Sema &S,
while (const ConstantArrayType *Array
= S.Context.getAsConstantArrayType(BaseType)) {
// Create the iteration variable for this array index.
- IdentifierInfo *IterationVarName = 0;
+ IdentifierInfo *IterationVarName = nullptr;
{
SmallString<8> Str;
llvm::raw_svector_ostream OS(Str);
@@ -11913,7 +11916,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI,
}
// Capture this variable in the lambda.
- Expr *CopyExpr = 0;
+ Expr *CopyExpr = nullptr;
if (BuildAndDiagnose) {
ExprResult Result = addAsFieldToClosureType(S, LSI, Var,
CaptureType, DeclRefType, Loc,
@@ -12093,7 +12096,7 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc,
QualType DeclRefType;
return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
/*BuildAndDiagnose=*/true, CaptureType,
- DeclRefType, 0);
+ DeclRefType, nullptr);
}
QualType Sema::getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc) {
@@ -12103,7 +12106,7 @@ QualType Sema::getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc) {
// Determine whether we can capture this variable.
if (tryCaptureVariable(Var, Loc, TryCapture_Implicit, SourceLocation(),
/*BuildAndDiagnose=*/false, CaptureType,
- DeclRefType, 0))
+ DeclRefType, nullptr))
return QualType();
return DeclRefType;
@@ -12120,7 +12123,7 @@ static inline bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var,
if (Var->getType()->isDependentType())
return false;
- const VarDecl *DefVD = 0;
+ const VarDecl *DefVD = nullptr;
Var->getAnyInitializer(DefVD);
if (!DefVD)
return false;
@@ -12146,7 +12149,7 @@ void Sema::UpdateMarkingForLValueToRValue(Expr *E) {
// variable.
if (LambdaScopeInfo *LSI = getCurLambda()) {
Expr *SansParensExpr = E->IgnoreParens();
- VarDecl *Var = 0;
+ VarDecl *Var = nullptr;
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
Var = dyn_cast<VarDecl>(DRE->getFoundDecl());
else if (MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
@@ -12185,7 +12188,8 @@ void Sema::CleanupVarDeclMarking() {
llvm_unreachable("Unexpcted expression");
}
- MarkVarDeclODRUsed(Var, Loc, *this, /*MaxFunctionScopeIndex Pointer*/ 0);
+ MarkVarDeclODRUsed(Var, Loc, *this,
+ /*MaxFunctionScopeIndex Pointer*/ nullptr);
}
MaybeODRUseExprs.clear();
@@ -12296,14 +12300,15 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc,
if (!Var->getType()->isReferenceType())
SemaRef.MaybeODRUseExprs.insert(E);
} else
- MarkVarDeclODRUsed(Var, Loc, SemaRef, /*MaxFunctionScopeIndex ptr*/0);
+ MarkVarDeclODRUsed(Var, Loc, SemaRef,
+ /*MaxFunctionScopeIndex ptr*/ nullptr);
}
/// \brief Mark a variable referenced, and check whether it is odr-used
/// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
/// used directly for normal expressions referring to VarDecl.
void Sema::MarkVariableReferenced(SourceLocation Loc, VarDecl *Var) {
- DoMarkVarDeclReferenced(*this, Loc, Var, 0);
+ DoMarkVarDeclReferenced(*this, Loc, Var, nullptr);
}
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc,
OpenPOWER on IntegriCloud