mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ClangImporter] Assert when we're expecting a definition (#11170)
No functionality change.
This commit is contained in:
@@ -36,6 +36,8 @@ using namespace importer;
|
||||
/// Classify the given Clang enumeration to describe how to import it.
|
||||
void EnumInfo::classifyEnum(ASTContext &ctx, const clang::EnumDecl *decl,
|
||||
clang::Preprocessor &pp) {
|
||||
assert(decl->isThisDeclarationADefinition());
|
||||
|
||||
// Anonymous enumerations simply get mapped to constants of the
|
||||
// underlying type of the enum, because there is no way to conjure up a
|
||||
// name for the Swift type.
|
||||
|
||||
@@ -587,6 +587,13 @@ static bool matchesVersion(A *versionedAttr, ImportNameVersion version) {
|
||||
const clang::SwiftNameAttr *
|
||||
importer::findSwiftNameAttr(const clang::Decl *decl,
|
||||
ImportNameVersion version) {
|
||||
#ifndef NDEBUG
|
||||
if (Optional<const clang::Decl *> def = getDefinitionForClangTypeDecl(decl)) {
|
||||
assert((*def == nullptr || *def == decl) &&
|
||||
"swift_name should only appear on the definition");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (version == ImportNameVersion::Raw)
|
||||
return nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user