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

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Feb 2 21:58:16 PST 2012


Author: akirtzidis
Date: Thu Feb  2 23:58:16 2012
New Revision: 149675

URL: http://llvm.org/viewvc/llvm-project?rev=149675&view=rev
Log:
Move isSentinelNullExpr() from Sema to ASTContext to make it more widely
available.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=149675&r1=149674&r2=149675&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Feb  2 23:58:16 2012
@@ -1664,6 +1664,8 @@
     return Res;
   }
 
+  bool isSentinelNullExpr(const Expr *E);
+
   /// \brief Get the implementation of ObjCInterfaceDecl,or NULL if none exists.
   ObjCImplementationDecl *getObjCImplementation(ObjCInterfaceDecl *D);
   /// \brief Get the implementation of ObjCCategoryDecl, or NULL if none exists.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=149675&r1=149674&r2=149675&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb  2 23:58:16 2012
@@ -1381,7 +1381,6 @@
                                  QualType &ConvertedType);
   bool IsBlockPointerConversion(QualType FromType, QualType ToType,
                                 QualType& ConvertedType);
-  bool isSentinelNullExpr(const Expr *E) const;
   bool FunctionArgTypesAreEqual(const FunctionProtoType *OldType,
                                 const FunctionProtoType *NewType,
                                 unsigned *ArgPos = 0);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=149675&r1=149674&r2=149675&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Feb  2 23:58:16 2012
@@ -1247,6 +1247,24 @@
   return count;
 }
 
+bool ASTContext::isSentinelNullExpr(const Expr *E) {
+  if (!E)
+    return false;
+
+  // nullptr_t is always treated as null.
+  if (E->getType()->isNullPtrType()) return true;
+
+  if (E->getType()->isAnyPointerType() &&
+      E->IgnoreParenCasts()->isNullPointerConstant(*this,
+                                                Expr::NPC_ValueDependentIsNull))
+    return true;
+
+  // Unfortunately, __null has type 'int'.
+  if (isa<GNUNullExpr>(E)) return true;
+
+  return false;
+}
+
 /// \brief Get the implementation of ObjCInterfaceDecl,or NULL if none exists.
 ObjCImplementationDecl *ASTContext::getObjCImplementation(ObjCInterfaceDecl *D) {
   llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*>::iterator

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=149675&r1=149674&r2=149675&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Feb  2 23:58:16 2012
@@ -249,7 +249,7 @@
   Expr *sentinelExpr = args[numArgs - numArgsAfterSentinel - 1];
   if (!sentinelExpr) return;
   if (sentinelExpr->isValueDependent()) return;
-  if (isSentinelNullExpr(sentinelExpr)) 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
@@ -279,24 +279,6 @@
   return E ? E->getSourceRange() : SourceRange();
 }
 
-bool Sema::isSentinelNullExpr(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
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list