• Nico Weber's avatar
    Remove comparisons of this with NULL. · 1aef6f55
    Nico Weber authored
    Calling functions on objects that are NULL is undefined behavior.
    Hence, new versions of clang assume that `this` is never NULL,
    warn on comparisons of `this` with NULL, and optimize the comparison away.
    
    There were three comparisons of `this` with NULL in re2:
    
    1. CharClass::Delete(). There are only two callers of this method, and
       as far as I can tell `this` can't be NULL there, so just delete that check.
    2. Prefilter::DebugString(). This too has two callers: Prefilter::Info::ToString(),
       which already checks for NULL before calling, and DebugString() itself.
       Since several places check Prefilters for NULL, add explicit checks before
       calling here.
    3. Prefilter::Info::ToString(). This has three callers. In 2 cases this can't be
       NULL. In the third case it could conceivably be NULL if op() is
       kRegexpConcat and nchild_args is 0, so add an explicit check here.
    
    Fixes https://code.google.com/p/re2/issues/detail?id=115
    
    LGTM=rsc
    R=rsc
    CC=re2-dev
    https://codereview.appspot.com/107100043
    1aef6f55