示例#1
0
        private bool UnsupportedTemplateArgument(ClassTemplateSpecialization specialization, TemplateArgument a)
        {
            if (a.Type.Type == null ||
                CheckIgnoredDeclsPass.IsTypeExternal(
                    specialization.TranslationUnit.Module, a.Type.Type))
                return true;

            var typeIgnoreChecker = new TypeIgnoreChecker(Context.TypeMaps);
            a.Type.Type.Visit(typeIgnoreChecker);
            return typeIgnoreChecker.IsIgnored;
        }
        public override bool VisitClassDecl(Class @class)
        {
            if (!base.VisitClassDecl(@class) || @class.IsIncomplete || [email protected])
            {
                return(false);
            }

            @class.Specializations.RemoveAll(
                s => s.Fields.Any(f => f.Type.IsPrimitiveType(PrimitiveType.Void)));

            foreach (var specialization in @class.Specializations.Where(s => s.Arguments.Any(
                                                                            a => a.Type.Type != null &&
                                                                            CheckIgnoredDeclsPass.IsTypeExternal(@class.TranslationUnit.Module, a.Type.Type)) ||
                                                                        @class is ClassTemplatePartialSpecialization))
            {
                specialization.ExplicitlyIgnore();
            }

            if (@class.Specializations.Count == 0)
            {
                return(false);
            }

            Func <TemplateArgument, bool> allPointers = a => a.Type.Type != null && a.Type.Type.IsAddress();
            var groups = (from specialization in @class.Specializations
                          group specialization by specialization.Arguments.All(allPointers) into @group
                          select @group).ToList();

            foreach (var group in groups.Where(g => g.Key))
            {
                foreach (var specialization in group.Skip(1))
                {
                    @class.Specializations.Remove(specialization);
                }
            }

            for (int i = @class.Specializations.Count - 1; i >= 0; i--)
            {
                if (@class.Specializations[i] is ClassTemplatePartialSpecialization &&
                    [email protected][i].Arguments.All(allPointers))
                {
                    @class.Specializations.RemoveAt(i);
                }
            }

            return(true);
        }