summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-02-06 16:40:56 +0000
committerManuel Klimek <klimek@google.com>2013-02-06 16:40:56 +0000
commit82b836a61dc4be6a7b64e9df06dddee62ffe39bc (patch)
treeae76be00ea68cbcb751da7636e8b0b2938f462f4 /clang/lib
parent85cc9b655d958e9d0b8f47d27f82ea3426c26f5d (diff)
downloadbcm5719-llvm-82b836a61dc4be6a7b64e9df06dddee62ffe39bc.tar.gz
bcm5719-llvm-82b836a61dc4be6a7b64e9df06dddee62ffe39bc.zip
Fix handling of comments in macros.
We now correctly format: // Written as a macro, it is reformatted from: #define foo(a) \ do { \ /* Initialize num to zero. */ \ int num = 10; \ /* This line ensures a is never zero. */ \ int i = a == 0 ? 1 : a; \ i = num / i; /* This division is OK. */ \ return i; \ } while (false) llvm-svn: 174517
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 5af60a47c59..76e912cca5e 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -784,7 +784,7 @@ void UnwrappedLineParser::flushComments(bool NewlineBeforeNext) {
I = CommentsBeforeNextToken.begin(),
E = CommentsBeforeNextToken.end();
I != E; ++I) {
- if (I->HasUnescapedNewline && JustComments) {
+ if (I->NewlinesBefore && JustComments) {
addUnwrappedLine();
}
pushToken(*I);
@@ -798,7 +798,7 @@ void UnwrappedLineParser::flushComments(bool NewlineBeforeNext) {
void UnwrappedLineParser::nextToken() {
if (eof())
return;
- flushComments(FormatTok.HasUnescapedNewline);
+ flushComments(FormatTok.NewlinesBefore > 0);
pushToken(FormatTok);
readToken();
}
@@ -819,7 +819,7 @@ void UnwrappedLineParser::readToken() {
}
if (!FormatTok.Tok.is(tok::comment))
return;
- if (FormatTok.HasUnescapedNewline || FormatTok.IsFirst) {
+ if (FormatTok.NewlinesBefore > 0 || FormatTok.IsFirst) {
CommentsInCurrentLine = false;
}
if (CommentsInCurrentLine) {
OpenPOWER on IntegriCloud