[ClangImporter] Assert when we're expecting a definition (#11170)

No functionality change.
This commit is contained in:
Jordan Rose
2017-07-27 09:06:43 -07:00
committed by GitHub
parent b097197d28
commit 2c68f8d49d
2 changed files with 9 additions and 0 deletions

View File

@@ -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.

View File

@@ -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;