From 6566e23e131ae73c9724152ce9797cd9a6a4401f Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 9 Nov 2012 19:40:45 +0000 Subject: Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer for completeness and use it in CompilerInstance::InitializeSourceManager if the input is a memory buffer. llvm-svn: 167628 --- clang/lib/Frontend/CompilerInstance.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'clang/lib/Frontend/CompilerInstance.cpp') diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 9e7b630bf1a..22a74fcc35d 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -600,10 +600,18 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, 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); -- cgit v1.2.3