     self.enumDescriptor = descriptor
     self.generatorOptions = generatorOptions
     self.namer = namer
-
-    mainEnumValueDescriptors = descriptor.values.filter({
-      return $0.aliasOf == nil
-    })
-    mainEnumValueDescriptorsSorted = mainEnumValueDescriptors.sorted(by: {
+    aliasInfo = EnumDescriptor.ValueAliasInfo(enumDescriptor: descriptor)
+
+    mainEnumValueDescriptorsSorted = aliasInfo.mainValues.sorted(by: {
       return $0.number < $1.number
     })
 

    p.print("\(visibility)static let _protobuf_nameMap: \(namer.swiftProtobufModuleName)._NameMap = [")
    p.withIndentation { p in
      for v in mainEnumValueDescriptorsSorted {
        if v.aliases.isEmpty {
          p.print("\(v.number): .same(proto: \"\(v.name)\"),")
        } else {
          let aliasNames = v.aliases.map({ "\"\($0.name)\"" }).joined(separator: ", ")
          p.print("\(v.number): .aliased(proto: \"\(v.name)\", aliases: [\(aliasNames)]),")
        }
      }
    }

  private let generatorOptions: GeneratorOptions
  private let namer: SwiftProtobufNamer

  /// The aliasInfo for the values.
  private let aliasInfo: EnumDescriptor.ValueAliasInfo
  /// The values that aren't aliases, sorted by number.
  private let mainEnumValueDescriptorsSorted: [EnumValueDescriptor]

