From: John McCall Date: Tue, 8 Mar 2011 04:07:54 +0000 (+0000) Subject: Update the check for a NULL macro to use Preprocessor::getSpelling(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d45e4b767458104d7e842e253cd03df01ccba3f4;p=clang Update the check for a NULL macro to use Preprocessor::getSpelling(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127217 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f97d1a8f12..c4218c3365 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5261,11 +5261,9 @@ bool Sema::DiagnoseConditionalForNull(Expr *LHS, Expr *RHS, // In this case, check to make sure that we got here from a "NULL" // string in the source code. NullExpr = NullExpr->IgnoreParenImpCasts(); - SourceManager& SM = Context.getSourceManager(); - SourceLocation Loc = SM.getInstantiationLoc(NullExpr->getExprLoc()); - unsigned Len = - Lexer::MeasureTokenLength(Loc, SM, Context.getLangOptions()); - if (Len != 4 || memcmp(SM.getCharacterData(Loc), "NULL", 4)) + SourceLocation Loc = + getSourceManager().getInstantiationLoc(NullExpr->getExprLoc()); + if (getPreprocessor().getSpelling(Loc) != "NULL") return false; }