Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer
for completeness and use it in CompilerInstance::InitializeSourceManager if
the input is a memory buffer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167628 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 9e7b630..22a74fc 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -600,10 +600,18 @@
FileManager &FileMgr,
SourceManager &SourceMgr,
const FrontendOptions &Opts) {
- StringRef InputFile = Input.getFile();
SrcMgr::CharacteristicKind
Kind = Input.isSystem() ? SrcMgr::C_System : SrcMgr::C_User;
+ if (Input.isBuffer()) {
+ SourceMgr.createMainFileIDForMemBuffer(Input.getBuffer(), Kind);
+ assert(!SourceMgr.getMainFileID().isInvalid() &&
+ "Couldn't establish MainFileID!");
+ return true;
+ }
+
+ StringRef InputFile = Input.getFile();
+
// Figure out where to get and map in the main file.
if (InputFile != "-") {
const FileEntry *File = FileMgr.getFile(InputFile);