Skip to content

Instantiated CXXMethods are not always added at any DeclContext #23216

@llvmbot

Description

@llvmbot
Bugzilla Link 22842
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

Instantiated CXXMethods (e.g. CXXConstructorDecl) in TemplateDeclInstantiator (SemaTemplateInstantiateDecl.cpp) can go through one of two code paths.

  1. Thru VisitFunctionTemplateDecl->VisitCXXMethodDecl->VisitCXXMethodDecl in which case they are not added to the Owner DeclContext by VisitCXXMethodDecl due to
  // If there's a function template, let our caller handle it.
  if (FunctionTemplate) {

but indeed added to DeclContext by the caller VisitFunctionTemplateDecl:

  Owner->addDecl(InstTemplate);
  1. Thru VisitCXXConstructorDecl->VisitCXXMethodDecl->VisitCXXMethodDecl in which case, although VisitCXXMethodDecl expects the caller to addDecl to the DeclContext, it does not do so as far as I could follow the code.

I don't know if this is a bug but it does seem inconsistent behaviour between the two cases and with comment.

Shouldn't all CXXMethods be addDecl-ed to some DeclConext?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions