From 555efc36d08b07e65e2aba65c91fcaec63834c29 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Tue, 11 Jun 2013 16:01:49 +0000 Subject: 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 llvm-svn: 183750 --- clang/lib/Format/WhitespaceManager.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'clang/lib/Format/WhitespaceManager.h') diff --git a/clang/lib/Format/WhitespaceManager.h b/clang/lib/Format/WhitespaceManager.h index 25b7690a154..11167fa4c3c 100644 --- a/clang/lib/Format/WhitespaceManager.h +++ b/clang/lib/Format/WhitespaceManager.h @@ -52,17 +52,19 @@ public: /// 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 @@ private: /// \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); -- cgit v1.2.3