[llvm-commits] [lld] r158541 - /lld/trunk/lib/ReaderWriter/MachO/ReferenceKinds.cpp

Nick Kledzik kledzik at apple.com
Fri Jun 15 13:55:51 PDT 2012


On Jun 15, 2012, at 1:43 PM, Michael Spencer wrote:

>> +    .Case("lazyTarget",         lazyTarget)
>> +    .Case("lazyImmediate",      lazyImmediate)
>> +    .Case("subordinateLSDA",    subordinateLSDA);
>> 
>>   assert(0 && "invalid ARM Reference kind");
>>   return 0;
> 
> This isn't handling the default (unknown string) case. Generally how I
> handle this with StringSwitch is to use some specific value to
> represent the default case and checking for that.
Unknown strings are an error.   But I suppose there are cases where we don't want the assert to fire, but instead to bubble up the error to the caller.   I suppose that means adding a value to the Reference Kind enumeration called "invalid" or something.


> 
> Also the assert and return 0 are now dead code. And the assert should
> be a llvm_unreachable.

The next commit switched to using llvm_unreachable.  I got my fingers slapped for doing more than one change in a patch ;-)

-Nick




More information about the llvm-commits mailing list