Re: [Lldb-commits] [lldb] r259962 - Fix "thread backtrace -s": option was misparsed because of a missing break.

2016-02-06 Thread Jason Molenda via lldb-commits
Hi Zachary, related to this bug, I was looking into clang diagnostics and there 
is one that would have helped us catch this, -Wimplicit-fallthrough.  It would 
have issued a warning for CommandObjectThread.cpp (when built with clang, of 
course) but it won't generate a warning for

case 0:
case 1:
case 2: 
 ... do something for values 0-2
break;


There are some places in lldb where we have code AND we intentionally fall 
through; remarkably often there is a comment that it is intentional, like

case eConnectionStatusNoConnection: // No connection
case eConnectionStatusLostConnection:   // Lost connection while 
connected to a valid connection
done = true;
// Fall through...
case eConnectionStatusTimedOut: // Request timed out
if (log)
error.LogIfError (log,


etc.  In this case, if we add [[clang::fallthrough]]; before the '// Fall 
through...' comment, clang will not emit a warning.

I don't know the [[clang::fallthrough]]; syntax, I have a feeling it might be 
some C++11 thing that other compilers will ignore.  Do you know if MSVC will 
ignore this markup if we add it to the sources in the places where we mean to 
fall through?


(a quick look over the warnings makes me think there are probably another dozen 
of these bugs in the lldb codebase.  I'll look at those more closely on Monday.)


> On Feb 5, 2016, at 4:46 PM, Zachary Turner via lldb-commits 
>  wrote:
> 
> Sounds like we don't have a test for thread backtrace -s.  I know I usually 
> argue against tests of the CLI, but only when they're used instead of tests 
> for the api.  Seems like we should have at least one test for every option of 
> every command.
> 
> On Fri, Feb 5, 2016 at 4:35 PM Jim Ingham via lldb-commits 
>  wrote:
> Author: jingham
> Date: Fri Feb  5 18:31:23 2016
> New Revision: 259962
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=259962&view=rev
> Log:
> Fix "thread backtrace -s": option was misparsed because of a missing break.
> 
> 
> 
> Modified:
> lldb/trunk/source/Commands/CommandObjectThread.cpp
> 
> Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=259962&r1=259961&r2=259962&view=diff
> ==
> --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Feb  5 18:31:23 
> 2016
> @@ -194,6 +194,7 @@ public:
>  if (!success)
>  error.SetErrorStringWithFormat("invalid integer 
> value for option '%c'", short_option);
>  }
> +break;
>  case 'e':
>  {
>  bool success;
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r259962 - Fix "thread backtrace -s": option was misparsed because of a missing break.

2016-02-06 Thread Zachary Turner via lldb-commits
On MSVC 2015 I get this:

1>c:\users\zach\documents\visual studio
2015\projects\consoleapplication2\consoleapplication2\consoleapplication2.cpp(22):
warning C5030: attribute 'clang::fallthrough' is not recognized
1>c:\users\zach\documents\visual studio
2015\projects\consoleapplication2\consoleapplication2\consoleapplication2.cpp(22):
warning C4649: attributes are ignored in this context

I wouldn't mind disabling the warning, but the bigger problem is that the
android folks are still using MSVC 2013.

I would suggest making a #define out of it.

#if defined(CLANG)
#define LLVM_CASE_FALLTHROUGH() [[clang::fallthrough]];
#else
#define LLVM_CASE_FALLTHROUGH()
#endif

I would also suggest trying to get this into LLVM, as it seems generally
useful to the larger project and non-specific to LLDB.

On Sat, Feb 6, 2016 at 2:25 AM Jason Molenda  wrote:

> Hi Zachary, related to this bug, I was looking into clang diagnostics and
> there is one that would have helped us catch this, -Wimplicit-fallthrough.
> It would have issued a warning for CommandObjectThread.cpp (when built with
> clang, of course) but it won't generate a warning for
>
> case 0:
> case 1:
> case 2:
>  ... do something for values 0-2
> break;
>
>
> There are some places in lldb where we have code AND we intentionally fall
> through; remarkably often there is a comment that it is intentional, like
>
> case eConnectionStatusNoConnection: // No connection
> case eConnectionStatusLostConnection:   // Lost connection while
> connected to a valid connection
> done = true;
> // Fall through...
> case eConnectionStatusTimedOut: // Request timed out
> if (log)
> error.LogIfError (log,
>
>
> etc.  In this case, if we add [[clang::fallthrough]]; before the '// Fall
> through...' comment, clang will not emit a warning.
>
> I don't know the [[clang::fallthrough]]; syntax, I have a feeling it might
> be some C++11 thing that other compilers will ignore.  Do you know if MSVC
> will ignore this markup if we add it to the sources in the places where we
> mean to fall through?
>
>
> (a quick look over the warnings makes me think there are probably another
> dozen of these bugs in the lldb codebase.  I'll look at those more closely
> on Monday.)
>
>
> > On Feb 5, 2016, at 4:46 PM, Zachary Turner via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> >
> > Sounds like we don't have a test for thread backtrace -s.  I know I
> usually argue against tests of the CLI, but only when they're used instead
> of tests for the api.  Seems like we should have at least one test for
> every option of every command.
> >
> > On Fri, Feb 5, 2016 at 4:35 PM Jim Ingham via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> > Author: jingham
> > Date: Fri Feb  5 18:31:23 2016
> > New Revision: 259962
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=259962&view=rev
> > Log:
> > Fix "thread backtrace -s": option was misparsed because of a missing
> break.
> >
> > 
> >
> > Modified:
> > lldb/trunk/source/Commands/CommandObjectThread.cpp
> >
> > Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=259962&r1=259961&r2=259962&view=diff
> >
> ==
> > --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
> > +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Feb  5
> 18:31:23 2016
> > @@ -194,6 +194,7 @@ public:
> >  if (!success)
> >  error.SetErrorStringWithFormat("invalid integer
> value for option '%c'", short_option);
> >  }
> > +break;
> >  case 'e':
> >  {
> >  bool success;
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits