[lld] r218197 - Silence these C4715 warnings from Visual C++ (NFC)
David Blaikie
dblaikie at gmail.com
Sat Sep 20 22:12:17 PDT 2014
On Sat, Sep 20, 2014 at 9:13 PM, Yaron Keren <yaron.keren at gmail.com> wrote:
> Author: yrnkrn
> Date: Sat Sep 20 23:13:45 2014
> New Revision: 218197
>
> URL: http://llvm.org/viewvc/llvm-project?rev=218197&view=rev
> Log:
> Silence these C4715 warnings from Visual C++ (NFC)
>
> llvm\tools\lld\lib\readerwriter\macho\macholinkingcontext.cpp(647):
> warning C4715: 'lld::MachOLinkingContext::exportSymbolNamed' :
> not all control paths return a value
>
>
> llvm\tools\lld\lib\readerwriter\macho\machonormalizedfilefromatoms.cpp(723):
> warning C4715: '`anonymous namespace'::Util::getSymbolTableRegion' :
> not all control paths return a value
>
> While all enum values do appear in the switch, an uninitialized or
> corrupted
> enum variable would not be caught without the default: case in the switch.
>
Usually the right way to deal with this is to put the unreachable /after/
the switch, rather than adding a default (& you don't need a return after
an unreachable in any context)
Your change will probably cause a -Wcovered-switch-default warning/break,
unfortunately.
>
>
> Modified:
> lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
> lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=218197&r1=218196&r2=218197&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Sat Sep 20
> 23:13:45 2014
> @@ -643,6 +643,8 @@ bool MachOLinkingContext::exportSymbolNa
> return _exportedSymbols.count(sym);
> case ExportMode::blackList:
> return !_exportedSymbols.count(sym);
> + default:
> + llvm_unreachable("_exportMode unknown enum value");
> }
> }
>
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=218197&r1=218196&r2=218197&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
> (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Sat
> Sep 20 23:13:45 2014
> @@ -719,6 +719,9 @@ std::error_code Util::getSymbolTableRegi
> return std::error_code();
> }
> break;
> + default:
> + llvm_unreachable("atom->scope() unknown enum value");
> + return std::error_code();
> }
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140920/4a30be2e/attachment.html>
More information about the llvm-commits
mailing list