[PATCH] D132997: [clang][Interp] Handle DeclRefExpr of reference types

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 7 11:06:23 PDT 2022


aaron.ballman added a comment.

In D132997#3763367 <https://reviews.llvm.org/D132997#3763367>, @tbaeder wrote:

> In D132997#3763094 <https://reviews.llvm.org/D132997#3763094>, @shafik wrote:
>
>> I think like @aaron.ballman was saying in another PR you should aim for as complete set of tests as possible even if you have to comment one that can't work yet. For example cases that would involve `MemberExpr` or `UsingShadow` for example as well as the cases you mentioned not implemented in your description.
>
> I get it for the `MaterializeTemporaryExpr`s, but I don't understand why I would add tests using `MemberExpr` now and not when I work on record types (and references have already landed).

The test case I was thinking of for that is:

  struct S {
    int i, j;
  };
  
  constexpr int test() {
    S s{1, 2};
  
    int &j = s.i;
    j += 10;
  
    return j;
  }
  
  static_assert(test() == 11, "");

where the reference is a `DeclRefExpr`. Even if structures don't work yet, capturing it as a test case now means we don't have to remember to think about "what if there's a reference to this member" when structures are implemented.



================
Comment at: clang/test/AST/Interp/references.cpp:13
+  int a = 20;
+  int &b =a;
+
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132997/new/

https://reviews.llvm.org/D132997



More information about the cfe-commits mailing list