[clang] Move two utility functions into SourceManager

Summary: So we can keep that not-so-great logic in one place.

Reviewers: rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: nemanjai, kbarton, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D53837

llvm-svn: 345594
diff --git a/clang/lib/CodeGen/MacroPPCallbacks.cpp b/clang/lib/CodeGen/MacroPPCallbacks.cpp
index 48dea7d..05acc9b 100644
--- a/clang/lib/CodeGen/MacroPPCallbacks.cpp
+++ b/clang/lib/CodeGen/MacroPPCallbacks.cpp
@@ -88,16 +88,6 @@
   return SourceLocation();
 }
 
-static bool isBuiltinFile(SourceManager &SM, SourceLocation Loc) {
-  StringRef Filename(SM.getPresumedLoc(Loc).getFilename());
-  return Filename.equals("<built-in>");
-}
-
-static bool isCommandLineFile(SourceManager &SM, SourceLocation Loc) {
-  StringRef Filename(SM.getPresumedLoc(Loc).getFilename());
-  return Filename.equals("<command line>");
-}
-
 void MacroPPCallbacks::updateStatusToNextScope() {
   switch (Status) {
   case NoScope:
@@ -127,7 +117,7 @@
     updateStatusToNextScope();
     return;
   case BuiltinScope:
-    if (isCommandLineFile(PP.getSourceManager(), Loc))
+    if (PP.getSourceManager().isWrittenInCommandLineFile(Loc))
       return;
     updateStatusToNextScope();
     LLVM_FALLTHROUGH;
@@ -147,7 +137,7 @@
   default:
     llvm_unreachable("Do not expect to exit a file from current scope");
   case BuiltinScope:
-    if (!isBuiltinFile(PP.getSourceManager(), Loc))
+    if (!PP.getSourceManager().isWrittenInBuiltinFile(Loc))
       // Skip next scope and change status to MainFileScope.
       Status = MainFileScope;
     return;