On Thu, Jan 24, 2013 at 3:33 PM, jahanian <[email protected]> wrote:
>
> On Jan 24, 2013, at 3:27 PM, John McCall <[email protected]> wrote:
>
>> On Jan 24, 2013, at 3:11 PM, Richard Smith <[email protected]> wrote:
>>> On Thu, Jan 24, 2013 at 2:11 PM, Fariborz Jahanian <[email protected]> 
>>> wrote:
>>>> Author: fjahanian
>>>> Date: Thu Jan 24 16:11:45 2013
>>>> New Revision: 173377
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=173377&view=rev
>>>> Log:
>>>> Patch to check for integer overflow. It has been
>>>> commented on and approved by Richard Smith.
>>>>
>>>> Modified:
>>>>   cfe/trunk/include/clang/AST/Expr.h
>>>>   cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
>>>>   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>>>   cfe/trunk/include/clang/Sema/Sema.h
>>>>   cfe/trunk/lib/AST/ExprConstant.cpp
>>>>   cfe/trunk/lib/Sema/SemaChecking.cpp
>>>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>>>   cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>>>   cfe/trunk/lib/Sema/SemaStmt.cpp
>>>>   cfe/trunk/test/Sema/switch-1.c
>>>>
>>>> Modified: cfe/trunk/include/clang/AST/Expr.h
>>>> URL: 
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=173377&r1=173376&r2=173377&view=diff
>>>> ==============================================================================
>>>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>>>> +++ cfe/trunk/include/clang/AST/Expr.h Thu Jan 24 16:11:45 2013
>>>> @@ -570,6 +570,9 @@
>>>>  /// integer.
>>>>  llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx,
>>>>                          SmallVectorImpl<PartialDiagnosticAt> *Diag=0) 
>>>> const;
>>>> +
>>>> +  void EvaluateForOverflow(const ASTContext &Ctx,
>>>> +                           SmallVectorImpl<PartialDiagnosticAt> *Diag) 
>>>> const;
>>>>
>>>>  /// EvaluateAsLValue - Evaluate an expression to see if we can fold it to 
>>>> an
>>>>  /// lvalue with link time known address, with no side-effects.
>>>>
>>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
>>>> URL: 
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=173377&r1=173376&r2=173377&view=diff
>>>> ==============================================================================
>>>> --- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
>>>> +++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Thu Jan 24 
>>>> 16:11:45 2013
>>>> @@ -106,6 +106,9 @@
>>>>  "(skipping %0 call%s0 in backtrace; use -fconstexpr-backtrace-limit=0 to "
>>>>  "see all)">;
>>>> def note_constexpr_call_here : Note<"in call to '%0'">;
>>>> +def warn_integer_constant_overflow : Warning<
>>>> +  "overflow in case constant expression results in value %0 of type %1">,
>>>> +  InGroup<DiagGroup<"integer-overflow">>;
>>>
>>> This diagnostic text is wrong, since we're checking for overflow in
>>> all expressions, not just case constant expressions.
>>
>> It's also confusingly worded.  A better diagnostic, if we keep a specialized
>> message for case expressions, would be something like:
>>  "overflow in 'case' expression;  resulting value is %0 of type %1"
>> In particular, the quotation marks are importing in order to prevent
>> people from interpreting "in case ..." as the common English idiom.
>> It is also unnecessary to point out that this is a constant expression.
>
> No longer specialized to case expression.
> So, I need to mention that it is a constant expression.
> Currently it says. overflow of constant expression results in value %0 of 
> type %1
> I think your suggesting would be something like:
>
> "overflow of constant expression;  resulting  value is %0 of type %1"

The warning also catches cases which are not constant expressions, such as...

int a;
int b = (a, 65537) * 65537;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to