[LLVMdev] Advice on a VStudio specific patch

me22 me22.ca at gmail.com
Thu May 31 19:11:50 PDT 2007


On 31/05/07, Chuck Rose III <cfr at adobe.com> wrote:
> Here are the two problem areas:
>
> RegisterInfoEmitter.cpp
>
>   // Emit the subregister + index mapping function based on the
> information
>   // calculated above.
>   OS << "unsigned " << ClassName
>      << "::getSubReg(unsigned RegNo, unsigned Index) const {\n"
>      << "  switch (RegNo) {\n"
>      << "  default: abort(); break;\n";
> ...
>   OS << "  };\n";
>   OS << "  return 0; // Visual Studio 2005 does not respect the
> no-return semantics of abort\n";
>   OS << "}\n\n";
>
> Need this because otherwise the emitted function will fail to compile in
> VStudio.
>
This might be more subtle than it seems.  I'm assuming that since that
actually fails, you have warnings-as-errors on.  In compilers with
good flow analysis that do have noreturn abort, the extra return
should trigger an "unreachable code" warning, which will also prevent
compilation with treat warnings as errors on...

I know boost has a BOOST_UNREACHABLE_RETURN(x) macro for that
situation; Perhaps LLVM should have something similar?

~ Scott McMurray



More information about the llvm-dev mailing list