Skip to content

Commit b51e0f6

Browse files
committed
[ClangImporter] Refactor off CF reasoning helpers
Move helper methods off of the Impl and into CFTypeInfo.h, where we have the other CF type reasoning logic. NFC
1 parent ffadf05 commit b51e0f6

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

lib/ClangImporter/CFTypeInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ CFPointeeInfo::classifyTypedef(const clang::TypedefNameDecl *typedefDecl) {
101101
return forInvalid();
102102
}
103103

104-
bool ClangImporter::Implementation::isCFTypeDecl(
104+
bool importer::isCFTypeDecl(
105105
const clang::TypedefNameDecl *Decl) {
106106
if (CFPointeeInfo::classifyTypedef(Decl))
107107
return true;
108108
return false;
109109
}
110110

111-
StringRef ClangImporter::Implementation::getCFTypeName(
111+
StringRef importer::getCFTypeName(
112112
const clang::TypedefNameDecl *decl) {
113113
if (auto pointee = CFPointeeInfo::classifyTypedef(decl)) {
114114
auto name = decl->getName();

lib/ClangImporter/CFTypeInfo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ class CFPointeeInfo {
104104
return Decl.get<const clang::TypedefNameDecl *>();
105105
}
106106
};
107+
108+
/// Determine whether this typedef is a CF type.
109+
bool isCFTypeDecl(const clang::TypedefNameDecl *Decl);
110+
111+
/// Determine the imported CF type for the given typedef-name, or the empty
112+
/// string if this is not an imported CF type name.
113+
llvm::StringRef getCFTypeName(const clang::TypedefNameDecl *decl);
107114
}
108115
}
109116

lib/ClangImporter/IAMInference.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ class IAMInference {
503503
static StringRef getTypeName(clang::QualType qt) {
504504
if (auto typedefTy = qt->getAs<clang::TypedefType>()) {
505505
// Check for a CF type name (drop the "Ref")
506-
auto cfName = ClangImporter::Implementation::getCFTypeName(
507-
typedefTy->getDecl()->getCanonicalDecl());
506+
auto cfName = getCFTypeName(typedefTy->getDecl()->getCanonicalDecl());
508507
if (cfName != StringRef())
509508
return cfName;
510509
}

lib/ClangImporter/ImportName.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717

18+
#include "CFTypeInfo.h"
1819
#include "IAMInference.h"
1920
#include "ImporterImpl.h"
2021
#include "ClangDiagnosticConsumer.h"

lib/ClangImporter/ImportType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "CFTypeInfo.h"
1718
#include "ImporterImpl.h"
1819
#include "ClangDiagnosticConsumer.h"
1920
#include "swift/Strings.h"
@@ -573,7 +574,7 @@ namespace {
573574
ImportHint hint = ImportHint::None;
574575

575576
if (Impl.getSwiftNewtypeAttr(type->getDecl(), /*useSwift2Name=*/false)) {
576-
if (ClangImporter::Implementation::isCFTypeDecl(type->getDecl()))
577+
if (isCFTypeDecl(type->getDecl()))
577578
hint = ImportHint::SwiftNewtypeFromCFPointer;
578579
else
579580
hint = ImportHint::SwiftNewtype;

lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
717717
/// or a null type if the DeclContext does not have a corresponding type.
718718
static clang::QualType getClangDeclContextType(const clang::DeclContext *dc);
719719

720-
/// Determine whether this typedef is a CF type.
721-
static bool isCFTypeDecl(const clang::TypedefNameDecl *Decl);
722-
723-
/// Determine the imported CF type for the given typedef-name, or the empty
724-
/// string if this is not an imported CF type name.
725-
static StringRef getCFTypeName(const clang::TypedefNameDecl *decl);
726-
727720
/// Retrieve the type name of a Clang type for the purposes of
728721
/// omitting unneeded words.
729722
static OmissionTypeName getClangTypeNameForOmission(clang::ASTContext &ctx,

0 commit comments

Comments
 (0)