[PATCH] Assert that DebugLoc is valid

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon May 4 11:05:57 PDT 2015


> On 2015 May 2, at 21:29, Davide Italiano <dccitaliano at gmail.com> wrote:
> 
> Hi dexonsmith,
> 
> Noticed when trying to fix PR23380.
> I think it's better to assert than segfaulting one line below.
> 
> REPOSITORY
>  rL LLVM
> 
> http://reviews.llvm.org/D9464
> 
> Files:
>  lib/IR/DiagnosticInfo.cpp
> 
> Index: lib/IR/DiagnosticInfo.cpp
> ===================================================================
> --- lib/IR/DiagnosticInfo.cpp
> +++ lib/IR/DiagnosticInfo.cpp
> @@ -136,6 +136,7 @@
>                                                  unsigned *Line,
>                                                  unsigned *Column) const {
>   DILocation *L = getDebugLoc();
> +  assert(L != nullptr && "debug location is invalid");

I'd spell this:

    assert(L && "Expected valid debug location");

LGTM either way.

>   *Filename = L->getFilename();
>   *Line = L->getLine();
>   *Column = L->getColumn();
> 
> EMAIL PREFERENCES
>  http://reviews.llvm.org/settings/panel/emailpreferences/
> <D9464.24864.patch>




More information about the llvm-commits mailing list