Warnings for Perl and Ruby that can be fixed

15 views
Skip to first unread message

Neil Hodgson

unread,
Feb 23, 2012, 7:10:22 PM2/23/12
to scintilla-interest
Scintilla currently builds with no warnings on supported compilers
with the build files included. However, on OS X using Xcode, there is
an extra 'Analyze' target that has revealed some useful problems in
the past. It uses the Clang Static Analyzer
http://clang-analyzer.llvm.org/ .

Over time, warnings from Analyze have been fixed so that there are
now just 3 warnings for Scintilla which occur in the lexers for Perl
and Ruby. These are all 'dead code' warnings so can be fixed by
removing the code but it is possible that the dead code was meant to
be live so it is much better if people familiar with these languages
and lexers can check the warnings. The dead code may also be present
as a deliberate choice to preserve invariants in case of future
additions, in which case the warnings should be suppressed in some
way. They are, edited for brevity:

Analyze ../../lexers/LexPerl.cxx
...

scintilla/cocoa/ScintillaFramework/../../lexers/LexPerl.cxx:949:7:
warning: Value stored to 'pod' is never read
pod = SCE_PL_POD;
^ ~~~~~~~~~~
1 warning generated.

Analyze ../../lexers/LexRuby.cxx
...

scintilla/cocoa/ScintillaFramework/../../lexers/LexRuby.cxx:1195:21:
warning: Value stored to 'chNext2' is never read
chNext2 = chNext;
^ ~~~~~~
scintilla/cocoa/ScintillaFramework/../../lexers/LexRuby.cxx:1352:21:
warning: Value stored to 'chNext2' is never read
chNext2 = styler.SafeGetCharAt(i + 2);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

The versions of Clang easily available with Linux distributions
tend to be old (2.9) and are often confused by C++ code.

Neil

KHMan

unread,
Feb 23, 2012, 7:55:41 PM2/23/12
to scintilla...@googlegroups.com
On 2/24/2012 8:10 AM, Neil Hodgson wrote:
> [snip]

> Over time, warnings from Analyze have been fixed so that there are
> now just 3 warnings for Scintilla which occur in the lexers for Perl
> and Ruby. These are all 'dead code' warnings so can be fixed by
> removing the code but it is possible that the dead code was meant to
> be live so it is much better if people familiar with these languages
> and lexers can check the warnings. The dead code may also be present
> as a deliberate choice to preserve invariants in case of future
> additions, in which case the warnings should be suppressed in some
> way. They are, edited for brevity:
>
> Analyze ../../lexers/LexPerl.cxx
> ...
>
> scintilla/cocoa/ScintillaFramework/../../lexers/LexPerl.cxx:949:7:
> warning: Value stored to 'pod' is never read
> pod = SCE_PL_POD;
> ^ ~~~~~~~~~~
> 1 warning generated.

"else pod = SCE_PL_POD;" can be deleted. Best I can tell is that
it's a no-op artifact left over from laying out the if statements
so that all POD state switching combinations have been covered.

In detail:

The line is reached by (sc.state == SCE_PL_POD) && (pod ==
SCE_PL_DEFAULT).

(pod == SCE_PL_DEFAULT) means the POD line has some whitespace and
nothing else. It looks like an empty line so we just continue with
SCE_PL_POD, a no-op.

The other state in the block, (sc.state == SCE_PL_POD_VERB) &&
(pod == SCE_PL_DEFAULT), has some code to adjust classification of
lines-that-are-whitespace trailing a SCE_PL_POD_VERB block, a
cosmetic detail.

Thanks,
--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

Eric Promislow

unread,
Feb 23, 2012, 8:35:04 PM2/23/12
to scintilla...@googlegroups.com
+1 on removing the Ruby lines.

> --
> You received this message because you are subscribed to the Google Groups
> "scintilla-interest" group.
> To post to this group, send email to scintilla...@googlegroups.com.
> To unsubscribe from this group, send email to
> scintilla-inter...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/scintilla-interest?hl=en.
>

Neil Hodgson

unread,
Feb 24, 2012, 6:59:51 PM2/24/12
to scintilla...@googlegroups.com
Dead code removal now committed.

Neil

Reply all
Reply to author
Forward
0 new messages