diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-01-02 15:13:14 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-01-02 15:13:14 +0000 |
commit | ce9161a5575504df72321c14bb5bcd3f33592c5d (patch) | |
tree | f38c8522dbb7c288ae3b9e0c7fd790601a5bdcc7 /clang/lib/Format/ContinuationIndenter.cpp | |
parent | e83b9060cb913bd687fb5a78298404f8283cf3cb (diff) | |
download | bcm5719-llvm-ce9161a5575504df72321c14bb5bcd3f33592c5d.tar.gz bcm5719-llvm-ce9161a5575504df72321c14bb5bcd3f33592c5d.zip |
Added an option to avoid splitting certain kinds of comments into lines.
Summary: Added CommentPragmas option for this.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2460
llvm-svn: 198310
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index d4bf6ecfa91..872545660ca 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -63,7 +63,8 @@ ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style, bool BinPackInconclusiveFunctions) : Style(Style), SourceMgr(SourceMgr), Whitespaces(Whitespaces), Encoding(Encoding), - BinPackInconclusiveFunctions(BinPackInconclusiveFunctions) {} + BinPackInconclusiveFunctions(BinPackInconclusiveFunctions), + CommentPragmasRegex(Style.CommentPragmas) {} LineState ContinuationIndenter::getInitialState(unsigned FirstIndent, const AnnotatedLine *Line, @@ -810,12 +811,16 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, return 0; } } else if (Current.Type == TT_BlockComment && Current.isTrailingComment()) { + if (CommentPragmasRegex.match(Current.TokenText.substr(2))) + return 0; Token.reset(new BreakableBlockComment( Current, State.Line->Level, StartColumn, Current.OriginalColumn, !Current.Previous, State.Line->InPPDirective, Encoding, Style)); } else if (Current.Type == TT_LineComment && (Current.Previous == NULL || Current.Previous->Type != TT_ImplicitStringLiteral)) { + if (CommentPragmasRegex.match(Current.TokenText.substr(2))) + return 0; Token.reset(new BreakableLineComment(Current, State.Line->Level, StartColumn, /*InPPDirective=*/false, Encoding, Style)); |