[cfe-commits] r148722 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaExpr.cpp

Argyrios Kyrtzidis kyrtzidis at apple.com
Mon Jan 23 19:18:48 PST 2012


On Jan 23, 2012, at 6:55 PM, Eli Friedman wrote:

> On Mon, Jan 23, 2012 at 12:38 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
>> Author: akirtzidis
>> Date: Mon Jan 23 14:38:53 2012
>> New Revision: 148722
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=148722&view=rev
>> Log:
>> Introduce Sema::isNullExpr() that contains the checks that
>> Sema::DiagnoseSentinelCalls() does.
> 
> What are you planning on using this for?  The name is deceptive
> because it's basically useless for anything other than sentinel
> checking.

Renamed to isSentinelNullExpr in r148772.

-Argyrios

> 
> -Eli
> 
>> Modified:
>>    cfe/trunk/include/clang/Sema/Sema.h
>>    cfe/trunk/lib/Sema/SemaExpr.cpp
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=148722&r1=148721&r2=148722&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Jan 23 14:38:53 2012
>> @@ -1375,6 +1375,7 @@
>>                                  QualType &ConvertedType);
>>   bool IsBlockPointerConversion(QualType FromType, QualType ToType,
>>                                 QualType& ConvertedType);
>> +  bool isNullExpr(const Expr *E) const;
>>   bool FunctionArgTypesAreEqual(const FunctionProtoType *OldType,
>>                                 const FunctionProtoType *NewType,
>>                                 unsigned *ArgPos = 0);
>> 
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=148722&r1=148721&r2=148722&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan 23 14:38:53 2012
>> @@ -249,17 +249,7 @@
>>   Expr *sentinelExpr = args[numArgs - numArgsAfterSentinel - 1];
>>   if (!sentinelExpr) return;
>>   if (sentinelExpr->isValueDependent()) return;
>> -
>> -  // nullptr_t is always treated as null.
>> -  if (sentinelExpr->getType()->isNullPtrType()) return;
>> -
>> -  if (sentinelExpr->getType()->isAnyPointerType() &&
>> -      sentinelExpr->IgnoreParenCasts()->isNullPointerConstant(Context,
>> -                                            Expr::NPC_ValueDependentIsNull))
>> -    return;
>> -
>> -  // Unfortunately, __null has type 'int'.
>> -  if (isa<GNUNullExpr>(sentinelExpr)) return;
>> +  if (isNullExpr(sentinelExpr)) return;
>> 
>>   // Pick a reasonable string to insert.  Optimistically use 'nil' or
>>   // 'NULL' if those are actually defined in the context.  Only use
>> @@ -289,6 +279,24 @@
>>   return E ? E->getSourceRange() : SourceRange();
>>  }
>> 
>> +bool Sema::isNullExpr(const Expr *E) const {
>> +  if (!E)
>> +    return false;
>> +
>> +  // nullptr_t is always treated as null.
>> +  if (E->getType()->isNullPtrType()) return true;
>> +
>> +  if (E->getType()->isAnyPointerType() &&
>> +      E->IgnoreParenCasts()->isNullPointerConstant(Context,
>> +                                            Expr::NPC_ValueDependentIsNull))
>> +    return true;
>> +
>> +  // Unfortunately, __null has type 'int'.
>> +  if (isa<GNUNullExpr>(E)) return true;
>> +
>> +  return false;
>> +}
>> +
>>  //===----------------------------------------------------------------------===//
>>  //  Standard Promotions and Conversions
>>  //===----------------------------------------------------------------------===//
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list