summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatToken.h
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-08-06 14:15:41 +0000
committerDaniel Jasper <djasper@google.com>2014-08-06 14:15:41 +0000
commit78b1949950439959ecfd9185a13e42886dd712a2 (patch)
treef8cb432f5ceb88d8b0e33f0fbaf3b25a7384aa39 /clang/lib/Format/FormatToken.h
parentce5377afa0b74e1b972aa7d215487125648dec97 (diff)
downloadbcm5719-llvm-78b1949950439959ecfd9185a13e42886dd712a2.tar.gz
bcm5719-llvm-78b1949950439959ecfd9185a13e42886dd712a2.zip
clang-format: Correct SBPO_Always-behavior after function-like keywords
Before: auto f (int x) -> decltype(x) { return sizeof(x); } int g () noexcept(someCall ()); static_assert(sizeof(char) == 1, "Your compiler is broken"); After: auto f (int x) -> decltype (x) { return sizeof (x); } int g () noexcept (someCall ()); static_assert (sizeof (char) == 1, "Your compiler is broken"); This fixes llvm.org/PR20559. Patch by Roman Kashitsyn, thank you! llvm-svn: 214969
Diffstat (limited to 'clang/lib/Format/FormatToken.h')
-rw-r--r--clang/lib/Format/FormatToken.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index c376c500955..374c408dff5 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -353,6 +353,26 @@ struct FormatToken {
return is(tok::comment) && (!Next || Next->NewlinesBefore > 0);
}
+ /// \brief Returns \c true if this is a keyword that can be used
+ /// like a function call (e.g. sizeof, typeid, ...).
+ bool isFunctionLikeKeyword() const {
+ switch (Tok.getKind()) {
+ case tok::kw_throw:
+ case tok::kw_typeid:
+ case tok::kw_return:
+ case tok::kw_sizeof:
+ case tok::kw_alignof:
+ case tok::kw_alignas:
+ case tok::kw_decltype:
+ case tok::kw_noexcept:
+ case tok::kw_static_assert:
+ case tok::kw___attribute:
+ return true;
+ default:
+ return false;
+ }
+ }
+
prec::Level getPrecedence() const {
return getBinOpPrecedence(Tok.getKind(), true, true);
}
OpenPOWER on IntegriCloud