Newer CDNs (Cloudflare, MaxCDN, fast.ly) use anycast for both DNS and actual content servers. This is somewhat better than trying to use the source IP of a DNS query and an ever changing mapping database.
In theory using anycast for both the DNS and content servers allows the network itself to find the "closest" servers to the client. In Practice, this is mostly true, but some weird cases arise where people in Singapore will hit edge servers in California instead of Hong Kong due to the ever-changing peering relationships between ISPs.
Anycast is hard to do well. See https://www.maxcdn.com/blog/anycast-ip-routing-used-maxcdn/ for more information.
Older CDN like Akamai and Limelight generally use anycast to get you to the closest DNS server, but then take the guess-based-on-source-IP approach. This doesn't work as well in my experience, especially if a client is using DNS severe that aren't actually nearby in the network topology. However, a huge established CDN like Akamai has hundreds of content server locations, so returning a "close enough" answer results in a decent user experience. Obviously, having hundreds of sites is very expensive, which is why none of the all-anycast CDNs chose that route. Consequently, They also don't charge as much for mostly-equivalent service.