Insert a space at the start of a line comment in case it starts with an alphanumeric character.
Summary:
"//Test" becomes "// Test". This change is aimed to improve code
readability and conformance to certain coding styles. If a comment starts with a
non-alphanumeric character, the space isn't added, e.g. "//-*-c++-*-" stays
unchanged.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D949
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183750 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/WhitespaceManager.h b/lib/Format/WhitespaceManager.h
index 25b7690..11167fa 100644
--- a/lib/Format/WhitespaceManager.h
+++ b/lib/Format/WhitespaceManager.h
@@ -52,17 +52,19 @@
/// was not called.
void addUntouchableToken(const FormatToken &Tok, bool InPPDirective);
- /// \brief Inserts a line break into the middle of a token.
+ /// \brief Inserts or replaces whitespace in the middle of a token.
///
- /// Will break at \p Offset inside \p Tok, putting \p PreviousPostfix before
- /// the line break and \p CurrentPrefix before the rest of the token starts in
- /// the next line.
+ /// Inserts \p PreviousPostfix, \p Newlines, \p Spaces and \p CurrentPrefix
+ /// (in this order) at \p Offset inside \p Tok, replacing \p ReplaceChars
+ /// characters.
///
- /// \p InPPDirective and \p Spaces are used to generate the correct line
- /// break.
- void breakToken(const FormatToken &Tok, unsigned Offset,
- unsigned ReplaceChars, StringRef PreviousPostfix,
- StringRef CurrentPrefix, bool InPPDirective, unsigned Spaces);
+ /// When \p InPPDirective is true, escaped newlines are inserted. \p Spaces is
+ /// used to align backslashes correctly.
+ void replaceWhitespaceInToken(const FormatToken &Tok, unsigned Offset,
+ unsigned ReplaceChars,
+ StringRef PreviousPostfix,
+ StringRef CurrentPrefix, bool InPPDirective,
+ unsigned Newlines, unsigned Spaces);
/// \brief Returns all the \c Replacements created during formatting.
const tooling::Replacements &generateReplacements();
@@ -151,8 +153,8 @@
/// \brief Stores \p Text as the replacement for the whitespace in \p Range.
void storeReplacement(const SourceRange &Range, StringRef Text);
- std::string getNewLineText(unsigned NewLines, unsigned Spaces);
- std::string getNewLineText(unsigned NewLines, unsigned Spaces,
+ std::string getNewlineText(unsigned Newlines, unsigned Spaces);
+ std::string getNewlineText(unsigned Newlines, unsigned Spaces,
unsigned PreviousEndOfTokenColumn,
unsigned EscapedNewlineColumn);
std::string getIndentText(unsigned Spaces);