diff options
author | Nico Weber <nicolasweber@gmx.de> | 2008-08-10 19:59:06 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2008-08-10 19:59:06 +0000 |
commit | 7bfaaaecb3113f955db31e8d8a51acffd1bc0c27 (patch) | |
tree | bac57d5f77ac6696a51a822a63f513fb92d79a65 /include/clang/Basic/SourceManager.h | |
parent | 3ac5e9fc38e1a59da84844f6adb95e803779098d (diff) |
* Remove isInSystemHeader() from DiagClient, move it to SourceManager
* Move FormatError() from TextDiagnostic up to DiagClient, remove now
empty class TextDiagnostic
* Make DiagClient optional for Diagnostic
This fixes the following problems:
* -html-diags (and probably others) does now output the same set of
warnings as console clang does
* nothing crashes if one forgets to call setHeaderSearch() on
TextDiagnostic
* some code duplication is removed
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 7cb1f4c4ba..7cc4087db8 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -112,25 +112,30 @@ namespace SrcMgr { /// ChunkNo - Really large buffers are broken up into chunks that are /// each (1 << SourceLocation::FilePosBits) in size. This specifies the /// chunk number of this FileID. - unsigned ChunkNo; + unsigned ChunkNo:30; + + /// isSystemHeader - Set for system header files. + bool isSysHeader:1; /// Content - Information about the source buffer itself. const ContentCache* Content; - + public: /// get - Return a FileIDInfo object. static FileIDInfo get(SourceLocation IL, unsigned CN, - const ContentCache *Con) { + const ContentCache *Con, bool SysHeader) { FileIDInfo X; X.IncludeLoc = IL; X.ChunkNo = CN; X.Content = Con; + X.isSysHeader = SysHeader; return X; } SourceLocation getIncludeLoc() const { return IncludeLoc; } unsigned getChunkNo() const { return ChunkNo; } const ContentCache* getContentCache() const { return Content; } + bool isSystemHeader() const { return isSysHeader; } /// Emit - Emit this FileIDInfo to Bitcode. void Emit(llvm::Serializer& S) const; @@ -244,10 +249,11 @@ public: /// createFileID - Create a new FileID that represents the specified file /// being #included from the specified IncludePosition. This returns 0 on /// error and translates NULL into standard input. - unsigned createFileID(const FileEntry *SourceFile, SourceLocation IncludePos){ + unsigned createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, + bool isSysHeader = false) { const SrcMgr::ContentCache *IR = getContentCache(SourceFile); if (IR == 0) return 0; // Error opening file? - return createFileID(IR, IncludePos); + return createFileID(IR, IncludePos, isSysHeader); } /// createMainFileID - Create the FileID for the main source file. @@ -262,8 +268,10 @@ public: /// createFileIDForMemBuffer - Create a new FileID that represents the /// specified memory buffer. This does no caching of the buffer and takes /// ownership of the MemoryBuffer, so only pass a MemoryBuffer to this once. - unsigned createFileIDForMemBuffer(const llvm::MemoryBuffer *Buffer) { - return createFileID(createMemBufferContentCache(Buffer), SourceLocation()); + unsigned createFileIDForMemBuffer(const llvm::MemoryBuffer *Buffer, + bool isSysHeader = false) { + return createFileID(createMemBufferContentCache(Buffer), SourceLocation(), + isSysHeader); } /// createMainFileIDForMembuffer - Create the FileID for a memory buffer @@ -421,6 +429,12 @@ public: bool isFromMainFile(SourceLocation Loc) const { return getCanonicalFileID(Loc) == getMainFileID(); } + + /// isInSystemHeader - Returns if a SourceLocation is in a system header. + bool isInSystemHeader(SourceLocation Loc) const { + assert (Loc.isFileID() && "method only valid for file ids"); + return getFIDInfo(Loc.getFileID())->isSystemHeader(); + } /// PrintStats - Print statistics to stderr. /// @@ -440,7 +454,7 @@ private: /// include position. This works regardless of whether the ContentCache /// corresponds to a file or some other input source. unsigned createFileID(const SrcMgr::ContentCache* File, - SourceLocation IncludePos); + SourceLocation IncludePos, bool isSysHeader = false); /// getContentCache - Create or return a cached ContentCache for the specified /// file. This returns null on failure. |