[lld] r179590 - Moved llvm_unreachable out of switch blocks to avoid the "control reaches end of non-void function" warning.

Andy Gibbs andyg1001 at hotmail.co.uk
Tue Apr 16 12:32:39 PDT 2013


On Tuesday, April 16, 2013 8:34 PM, Nick Kledzik wrote:

> Ah!  In that case, I think you want to distinguish between a known
> enum value that should not happen and an invalid enum value.
>  E.g.
>
>  case Flavor::core:
>    return CoreDriver::link(args.size(), args.data(), diagnostics);
>  case Flavor::win_link:
>    llvm_unreachable("Unsupported flavor");
>   break;
>  case Flavor::invalid:
>    return true;
>  }
>  llvm_unreachable("Invalid enum value");
> }
>

This is a very fair point.  I've made the change in r179617 to 
UniversalDriver.cpp, but left MachOTargetInfo.cpp as was since I considered 
the error message to be descriptive for both scenarios.  (Feel free to tell 
me to change it also if you want!)

Thanks for the feedback

Andy
 




More information about the llvm-commits mailing list