[cfe-commits] r86243 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/compare.c

John McCall rjmccall at apple.com
Fri Nov 6 00:53:51 PST 2009


Author: rjmccall
Date: Fri Nov  6 02:53:51 2009
New Revision: 86243

URL: http://llvm.org/viewvc/llvm-project?rev=86243&view=rev
Log:
compare.c also needs a target triple now, and improve some comments while we're
at it.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/compare.c

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Nov  6 02:53:51 2009
@@ -4450,8 +4450,8 @@
 /// \param lex the left-hand expression
 /// \param rex the right-hand expression
 /// \param OpLoc the location of the joining operator
-/// \param Equality whether this is an "equality-like" join;
-///   this suppresses the warning in some cases
+/// \param Equality whether this is an "equality-like" join, which
+///   suppresses the warning in some cases
 void Sema::CheckSignCompare(Expr *lex, Expr *rex, SourceLocation OpLoc,
                             const PartialDiagnostic &PD, bool Equality) {
   QualType lt = lex->getType(), rt = rex->getType();
@@ -4479,8 +4479,8 @@
   }
 
   // If the unsigned type is strictly smaller than the signed type,
-  // then (1) the result type will be signed and (2) the unsigned type
-  // will fight losslessly within the signed type, and so the result
+  // then (1) the result type will be signed and (2) the unsigned
+  // value will fit fully within the signed type, and thus the result
   // of the comparison will be exact.
   if (Context.getIntWidth(signedOperand->getType()) >
       Context.getIntWidth(unsignedOperand->getType()))
@@ -4498,9 +4498,9 @@
 
   if (Equality) {
     // For (in)equality comparisons, if the unsigned operand is a
-    // constant no greater than the maximum signed operand, then
-    // reinterpreting the signed operand as unsigned will not change
-    // the result of the comparison.
+    // constant which cannot collide with a overflowed signed operand,
+    // then reinterpreting the signed operand as unsigned will not
+    // change the result of the comparison.
     if (unsignedOperand->isIntegerConstantExpr(value, Context)) {
       assert(!value.isSigned() && "result of unsigned expression is signed");
 

Modified: cfe/trunk/test/Sema/compare.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compare.c?rev=86243&r1=86242&r2=86243&view=diff

==============================================================================
--- cfe/trunk/test/Sema/compare.c (original)
+++ cfe/trunk/test/Sema/compare.c Fri Nov  6 02:53:51 2009
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -pedantic -verify -Wsign-compare %s
+// RUN: clang-cc -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare %s
 
 int test(char *C) { // nothing here should warn.
   return C != ((void*)0);





More information about the cfe-commits mailing list