PTH:
- Use canonical FileID when using getSpelling() caching.  This
  addresses some cache misses we were seeing with -fsyntax-only on
  Cocoa.h
- Added Preprocessor::getPhysicalCharacterAt() utility method for
  clients to grab the first character at a specified sourcelocation.
  This uses the PTH spelling cache.
- Modified Sema::ActOnNumericConstant() to use
  Preprocessor::getPhysicalCharacterAt() instead of
  SourceManager::getCharacterData() (to get PTH hits).

These changes cause -fsyntax-only to not page in any sources from
Cocoa.h.  We see a speedup of 27%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62193 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index a815265..e09ce13 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -199,7 +199,7 @@
   
   if (PTH) {
     SourceLocation sloc = SourceMgr.getPhysicalLoc(Tok.getLocation());
-    unsigned fid = sloc.getFileID();
+    unsigned fid = SourceMgr.getCanonicalFileID(sloc);
     unsigned fpos = SourceMgr.getFullFilePos(sloc);
     if (unsigned len = PTH->getSpelling(fid, fpos, TokStart)) {
       assert(!Tok.needsCleaning());
@@ -265,7 +265,7 @@
     }
     else {
       SourceLocation sloc = SourceMgr.getPhysicalLoc(Tok.getLocation());
-      unsigned fid = sloc.getFileID();
+      unsigned fid = SourceMgr.getCanonicalFileID(sloc);
       unsigned fpos = SourceMgr.getFullFilePos(sloc);      
       len = PTH->getSpelling(fid, fpos, Buffer);      
     }