[cfe-commits] r65395 - in /cfe/trunk/lib/Sema: Sema.h SemaInit.cpp

Chris Lattner sabre at nondot.org
Tue Feb 24 14:36:59 PST 2009


Author: lattner
Date: Tue Feb 24 16:36:59 2009
New Revision: 65395

URL: http://llvm.org/viewvc/llvm-project?rev=65395&view=rev
Log:
change IsStringLiteralInit into a static function in SemaInit.cpp

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=65395&r1=65394&r2=65395&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Feb 24 16:36:59 2009
@@ -1897,7 +1897,6 @@
   bool CheckAddressConstantExpressionLValue(const Expr* e);
   void InitializerElementNotConstant(const Expr *e);
   
-  StringLiteral *IsStringLiteralInit(Expr *Init, QualType DeclType);
   bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT);
   bool CheckValueInitialization(QualType Type, SourceLocation Loc);
 

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=65395&r1=65394&r2=65395&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Feb 24 16:36:59 2009
@@ -27,7 +27,8 @@
 // Sema Initialization Checking
 //===----------------------------------------------------------------------===//
 
-StringLiteral *Sema::IsStringLiteralInit(Expr *Init, QualType DeclType) {
+static StringLiteral *IsStringInit(Expr *Init, QualType DeclType,
+                                   ASTContext &Context) {
   if (const ArrayType *AT = Context.getAsArrayType(DeclType))
     if (AT->getElementType()->isCharType())
       return dyn_cast<StringLiteral>(Init->IgnoreParens());
@@ -105,7 +106,7 @@
   InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
   if (!InitList) {
     // FIXME: Handle wide strings
-    if (StringLiteral *StrLiteral = IsStringLiteralInit(Init, DeclType))
+    if (StringLiteral *StrLiteral = IsStringInit(Init, DeclType, Context))
       return CheckStringLiteralInit(StrLiteral, DeclType);
     
     // C++ [dcl.init]p14:
@@ -475,7 +476,7 @@
   if (Index < IList->getNumInits()) {
     // We have leftover initializers
     if (IList->getNumInits() > 0 &&
-        SemaRef->IsStringLiteralInit(IList->getInit(Index), T)) {
+        IsStringInit(IList->getInit(Index), T, SemaRef->Context)) {
       unsigned DK = diag::warn_excess_initializers_in_char_array_initializer;
       if (SemaRef->getLangOptions().CPlusPlus)
         DK = diag::err_excess_initializers_in_char_array_initializer;
@@ -579,8 +580,8 @@
                           newStructuredList, newStructuredIndex);
     ++StructuredIndex;
     ++Index;
-  } else if (StringLiteral *lit =
-             SemaRef->IsStringLiteralInit(expr, ElemType)) {
+  } else if (StringLiteral *lit = IsStringInit(expr, ElemType,
+                                               SemaRef->Context)) {
     SemaRef->CheckStringLiteralInit(lit, ElemType);
     UpdateStructuredListElement(StructuredList, StructuredIndex, lit);
     ++Index;
@@ -765,8 +766,8 @@
                                      unsigned &StructuredIndex) {
   // Check for the special-case of initializing an array with a string.
   if (Index < IList->getNumInits()) {
-    if (StringLiteral *lit = 
-        SemaRef->IsStringLiteralInit(IList->getInit(Index), DeclType)) {
+    if (StringLiteral *lit = IsStringInit(IList->getInit(Index), DeclType,
+                                          SemaRef->Context)) {
       SemaRef->CheckStringLiteralInit(lit, DeclType);
       // We place the string literal directly into the resulting
       // initializer list. This is the only place where the structure





More information about the cfe-commits mailing list