[all-commits] [llvm/llvm-project] 6a5e08: [AST] injected-class-name is not a redecl, even in...

Sam McCall via All-commits all-commits at lists.llvm.org
Tue Nov 2 06:38:08 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a5e08cc4a5c64de08a277dd2e0a862120c5fc28
      https://github.com/llvm/llvm-project/commit/6a5e08cc4a5c64de08a277dd2e0a862120c5fc28
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2021-11-02 (Tue, 02 Nov 2021)

  Changed paths:
    M clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/lib/AST/ASTDumper.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/test/AST/ast-dump-decl.cpp
    M clang/test/AST/ast-dump-openmp-begin-declare-variant_reference.cpp
    M clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp

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

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.

Differential Revision: https://reviews.llvm.org/D112765




More information about the All-commits mailing list