From d45e4b767458104d7e842e253cd03df01ccba3f4 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 8 Mar 2011 04:07:54 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaExpr.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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; } -- 2.50.1