diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
commit | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch) | |
tree | 02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /include/clang/Basic/SourceManager.h | |
parent | c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff) |
Notes
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index af7dbbc13ca7b..dcc4a37e239cd 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -449,7 +449,7 @@ namespace SrcMgr { } static SLocEntry get(unsigned Offset, const FileInfo &FI) { - assert(!(Offset & (1 << 31)) && "Offset is too large"); + assert(!(Offset & (1u << 31)) && "Offset is too large"); SLocEntry E; E.Offset = Offset; E.IsExpansion = false; @@ -458,7 +458,7 @@ namespace SrcMgr { } static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) { - assert(!(Offset & (1 << 31)) && "Offset is too large"); + assert(!(Offset & (1u << 31)) && "Offset is too large"); SLocEntry E; E.Offset = Offset; E.IsExpansion = true; @@ -1024,13 +1024,14 @@ public: /// Set the number of FileIDs (files and macros) that were created /// during preprocessing of \p FID, including it. - void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs) const { + void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs, + bool Force = false) const { bool Invalid = false; const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid); if (Invalid || !Entry.isFile()) return; - assert(Entry.getFile().NumCreatedFIDs == 0 && "Already set!"); + assert((Force || Entry.getFile().NumCreatedFIDs == 0) && "Already set!"); const_cast<SrcMgr::FileInfo &>(Entry.getFile()).NumCreatedFIDs = NumFIDs; } @@ -1428,6 +1429,18 @@ public: return getFileID(Loc) == getMainFileID(); } + /// Returns whether \p Loc is located in a <built-in> file. + bool isWrittenInBuiltinFile(SourceLocation Loc) const { + StringRef Filename(getPresumedLoc(Loc).getFilename()); + return Filename.equals("<built-in>"); + } + + /// Returns whether \p Loc is located in a <command line> file. + bool isWrittenInCommandLineFile(SourceLocation Loc) const { + StringRef Filename(getPresumedLoc(Loc).getFilename()); + return Filename.equals("<command line>"); + } + /// Returns if a SourceLocation is in a system header. bool isInSystemHeader(SourceLocation Loc) const { return isSystem(getFileCharacteristic(Loc)); |