lib/ClangImporter/ImportDecl.cpp
/// \brief Classify the given Clang enumeration to describe how to import it.
\brief Classify the given Clang enumeration to describe how to import it.
\ brief Classify the given Clang enumeration to describe how to import it .
EnumKind ClangImporter::Implementation::
classifyEnum(clang::Preprocessor &pp, const clang::EnumDecl *decl) {
  if (!decl->hasNameForLinkage())
    return EnumKind::Constants;
  auto loc = decl->getLocStart();
  if (loc.isMacroID()) {
    StringRef MacroName = pp.getImmediateMacroName(loc);
    if (MacroName == "CF_ENUM" || MacroName == "__CF_NAMED_ENUM" ||
        MacroName == "OBJC_ENUM" ||
        MacroName == "SWIFT_ENUM" || MacroName == "SWIFT_ENUM_NAMED")
      return EnumKind::Enum;
    if (MacroName == "CF_OPTIONS" || MacroName == "OBJC_OPTIONS"
        || MacroName == "SWIFT_OPTIONS")
      return EnumKind::Options;
  }
  if (decl->getName() == "DYLD_BOOL")
    return EnumKind::Enum;
  return EnumKind::Unknown;
}
EnumKind ClangImporter :: Implementation :: classifyEnum ( clang :: Preprocessor & pp , const clang :: EnumDecl * decl ) { if ( ! decl -> hasNameForLinkage ( ) ) return EnumKind :: Constants ; auto loc = decl -> getLocStart ( ) ; if ( loc . isMacroID ( ) ) { StringRef MacroName = pp . getImmediateMacroName ( loc ) ; if ( MacroName == " " || MacroName == " " || MacroName == " " || MacroName == " " || MacroName == " " ) return EnumKind :: Enum ; if ( MacroName == " " || MacroName == " " || MacroName == " " ) return EnumKind :: Options ; } if ( decl -> getName ( ) == " " ) return EnumKind :: Enum ; return EnumKind :: Unknown ; }
\brief Classify the given Clang enumeration to describe how to import it.
\ brief Classify the given Clang enumeration to describe how to import it .
// 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. // Was the enum declared using *_ENUM or *_OPTIONS? // FIXME: Use Clang attributes instead of grovelling the macro expansion loc. // Hardcode a particular annoying case in the OS X headers. // Fall back to the 'Unknown' path.