[cfe-commits] [PATCH] Initial version of formatting library
Sean Silva
silvas at purdue.edu
Fri Nov 16 17:10:14 PST 2012
================
Comment at: include/clang/Format/Format.h:9-15
@@ +8,9 @@
+//===----------------------------------------------------------------------===//
+//
+// \file
+// Various functions to configurably format source code.
+//
+// This is EXPERIMENTAL code under heavy development. It is not in a state yet,
+// where it can be used to format real code.
+//
+//===----------------------------------------------------------------------===//
----------------
I think these are supposed to be `///` in order for doxygen to pick them up.
================
Comment at: lib/Format/Format.cpp:107-108
@@ +106,4 @@
+ Line.Tokens[Index].Tok);
+ //if (Line.Tokens[Index].NewlinesBefore == 0)
+ // Space = Line.Tokens[Index].WhiteSpaceLength > 0;
+ if (!DryRun)
----------------
Delete.
================
Comment at: lib/Format/Format.cpp:49
@@ +48,3 @@
+ // Start iterating at 1 as we have correctly formatted of Token #0 above.
+ for (unsigned i = 1, n = Line.Tokens.size(); i != n; ++i) {
+ bool InsertNewLine = Line.Tokens[i].NewlinesBefore > 0;
----------------
These variables should be capitalized.
================
Comment at: lib/Format/UnwrappedLineParser.cpp:65
@@ +64,3 @@
+ --Line.Level;
+ if (FormatTok.Tok.getKind() != tok::r_brace) abort();
+ nextToken();
----------------
assert. grep for calls to abort() and replace with assertions.
================
Comment at: lib/Format/UnwrappedLineParser.cpp:74
@@ +73,3 @@
+ nextToken();
+ if (FormatTok.NewlinesBefore > 0) return;
+ }
----------------
these oneline if's are kind of confusing. Also, they don't seem to be endemic to the codebase. I believe Dmitri already voiced some concern over this. To avoid going against the grain, it's probably best to just change all of the one statement ifs to have their body on its own line.
http://llvm-reviews.chandlerc.com/D80
More information about the cfe-commits
mailing list