Skip to content

Commit 4432453

Browse files
authored
Merge pull request #39432 from zoecarver/lazy-pt4-misc-changes
[cxx-interop] A few misc. changes from #38675.
2 parents 9bf9de8 + 0adf067 commit 4432453

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,8 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl) {
23422342
// Note: Namespaces are not really enums, but since namespaces are
23432343
// imported as enums, be consistent.
23442344
appendOperator("O");
2345+
} else if (isa<clang::ClassTemplateDecl>(namedDecl)) {
2346+
appendIdentifier(nominal->getName().str());
23452347
} else {
23462348
llvm_unreachable("unknown imported Clang type");
23472349
}

lib/AST/ASTPrinter.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ class PrintAST : public ASTVisitor<PrintAST> {
991991
}
992992
}
993993

994-
994+
995995
Printer.callPrintDeclPre(D, Options.BracketOptions);
996996

997997
bool haveFeatureChecks = Options.PrintCompatibilityFeatureChecks &&
@@ -2784,14 +2784,14 @@ static bool usesFeatureImplicitSelfCapture(Decl *decl) {
27842784
/// want a baseline version.
27852785
static std::vector<Feature> getFeaturesUsed(Decl *decl) {
27862786
std::vector<Feature> features;
2787-
2787+
27882788
// Go through each of the features, checking whether the declaration uses that
27892789
// feature. This also ensures that the resulting set is in sorted order.
27902790
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
27912791
if (usesFeature##FeatureName(decl)) \
27922792
features.push_back(Feature::FeatureName);
27932793
#include "swift/Basic/Features.def"
2794-
2794+
27952795
return features;
27962796
}
27972797

@@ -2852,7 +2852,7 @@ bool swift::printCompatibilityFeatureChecksPre(
28522852
if (features.empty())
28532853
return false;
28542854

2855-
printer.printNewline();
2855+
printer.printNewline();
28562856
printer << "#if compiler(>=5.3) && ";
28572857
llvm::interleave(features.begin(), features.end(),
28582858
[&](Feature feature) {
@@ -2977,7 +2977,7 @@ void PrintAST::visitPoundDiagnosticDecl(PoundDiagnosticDecl *PDD) {
29772977
if (PDD->isError()) {
29782978
Printer << tok::pound_error;
29792979
} else {
2980-
Printer << tok::pound_warning;
2980+
Printer << tok::pound_warning;
29812981
}
29822982

29832983
Printer << "(\"" << PDD->getMessage()->getValue() << "\")";
@@ -3609,7 +3609,7 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
36093609
}
36103610

36113611
printBodyIfNecessary(decl);
3612-
3612+
36133613
// If the function has an opaque result type, print the opaque type decl.
36143614
if (auto opaqueResult = decl->getOpaqueResultTypeDecl()) {
36153615
Printer.printNewline();
@@ -4939,7 +4939,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
49394939
});
49404940
Printer << ">";
49414941
}
4942-
4942+
49434943
void visitGenericFunctionType(GenericFunctionType *T) {
49444944
Printer.callPrintStructurePre(PrintStructureKind::FunctionType);
49454945
SWIFT_DEFER {
@@ -5021,7 +5021,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
50215021
PrintAST::PrintRequirements);
50225022
Printer << " ";
50235023
}
5024-
5024+
50255025
// If this is a substituted function type, then its generic signature is
50265026
// independent of the enclosing context, and defines the parameters active
50275027
// in the interface params and results. Unsubstituted types use the existing
@@ -5044,7 +5044,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
50445044
PrintAST::PrintRequirements);
50455045
sub->Printer << " ";
50465046
}
5047-
5047+
50485048
// Capture list used here to ensure we don't print anything using `this`
50495049
// printer, but only the sub-Printer.
50505050
[T, sub, &subOptions] {
@@ -5226,7 +5226,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
52265226
Printer << "@opened(\"" << T->getOpenedExistentialID() << "\") ";
52275227
visit(T->getOpenedExistentialType());
52285228
}
5229-
5229+
52305230
void printArchetypeCommon(ArchetypeType *T,
52315231
const AbstractTypeParamDecl *Decl) {
52325232
if (Options.AlternativeTypeNames) {
@@ -5251,11 +5251,11 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
52515251
visitParentType(T->getParent());
52525252
printArchetypeCommon(T, T->getAssocType());
52535253
}
5254-
5254+
52555255
void visitPrimaryArchetypeType(PrimaryArchetypeType *T) {
52565256
printArchetypeCommon(T, T->getInterfaceType()->getDecl());
52575257
}
5258-
5258+
52595259
void visitOpaqueTypeArchetypeType(OpaqueTypeArchetypeType *T) {
52605260
switch (Options.OpaqueReturnTypePrinting) {
52615261
case PrintOptions::OpaqueReturnTypePrintingMode::WithOpaqueKeyword:
@@ -5272,14 +5272,14 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
52725272
// type.
52735273
Printer << "@_opaqueReturnTypeOf(";
52745274
OpaqueTypeDecl *decl = T->getDecl();
5275-
5275+
52765276
Printer.printEscapedStringLiteral(
52775277
decl->getOpaqueReturnTypeIdentifier().str());
5278-
5278+
52795279
Printer << ", " << T->getInterfaceType()
52805280
->castTo<GenericTypeParamType>()
52815281
->getIndex();
5282-
5282+
52835283
// The identifier after the closing parenthesis is irrelevant and can be
52845284
// anything. It just needs to be there for the @_opaqueReturnTypeOf
52855285
// attribute to apply to, but the attribute alone references the opaque
@@ -5433,7 +5433,7 @@ void LayoutConstraintInfo::print(ASTPrinter &Printer,
54335433
break;
54345434
}
54355435
}
5436-
5436+
54375437
void LayoutConstraint::dump() const {
54385438
if (!*this) {
54395439
llvm::errs() << "(null)\n";

lib/ClangImporter/ImportName.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,11 +1709,12 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
17091709
case clang::DeclarationName::CXXOperatorName: {
17101710
auto op = D->getDeclName().getCXXOverloadedOperator();
17111711
auto functionDecl = dyn_cast<clang::FunctionDecl>(D);
1712-
if (!functionDecl) {
1713-
// This can happen for example for templated operators functions.
1714-
// We don't support those, yet.
1712+
1713+
if (auto functionTemplate = dyn_cast<clang::FunctionTemplateDecl>(D))
1714+
functionDecl = functionTemplate->getAsFunction();
1715+
1716+
if (!functionDecl)
17151717
return ImportedName();
1716-
}
17171718

17181719
switch (op) {
17191720
case clang::OverloadedOperatorKind::OO_Plus:

0 commit comments

Comments
 (0)