[clang] Fix noderef for array member of deref expr
authorLeonard Chan <leonardchan@google.com>
Mon, 7 Dec 2020 22:39:42 +0000 (14:39 -0800)
committerLeonard Chan <leonardchan@google.com>
Mon, 7 Dec 2020 22:39:42 +0000 (14:39 -0800)
commit155fca3cae275562e626d3e4fbfac70b4b75d2e7
treec8de5b2d62abbc75b1e2bc0860e73cb79acf5a22
parent1d03a54d9460fa122f0be9bf9018b9a4358745a9
[clang] Fix noderef for array member of deref expr

    Committing on behalf of thejh (Jann Horn).

    Given an attribute((noderef)) pointer "p" to the struct

    struct s { int a[2]; };
    ensure that the following expressions are treated the same way by the
    noderef logic:

    p->a
    (*p).a
    Until now, the first expression would be treated correctly (nothing is
    added to PossibleDerefs because CheckMemberAccessOfNoDeref() bails out
    on array members), but the second expression would incorrectly warn
    because "*p" creates a PossibleDerefs entry.

    Handle this case the same way as for the AddrOf operator.

    Differential Revision: https://reviews.llvm.org/D92140
clang/lib/Sema/SemaExprMember.cpp
clang/test/Frontend/noderef.c