aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-13 08:01:36 +0000
committerDaniel Jasper <djasper@google.com>2013-01-13 08:01:36 +0000
commit4981bd0ca215570ef1e2e1c1c64a2c399069dc42 (patch)
tree8609a1c7cea041e660bc9d6f7ea3f8ab781e579d /lib/Format/Format.cpp
parent377b8c66b48b01fdd3f308d33f49af64ad632e87 (diff)
Improve identification of c-style casts.
A ")" before any of "=", "{" or ";" won't be a cast. This fixes issues with the formatting of unnamed parameters. Before: void f(int *){} After: void f(int *) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r--lib/Format/Format.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 29debe58b6..5de1717911 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -976,7 +976,11 @@ private:
Current.Type = TT_BlockComment;
} else if (Current.is(tok::r_paren) &&
(Current.Parent->Type == TT_PointerOrReference ||
- Current.Parent->Type == TT_TemplateCloser)) {
+ Current.Parent->Type == TT_TemplateCloser) &&
+ (Current.Children.empty() ||
+ (Current.Children[0].isNot(tok::equal) &&
+ Current.Children[0].isNot(tok::semi) &&
+ Current.Children[0].isNot(tok::l_brace)))) {
// FIXME: We need to get smarter and understand more cases of casts.
Current.Type = TT_CastRParen;
} else if (Current.is(tok::at) && Current.Children.size()) {