mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-25 22:01:10 +00:00
Add support for exporting Carbon functions as constructors. (#7560)
Co-authored-by: Nicholas Bishop <nbishop@nbishop.net>
This commit is contained in:
1 parent
de68b19784
commit
3cb143e878
7 files changed
+576
-100
No files matched your search
@@ -574,10 +574,21 @@ auto CarbonExternalASTSource::FindExternalVisibleDeclsByName(
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* identifier = decl_name.getAsIdentifierInfo();
|
||||
if (!identifier) {
|
||||
// Only supporting identifiers for now.
|
||||
return false;
|
||||
clang::IdentifierInfo* identifier = nullptr;
|
||||
switch (decl_name.getNameKind()) {
|
||||
case clang::DeclarationName::Identifier: {
|
||||
identifier = decl_name.getAsIdentifierInfo();
|
||||
break;
|
||||
}
|
||||
case clang::DeclarationName::CXXConstructorName: {
|
||||
// The Carbon counterpart of a constructor is a function whose name
|
||||
// matches the class name.
|
||||
identifier =
|
||||
llvm::cast<clang::CXXRecordDecl>(decl_context)->getIdentifier();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
auto name_id = AddIdentifierName(*context_, identifier->getName());
|
||||
|
||||
Reference in new issue
Block a user