diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/FileManager.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 31 | ||||
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 15 |
3 files changed, 39 insertions, 10 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index ea58e2d76a..930523f4a7 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -221,7 +221,8 @@ public: /// \brief Open the specified file as a MemoryBuffer, returning a new /// MemoryBuffer if successful, otherwise returning null. llvm::MemoryBuffer *getBufferForFile(const FileEntry *Entry, - std::string *ErrorStr = 0); + std::string *ErrorStr = 0, + bool isVolatile = false); llvm::MemoryBuffer *getBufferForFile(StringRef Filename, std::string *ErrorStr = 0); diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 415b017b73..082cbb1fb1 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -128,14 +128,20 @@ namespace SrcMgr { /// When true, the original entry may be a virtual file that does not /// exist. unsigned BufferOverridden : 1; + + /// \brief True if this content cache was initially created for a source + /// file considered as a system one. + unsigned IsSystemFile : 1; ContentCache(const FileEntry *Ent = 0) : Buffer(0, false), OrigEntry(Ent), ContentsEntry(Ent), - SourceLineCache(0), NumLines(0), BufferOverridden(false) {} + SourceLineCache(0), NumLines(0), BufferOverridden(false), + IsSystemFile(false) {} ContentCache(const FileEntry *Ent, const FileEntry *contentEnt) : Buffer(0, false), OrigEntry(Ent), ContentsEntry(contentEnt), - SourceLineCache(0), NumLines(0), BufferOverridden(false) {} + SourceLineCache(0), NumLines(0), BufferOverridden(false), + IsSystemFile(false) {} ~ContentCache(); @@ -143,7 +149,8 @@ namespace SrcMgr { /// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory /// is not transferred, so this is a logical error. ContentCache(const ContentCache &RHS) - : Buffer(0, false), SourceLineCache(0), BufferOverridden(false) + : Buffer(0, false), SourceLineCache(0), BufferOverridden(false), + IsSystemFile(false) { OrigEntry = RHS.OrigEntry; ContentsEntry = RHS.ContentsEntry; @@ -534,6 +541,10 @@ class SourceManager : public RefCountedBase<SourceManager> { /// files, should report the original file name. Defaults to true. bool OverridenFilesKeepOriginalName; + /// \brief True if non-system source files should be treated as volatile + /// (likely to change while trying to use them). Defaults to false. + bool UserFilesAreVolatile; + struct OverriddenFilesInfoTy { /// \brief Files that have been overriden with the contents from another /// file. @@ -639,7 +650,8 @@ class SourceManager : public RefCountedBase<SourceManager> { explicit SourceManager(const SourceManager&); void operator=(const SourceManager&); public: - SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr); + SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr, + bool UserFilesAreVolatile = false); ~SourceManager(); void clearIDTables(); @@ -654,6 +666,10 @@ public: OverridenFilesKeepOriginalName = value; } + /// \brief True if non-system source files should be treated as volatile + /// (likely to change while trying to use them). + bool userFilesAreVolatile() const { return UserFilesAreVolatile; } + /// \brief Create the FileID for a memory buffer that will represent the /// FileID for the main source. /// @@ -706,7 +722,9 @@ public: FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID = 0, unsigned LoadedOffset = 0) { - const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile); + const SrcMgr::ContentCache * + IR = getOrCreateContentCache(SourceFile, + /*isSystemFile=*/FileCharacter != SrcMgr::C_User); assert(IR && "getOrCreateContentCache() cannot return NULL"); return createFileID(IR, IncludePos, FileCharacter, LoadedID, LoadedOffset); } @@ -1519,7 +1537,8 @@ private: int LoadedID, unsigned LoadedOffset); const SrcMgr::ContentCache * - getOrCreateContentCache(const FileEntry *SourceFile); + getOrCreateContentCache(const FileEntry *SourceFile, + bool isSystemFile = false); /// \brief Create a new ContentCache for the specified memory buffer. const SrcMgr::ContentCache* diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index afaf60e89a..8dd863e304 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -254,6 +254,10 @@ private: /// \brief Whether to include brief documentation within the set of code /// completions cached. bool IncludeBriefCommentsInCodeCompletion : 1; + + /// \brief True if non-system source files should be treated as volatile + /// (likely to change while trying to use them). + bool UserFilesAreVolatile : 1; /// \brief The language options used when we load an AST file. LangOptions ASTFileLangOpts; @@ -619,7 +623,8 @@ public: /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation. static ASTUnit *create(CompilerInvocation *CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - bool CaptureDiagnostics = false); + bool CaptureDiagnostics, + bool UserFilesAreVolatile); /// \brief Create a ASTUnit from an AST file. /// @@ -636,7 +641,8 @@ public: RemappedFile *RemappedFiles = 0, unsigned NumRemappedFiles = 0, bool CaptureDiagnostics = false, - bool AllowPCHWithCompilerErrors = false); + bool AllowPCHWithCompilerErrors = false, + bool UserFilesAreVolatile = false); private: /// \brief Helper function for \c LoadFromCompilerInvocation() and @@ -687,6 +693,7 @@ public: bool PrecompilePreamble = false, bool CacheCodeCompletionResults = false, bool IncludeBriefCommentsInCodeCompletion = false, + bool UserFilesAreVolatile = false, OwningPtr<ASTUnit> *ErrAST = 0); /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a @@ -707,7 +714,8 @@ public: bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false); + bool IncludeBriefCommentsInCodeCompletion = false, + bool UserFilesAreVolatile = false); /// LoadFromCommandLine - Create an ASTUnit from a vector of command line /// arguments, which must specify exactly one source file. @@ -742,6 +750,7 @@ public: bool IncludeBriefCommentsInCodeCompletion = false, bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, + bool UserFilesAreVolatile = false, OwningPtr<ASTUnit> *ErrAST = 0); /// \brief Reparse the source files using the same command-line options that |