Skip to content

Commit 5328572

Browse files
committed
[cxx-interop] Use clang::CanQualType in ClangTypeExplicitSafetyDescriptor
This will hopefully improve the cache hit rate.
1 parent afaa499 commit 5328572

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

include/swift/ClangImporter/ClangImporterRequests.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,11 @@ void simple_display(llvm::raw_ostream &out, CxxValueSemanticsDescriptor desc);
625625
SourceLoc extractNearestSourceLoc(CxxValueSemanticsDescriptor desc);
626626

627627
struct ClangTypeExplicitSafetyDescriptor final {
628-
clang::QualType type;
628+
clang::CanQualType type;
629629

630-
ClangTypeExplicitSafetyDescriptor(clang::QualType type) : type(type) {}
630+
ClangTypeExplicitSafetyDescriptor(clang::CanQualType type) : type(type) {}
631+
ClangTypeExplicitSafetyDescriptor(clang::QualType type)
632+
: type(type->getCanonicalTypeUnqualified()) {}
631633

632634
friend llvm::hash_code
633635
hash_value(const ClangTypeExplicitSafetyDescriptor &desc) {

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8642,8 +8642,8 @@ SourceLoc swift::extractNearestSourceLoc(SafeUseOfCxxDeclDescriptor desc) {
86428642

86438643
void swift::simple_display(llvm::raw_ostream &out,
86448644
ClangTypeExplicitSafetyDescriptor desc) {
8645-
out << "Checking if type '" << desc.type.getAsString()
8646-
<< "' is explicitly safe.\n";
8645+
auto qt = static_cast<clang::QualType>(desc.type);
8646+
out << "Checking if type '" << qt.getAsString() << "' is explicitly safe.\n";
86478647
}
86488648

86498649
SourceLoc swift::extractNearestSourceLoc(ClangTypeExplicitSafetyDescriptor desc) {
@@ -8652,7 +8652,7 @@ SourceLoc swift::extractNearestSourceLoc(ClangTypeExplicitSafetyDescriptor desc)
86528652

86538653
ExplicitSafety ClangTypeExplicitSafety::evaluate(
86548654
Evaluator &evaluator, ClangTypeExplicitSafetyDescriptor desc) const {
8655-
auto clangType = desc.type;
8655+
auto clangType = static_cast<clang::QualType>(desc.type);
86568656

86578657
// Handle pointers.
86588658
auto pointeeType = clangType->getPointeeType();

0 commit comments

Comments
 (0)