[cfe-commits] [PATCH] First version of a command line clang-format tool.
Manuel Klimek
klimek at google.com
Tue Dec 4 23:33:54 PST 2012
================
Comment at: clang-format/ClangFormat.cpp:44
@@ +43,3 @@
+ const FileEntry *Entry =
+ Files.getVirtualFile("file.cpp", Source->getBufferSize(), 0);
+ Sources.overrideFileContents(Entry, Source, true);
----------------
Perhaps call it "<stdin>" so it's clear that this isn't a file?
================
Comment at: clang-format/ClangFormat.cpp:55
@@ +54,3 @@
+ OwningPtr<MemoryBuffer> Code;
+ assert(!MemoryBuffer::getSTDIN(Code) && "Could not read stdin.");
+ FileID ID = createInMemoryFile(Code.get(), Sources, Files);
----------------
Won't that be a bad idea in a non-assert build?
================
Comment at: clang-format/ClangFormat.cpp:63
@@ +62,3 @@
+ SourceLocation End = Sources.getLocForEndOfFile(ID);
+ if (Length != - 1)
+ End = Start.getLocWithOffset(Length);
----------------
Please run an updated clang-format :D
http://llvm-reviews.chandlerc.com/D167
More information about the cfe-commits
mailing list