From dbebe6ee9c0b6e15541bf03b3bf08dd1fd107a88 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 30 Oct 2018 12:37:16 +0000 Subject: [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345594 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/SourceManager.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/clang/Basic/SourceManager.h') diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index c5a53960b3..914225a5c2 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -1428,6 +1428,18 @@ public: return getFileID(Loc) == getMainFileID(); } + /// Returns whether \p Loc is located in a file. + bool isWrittenInBuiltinFile(SourceLocation Loc) const { + StringRef Filename(getPresumedLoc(Loc).getFilename()); + return Filename.equals(""); + } + + /// Returns whether \p Loc is located in a file. + bool isWrittenInCommandLineFile(SourceLocation Loc) const { + StringRef Filename(getPresumedLoc(Loc).getFilename()); + return Filename.equals(""); + } + /// Returns if a SourceLocation is in a system header. bool isInSystemHeader(SourceLocation Loc) const { return isSystem(getFileCharacteristic(Loc)); -- cgit v1.2.3