Don't use StringRef iterator functions for data access

And also remove some redundant casts from r212371.
SourceMgr: make valid buffer IDs start from one

Use 0 for the invalid buffer instead of -1/~0 and switch to unsigned
representation to enable more idiomatic usage.

Also introduce a trivial SourceMgr::getMainFileID() instead of hard-coding 0/1
to identify the main file.