summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-07-27 02:41:40 +0000
committerNico Weber <nicolasweber@gmx.de>2019-07-27 02:41:40 +0000
commit1361a4c2d8b000c3e9441f956b8213e4c6d37075 (patch)
treece7ea5330099a981ab8773f3ccf1de425f68e698 /clang/lib/Format/UnwrappedLineParser.cpp
parent92a2e1bbb900cb0ba24ed2d441baebff0ce88988 (diff)
downloadbcm5719-llvm-1361a4c2d8b000c3e9441f956b8213e4c6d37075.tar.gz
bcm5719-llvm-1361a4c2d8b000c3e9441f956b8213e4c6d37075.zip
clang-format: Support `if CONSTEXPR` if CONSTEXPR is a macro.
This is like r305666 (which added support for `if constexpr`) except that it allows a macro name after the if. This is slightly tricky for two reasons: 1. r305666 didn't add test coverage for all cases where it added a kw_constexpr, so I had to figure out what all the added cases were for. I now added tests for all `if constexpr` bits that didn't have tests. (This took a while, see e.g. https://reviews.llvm.org/D65223) 2. Parsing `if <ident> (` as an if means that `#if defined(` and `#if __has_include(` parse as ifs too. Add some special-case code to prevent this from happening where it's incorrect. Fixes PR39248. Differential Revision: https://reviews.llvm.org/D65227 llvm-svn: 367167
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 33d0563d942..8a3a9bd5809 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1756,7 +1756,7 @@ void UnwrappedLineParser::parseSquare(bool LambdaIntroducer) {
void UnwrappedLineParser::parseIfThenElse() {
assert(FormatTok->Tok.is(tok::kw_if) && "'if' expected");
nextToken();
- if (FormatTok->Tok.is(tok::kw_constexpr))
+ if (FormatTok->Tok.isOneOf(tok::kw_constexpr, tok::identifier))
nextToken();
if (FormatTok->Tok.is(tok::l_paren))
parseParens();
OpenPOWER on IntegriCloud