[PATCH] D112765: [AST] injected-class-name is not a redecl, even in template specializations

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 28 15:50:50 PDT 2021


sammccall created this revision.
sammccall added reviewers: hokein, aaron.ballman, whisperity.
Herald added subscribers: rnkovacs, kbarton, nemanjai.
sammccall requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Back in the mists of time, the CXXRecordDecl for the injected-class-name was
a redecl of the outer class itself.
This got changed in 470c454a6176ef31474553e408c90f5ee630df89, but only for plain
classes: class template instantation was still detecting the injected-class-name
in the template body and marking its instantiation as a redecl.

This causes some subtle inconsistent behavior between the two, e.g.
hasDefinition() returns true for Foo<int>::Foo but false for Bar::Bar.
This is the root cause of PR51912.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112765

Files:
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112765.383183.patch
Type: text/x-patch
Size: 11682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211028/b49e028b/attachment.bin>


More information about the cfe-commits mailing list