Files
carbon-lang/toolchain/lower/clang_global_decl.cpp
T
Richard Smith c7cd24e1b2 Support for calling C++ destructors. (#6453)
Synthesize an impl of `Destroy` for C++ classes in response to impl
lookup.
2025-12-09 21:03:27 +00:00

24 lines
814 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/lower/clang_global_decl.h"
namespace Carbon::Lower {
auto CreateGlobalDecl(const clang::NamedDecl* decl) -> clang::GlobalDecl {
if (const auto* constructor_decl =
dyn_cast<clang::CXXConstructorDecl>(decl)) {
return clang::GlobalDecl(constructor_decl,
clang::CXXCtorType::Ctor_Complete);
}
if (const auto* destructor_decl = dyn_cast<clang::CXXDestructorDecl>(decl)) {
return clang::GlobalDecl(destructor_decl,
clang::CXXDtorType::Dtor_Complete);
}
return clang::GlobalDecl(decl);
}
} // namespace Carbon::Lower