llvm-project
652ae4ec - [Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (#88777)

Commit
1 year ago
[Clang][Sema] Warn when 'exclude_from_explicit_instantiation' attribute is used on local classes and members thereof (#88777) A local class and its members declared in a function template are instantiated alongside the definition of that template. It therefore does not make sense to apply the `exclude_from_explicit_instantiation` attribute to such declarations, and this patch adds a warning to diagnose these cases (in addition to ignoring the attribute). (The motivation for this patch is to fix a failing test in libc++ for #84050. In particular, line 199 in `include/__memory/uses_allocator_construction.h` in libc++ contains the expression `this->__value_` (reduced to https://godbolt.org/z/KqEerKWPd) which will be looked up prior to instantiation once #84050 lands (the lookup context is the current instantiation). `_LIBCPP_HIDE_FROM_ABI` includes `__attribute__((exclude_from_explicit_instantiation))`, which in the reduced example results in `Local` being instantiated with `Local::operator A` as its `DeclContext`)
Author
Parents
Loading