While I haven't fought a lot of swarms with my CSM and I'm relatively new to them, in theory I think Noise Marines would be a good troop choice vs swarms. Lots of shots at a long range, plus a pinning heavy weapon with an Assault mode.
Granted, most swarms have a way to be fearless, but that can usually be dealt with. Nid swarms, try to pick off synapse with obliterators or something. Ork swarms, multiple squads of Noise Marines shooting at them could eventually thin them down to being pinnable, but you're almost as good in hand to hand with them anyway and will swing first even if they get Furious Charge, so that might not even matter. IG I'd probably use Berserkers or Plague Marines instead, although I've always wanted to see if Noise Marines could outshoot IG by staying at least 13" away and letting the lasguns try to single-shot their way through their power armor, while you keep changing targets to spread the Pinning effects to whatever has the most shots available.
Set them up in some cover and shoot them as they come in, with Defilers next to them, shooting them with their Battle Cannon until they get close, then Fleeting up and tying them up in CC. Or you could use Oblits instead, who can either Lascannon vehicles/MCs/etc down or Plasma Cannon swarms into goo. Either way could be good times.
For more anti-swarm fun against Nids or IG, consider Nurgle Princes with Nurgle's Rot. 6" radius S3 autohit with no scatter is pretty shiny, especially since he can use it in CC, so you blast them with it while serial crushing them with your huge friggin guy. Not as good against Orks (but can still work), so for them you would either want Winds of Chaos or to go with Lash princes to group stuff up for your pie plate attacks.