[cfe-commits] [clang-tools-extra] r172405 - /clang-tools-extra/trunk/clang-format/ClangFormat.cpp

Alexander Kornienko alexfh at google.com
Mon Jan 14 05:40:44 PST 2013


Author: alexfh
Date: Mon Jan 14 07:40:44 2013
New Revision: 172405

URL: http://llvm.org/viewvc/llvm-project?rev=172405&view=rev
Log:
Fix: correct file name in diagnostics.

Modified:
    clang-tools-extra/trunk/clang-format/ClangFormat.cpp

Modified: clang-tools-extra/trunk/clang-format/ClangFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-format/ClangFormat.cpp?rev=172405&r1=172404&r2=172405&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-format/ClangFormat.cpp (original)
+++ clang-tools-extra/trunk/clang-format/ClangFormat.cpp Mon Jan 14 07:40:44 2013
@@ -44,10 +44,11 @@
 namespace clang {
 namespace format {
 
-static FileID createInMemoryFile(const MemoryBuffer *Source,
+static FileID createInMemoryFile(StringRef FileName, const MemoryBuffer *Source,
                                  SourceManager &Sources, FileManager &Files) {
-  const FileEntry *Entry =
-      Files.getVirtualFile("<stdio>", Source->getBufferSize(), 0);
+  const FileEntry *Entry = Files.getVirtualFile(FileName == "-" ? "<stdin>" :
+                                                    FileName,
+                                                Source->getBufferSize(), 0);
   Sources.overrideFileContents(Entry, Source, true);
   return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
 }
@@ -63,7 +64,7 @@
     llvm::errs() << ec.message() << "\n";
     return;
   }
-  FileID ID = createInMemoryFile(Code.get(), Sources, Files);
+  FileID ID = createInMemoryFile(FileName, Code.get(), Sources, Files);
   Lexer Lex(ID, Sources.getBuffer(ID), Sources, getFormattingLangOpts());
   SourceLocation Start =
       Sources.getLocForStartOfFile(ID).getLocWithOffset(Offset);





More information about the cfe-commits mailing list