r272867 - [Lex] Try to fix a 'comparison is always false' warning. NFC.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 16 10:27:11 PDT 2016


I can't remember the rules - but wouldn't this produce UB on a signed char
platform in the case where Ch is negative? (or is that just unspecified?
implementation defined?)

On Wed, Jun 15, 2016 at 7:30 PM, George Burgess IV via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: gbiv
> Date: Wed Jun 15 21:30:33 2016
> New Revision: 272867
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272867&view=rev
> Log:
> [Lex] Try to fix a 'comparison is always false' warning. NFC.
>
> Modified:
>     cfe/trunk/lib/Lex/PPDirectives.cpp
>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jun 15 21:30:33 2016
> @@ -162,7 +162,7 @@ static bool warnByDefaultOnWrongCase(Str
>    SmallString<32> LowerInclude{Include};
>    for (char &Ch : LowerInclude) {
>      // In the ASCII range?
> -    if (Ch < 0 || Ch > 0x7f)
> +    if (static_cast<unsigned char>(Ch) > 0x7f)
>        return false; // Can't be a standard header
>      // ASCII lowercase:
>      if (Ch >= 'A' && Ch <= 'Z')
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160616/417b6fc0/attachment.html>


More information about the cfe-commits mailing list