]> granicus.if.org Git - clang/commitdiff
Update the check for a NULL macro to use Preprocessor::getSpelling().
authorJohn McCall <rjmccall@apple.com>
Tue, 8 Mar 2011 04:07:54 +0000 (04:07 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 8 Mar 2011 04:07:54 +0000 (04:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127217 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index f97d1a8f12812538541f00788e0f5427194092cf..c4218c3365d081ca0bfc78077b3e7e4cf9a5a1f4 100644 (file)
@@ -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;
   }