summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 25acdd2600..33e63d9d40 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -35,6 +35,7 @@
#ifndef LLVM_CLANG_BASIC_SOURCEMANAGER_H
#define LLVM_CLANG_BASIC_SOURCEMANAGER_H
+#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/ArrayRef.h"
@@ -60,7 +61,6 @@ namespace clang {
class ASTReader;
class ASTWriter;
-class DiagnosticsEngine;
class LineTableInfo;
class SourceManager;
@@ -1815,6 +1815,28 @@ public:
}
};
+/// SourceManager and necessary depdencies (e.g. VFS, FileManager) for a single
+/// in-memorty file.
+class SourceManagerForFile {
+public:
+ /// Creates SourceManager and necessary depdencies (e.g. VFS, FileManager).
+ /// The main file in the SourceManager will be \p FileName with \p Content.
+ SourceManagerForFile(StringRef FileName, StringRef Content);
+
+ SourceManager &get() {
+ assert(SourceMgr);
+ return *SourceMgr;
+ }
+
+private:
+ // The order of these fields are important - they should be in the same order
+ // as they are created in `createSourceManagerForFile` so that they can be
+ // deleted in the reverse order as they are created.
+ std::unique_ptr<FileManager> FileMgr;
+ std::unique_ptr<DiagnosticsEngine> Diagnostics;
+ std::unique_ptr<SourceManager> SourceMgr;
+};
+
} // namespace clang
#endif // LLVM_CLANG_BASIC_SOURCEMANAGER_H