From 92493e5e96b86f4976499eacc9233461ade1de8d Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 13 Nov 2014 23:19:36 +0000 Subject: -Wsentinel: Suggest nullptr in C++11 instead of NULL llvm-svn: 221945 --- clang/lib/Sema/SemaExpr.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index dda9d88abac..de080117b49 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -398,8 +398,8 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, if (sentinelExpr->isValueDependent()) return; if (Context.isSentinelNullExpr(sentinelExpr)) return; - // Pick a reasonable string to insert. Optimistically use 'nil' or - // 'NULL' if those are actually defined in the context. Only use + // Pick a reasonable string to insert. Optimistically use 'nil', 'nullptr', + // or 'NULL' if those are actually defined in the context. Only use // 'nil' for ObjC methods, where it's much more likely that the // variadic arguments form a list of object pointers. SourceLocation MissingNilLoc @@ -408,6 +408,8 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, if (calleeType == CT_Method && PP.getIdentifierInfo("nil")->hasMacroDefinition()) NullValue = "nil"; + else if (getLangOpts().CPlusPlus11) + NullValue = "nullptr"; else if (PP.getIdentifierInfo("NULL")->hasMacroDefinition()) NullValue = "NULL"; else -- cgit v1.2.3