aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-09-26 20:12:23 +0000
committerChris Lattner <sabre@nondot.org>2008-09-26 20:12:23 +0000
commit721818304ac462d8c6ce05eecd02884033db78f1 (patch)
treea71956e82aa61337bbefcc15fc7bb8df83a73bf4 /include/clang/Basic/SourceManager.h
parent1b9ad143c163a8e18f8dc34e8cdabfa668a53aea (diff)
Fix the rest of rdar://6243860 hopefully. This requires changing FileIDInfo
to whether the fileid is a 'extern c system header' in addition to whether it is a system header, most of this is spreading plumbing around. Once we have that, PPLexerChange bases its "file enter/exit" notifications to PPCallbacks to base the system header state on FileIDInfo instead of HeaderSearch. Finally, in Preprocessor::HandleIncludeDirective, mirror logic in GCC: the system headerness of a file being entered can be set due to the #includer or the #includee. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 770ac803ae..c8a0b490d7 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -112,10 +112,11 @@ 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:30;
+ unsigned ChunkNo : 30;
- /// isSystemHeader - Set for system header files.
- bool isSysHeader:1;
+ /// DirCharacteristic - This is an instance of DirectoryLookup::DirType,
+ /// indicating whether this is a system header dir or not.
+ unsigned DirCharacteristic : 2;
/// Content - Information about the source buffer itself.
const ContentCache* Content;
@@ -123,19 +124,22 @@ namespace SrcMgr {
public:
/// get - Return a FileIDInfo object.
static FileIDInfo get(SourceLocation IL, unsigned CN,
- const ContentCache *Con, bool SysHeader) {
+ const ContentCache *Con, unsigned DirCharacter) {
FileIDInfo X;
X.IncludeLoc = IL;
X.ChunkNo = CN;
X.Content = Con;
- X.isSysHeader = SysHeader;
+ X.DirCharacteristic = DirCharacter;
return X;
}
SourceLocation getIncludeLoc() const { return IncludeLoc; }
unsigned getChunkNo() const { return ChunkNo; }
const ContentCache* getContentCache() const { return Content; }
- bool isSystemHeader() const { return isSysHeader; }
+
+ /// getDirCharacteristic - Return whether this is a system header or not.
+ /// FIXME: rename from dir to file?
+ unsigned getDirCharacteristic() const { return DirCharacteristic; }
/// Emit - Emit this FileIDInfo to Bitcode.
void Emit(llvm::Serializer& S) const;
@@ -250,10 +254,10 @@ public:
/// being #included from the specified IncludePosition. This returns 0 on
/// error and translates NULL into standard input.
unsigned createFileID(const FileEntry *SourceFile, SourceLocation IncludePos,
- bool isSysHeader = false) {
+ unsigned DirCharacter) {
const SrcMgr::ContentCache *IR = getContentCache(SourceFile);
if (IR == 0) return 0; // Error opening file?
- return createFileID(IR, IncludePos, isSysHeader);
+ return createFileID(IR, IncludePos, DirCharacter);
}
/// createMainFileID - Create the FileID for the main source file.
@@ -261,17 +265,17 @@ public:
SourceLocation IncludePos) {
assert (MainFileID == 0 && "MainFileID already set!");
- MainFileID = createFileID(SourceFile,IncludePos);
+ MainFileID = createFileID(SourceFile, IncludePos, 0);
return MainFileID;
}
/// 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,
- bool isSysHeader = false) {
+ unsigned createFileIDForMemBuffer(const llvm::MemoryBuffer *Buffer) {
return createFileID(createMemBufferContentCache(Buffer), SourceLocation(),
- isSysHeader);
+ // FIXME: USE ENUM
+ 0/*normal header*/);
}
/// createMainFileIDForMembuffer - Create the FileID for a memory buffer
@@ -432,8 +436,13 @@ public:
/// isInSystemHeader - Returns if a SourceLocation is in a system header.
bool isInSystemHeader(SourceLocation Loc) const {
- return getFIDInfo(getPhysicalLoc(Loc).getFileID())->isSystemHeader();
+ // FIXME: Use proper enum here!
+ return getDirCharacteristic(Loc) != 0;
+ }
+ unsigned getDirCharacteristic(SourceLocation Loc) const {
+ return getFIDInfo(getPhysicalLoc(Loc).getFileID())->getDirCharacteristic();
}
+
/// PrintStats - Print statistics to stderr.
///
@@ -453,7 +462,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, bool isSysHeader = false);
+ SourceLocation IncludePos, unsigned DirCharacter);
/// getContentCache - Create or return a cached ContentCache for the specified
/// file. This returns null on failure.