summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/WhitespaceManager.h
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-06-11 16:01:49 +0000
committerAlexander Kornienko <alexfh@google.com>2013-06-11 16:01:49 +0000
commit555efc36d08b07e65e2aba65c91fcaec63834c29 (patch)
tree4084d1b79103bd7851ece8261c34c59ec040d62e /clang/lib/Format/WhitespaceManager.h
parent447d2d12f0d4a41feeb88341bddbaa79c36a5103 (diff)
downloadbcm5719-llvm-555efc36d08b07e65e2aba65c91fcaec63834c29.tar.gz
bcm5719-llvm-555efc36d08b07e65e2aba65c91fcaec63834c29.zip
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
Diffstat (limited to 'clang/lib/Format/WhitespaceManager.h')
-rw-r--r--clang/lib/Format/WhitespaceManager.h24
1 files changed, 13 insertions, 11 deletions
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);
OpenPOWER on IntegriCloud