[PATCH] D19632: [scan-build] fix logic error warnings emitted on llvm code base

Richard Osborne via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 08:39:45 PDT 2016


On 27/04/16 23:06, Apelete Seketeli wrote:
> -
> +
> +  assert(SecondLastInst && "does not point to a valid instruction");
>     unsigned SecondLastOpc    = SecondLastInst->getOpcode();
>     XCore::CondCode BranchCode = GetCondFromBranchOpc(SecondLastOpc);
>     
SecondLastInst should never be null at this point as we would have 
returned from the function earlier if there was only one terminator. It 
is also the case that SecondLastInst should be non null when the if 
statement on line 233 is executed:

   if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(*--I))

Therefore this if condition can be changed to:

   if (I != MBB.begin() && isUnpredicatedTerminator(*--I))

If the changing the if condition silences the static analyzer I think 
that would be a better fix.


More information about the llvm-commits mailing list