[cfe-commits] r49372 - in /cfe/trunk/Driver: ASTConsumers.cpp RewriteTest.cpp

Chris Lattner sabre at nondot.org
Mon Apr 7 22:52:18 PDT 2008


Author: lattner
Date: Tue Apr  8 00:52:18 2008
New Revision: 49372

URL: http://llvm.org/viewvc/llvm-project?rev=49372&view=rev
Log:
silence some warnings when assertions are disabled.

Modified:
    cfe/trunk/Driver/ASTConsumers.cpp
    cfe/trunk/Driver/RewriteTest.cpp

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=49372&r1=49371&r2=49372&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Tue Apr  8 00:52:18 2008
@@ -166,9 +166,11 @@
   const char *l;
   if (LS->getLanguage() == LinkageSpecDecl::lang_c)
     l = "C";
-  else if (LS->getLanguage() == LinkageSpecDecl::lang_cxx)
+  else {
+    assert(LS->getLanguage() == LinkageSpecDecl::lang_cxx &&
+           "unknown language in linkage specification");
     l = "C++";
-  else assert(0 && "unknown language in linkage specification");
+  }
   Out << "extern \"" << l << "\" { ";
   PrintDecl(LS->getDecl());
   Out << "}\n";

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=49372&r1=49371&r2=49372&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Tue Apr  8 00:52:18 2008
@@ -1067,12 +1067,11 @@
     buf += elementName;
     buf += ";\n\t";
   }
-  else if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S->getElement())) {
+  else {
+    DeclRefExpr *DR = cast<DeclRefExpr>(S->getElement());
     elementName = DR->getDecl()->getName();
     elementTypeAsString = DR->getDecl()->getType().getAsString();
   }
-  else
-    assert(false && "RewriteObjCForCollectionStmt - bad element kind");
   
   // struct __objcFastEnumerationState enumState = { 0 };
   buf += "struct __objcFastEnumerationState enumState = { 0 };\n\t";
@@ -1279,11 +1278,10 @@
     if (catchList->hasEllipsis()) {
       // Now rewrite the body...
       lastCatchBody = catchList->getCatchBody();
-      SourceLocation rParenLoc = catchList->getRParenLoc();
       SourceLocation bodyLoc = lastCatchBody->getLocStart();
       const char *bodyBuf = SM->getCharacterData(bodyLoc);
-      const char *rParenBuf = SM->getCharacterData(rParenLoc);
-      assert((*rParenBuf == ')') && "bogus @catch paren location");
+      assert(*SM->getCharacterData(catchList->getRParenLoc()) == ')' &&
+             "bogus @catch paren location");
       assert((*bodyBuf == '{') && "bogus @catch body location");
       
       buf += "1) { id _tmp = _caught;";
@@ -1328,8 +1326,8 @@
   // Complete the catch list...
   if (lastCatchBody) {
     SourceLocation bodyLoc = lastCatchBody->getLocEnd();
-    const char *bodyBuf = SM->getCharacterData(bodyLoc);
-    assert((*bodyBuf == '}') && "bogus @catch body location");
+    assert(*SM->getCharacterData(bodyLoc) == '}' &&
+           "bogus @catch body location");
     bodyLoc = bodyLoc.getFileLocWithOffset(1);
     buf = " } } /* @catch end */\n";
   
@@ -1349,10 +1347,10 @@
     Stmt *body = finalStmt->getFinallyBody();
     SourceLocation startLoc = body->getLocStart();
     SourceLocation endLoc = body->getLocEnd();
-    const char *startBuf = SM->getCharacterData(startLoc);
-    const char *endBuf = SM->getCharacterData(endLoc);
-    assert((*startBuf == '{') && "bogus @finally body location");
-    assert((*endBuf == '}') && "bogus @finally body location");
+    assert(*SM->getCharacterData(startLoc) == '{' &&
+           "bogus @finally body location");
+    assert(*SM->getCharacterData(endLoc) == '}' && 
+           "bogus @finally body location");
   
     startLoc = startLoc.getFileLocWithOffset(1);
     buf = " if (!_rethrow) objc_exception_try_exit(&_stack);\n";





More information about the cfe-commits mailing list