r210804 - Basic: fix warnings from GCC

Saleem Abdulrasool compnerd at compnerd.org
Thu Jun 12 11:27:47 PDT 2014


On Thursday, June 12, 2014, Richard Smith <richard at metafoo.co.uk> wrote:

>
> On 12 Jun 2014 10:57, "Saleem Abdulrasool" <compnerd at compnerd.org
> <javascript:_e(%7B%7D,'cvml','compnerd at compnerd.org');>> wrote:
> >
> > Author: compnerd
> > Date: Thu Jun 12 12:43:37 2014
> > New Revision: 210804
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=210804&view=rev
> > Log:
> > Basic: fix warnings from GCC
> >
> > tools/clang/lib/Basic/DiagnosticIDs.cpp: In function
> ‘clang::DiagnosticIDs::Level toLevel(clang::diag::Severity)’:
> > tools/clang/lib/Basic/DiagnosticIDs.cpp:382:1: warning: control reaches
> end of non-void function [-Wreturn-type]
> >
> > tools/clang/lib/Format/Format.cpp: In member function ‘virtual
> std::string clang::format::ParseErrorCategory::message(int) const’:
> > tools/clang/lib/Format/Format.cpp:282:1: warning: control reaches end of
> non-void function [-Wreturn-type]
> >
> > Add a default cases that asserts that we handle the severity, parse
> error.
> >
> > Modified:
> >     cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> >     cfe/trunk/lib/Format/Format.cpp
> >
> > Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=210804&r1=210803&r2=210804&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
> > +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Jun 12 12:43:37 2014
> > @@ -368,6 +368,7 @@ StringRef DiagnosticIDs::getDescription(
> >
> >  static DiagnosticIDs::Level toLevel(diag::Severity SV) {
> >    switch (SV) {
> > +  default: llvm_unreachable("unexpected severity");
>
> The 'unreachable' call for a covered switch (in which every case returns)
> should go after the switch, not in a default: case, so we get a diagnostic
> if a new enumerator is added but isn't handled here.
>
 Oh, didn't consider we could catch it that way!  That is much better.
 I'll change this in a short while.

> >    case diag::Severity::Ignored:
> >      return DiagnosticIDs::Ignored;
> >    case diag::Severity::Remark:
> >
> > Modified: cfe/trunk/lib/Format/Format.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=210804&r1=210803&r2=210804&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Format/Format.cpp (original)
> > +++ cfe/trunk/lib/Format/Format.cpp Thu Jun 12 12:43:37 2014
> > @@ -272,6 +272,7 @@ const char *ParseErrorCategory::name() c
> >
> >  std::string ParseErrorCategory::message(int EV) const {
> >    switch (static_cast<ParseError>(EV)) {
> > +  default: llvm_unreachable("unexpected parse error");
> >    case ParseError::Success:
> >      return "Success";
> >    case ParseError::Error:
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> <javascript:_e(%7B%7D,'cvml','cfe-commits at cs.uiuc.edu');>
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140612/30ac2daf/attachment.html>


More information about the cfe-commits mailing list