[clang] [clang][Sema] Fix particular operator overload crash (PR #105976)

Nicolas van Kempen via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 2 21:47:08 PDT 2024


nicovank wrote:

The reason for the break in 0cb7e7ca0c864e052bf49978f3bcd667c9e16930 is that prior to this commit, using declarations were always kept at the front of the `NamedDecl` list. This behavior was changed in that commit.

See a comment here:
https://github.com/llvm/llvm-project/blob/3b8b5d1f22f2c5d8ae55709a92d02011dea056ca/clang/include/clang/AST/DeclContextInternals.h#L213-L216

Here, we re-establish the behavior of keeping using declarations at the head in `addOrReplaceDecl`.
https://github.com/llvm/llvm-project/blob/3b8b5d1f22f2c5d8ae55709a92d02011dea056ca/clang/include/clang/AST/DeclContextInternals.h#L218-L224

Some thoughts:
 1. Seems to me like this order shouldn't be relied on somewhere else in the code. But I'm not familiar.
 2. I conjecture that this custom-built linked list is overkill and doesn't actually have any significant runtime or memory win over `std::forward_list` for example. It makes the code hard to work with. But it's also pretty deeply ingrained into the code at this point.

Let me know what you think of this change (seems like the right way to go / worth it?) or any other solutions. It's a little heavy at the moment with the triple `Decl::IDNS_Using` check, I'll think about simplifying it.



https://github.com/llvm/llvm-project/pull/105976


More information about the cfe-commits mailing list