Don't use StringRef iterator functions for data access

And also remove some redundant casts from r212371.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212397 91177308-0d34-0410-b5e6-96231b3b80d8
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212398 91177308-0d34-0410-b5e6-96231b3b80d8