diff options
author | Clement Courbet <courbet@google.com> | 2018-12-11 07:04:49 +0000 |
---|---|---|
committer | Clement Courbet <courbet@google.com> | 2018-12-11 07:04:49 +0000 |
commit | 67b03de9a2d354d41eb88a801e16a7df193f1de2 (patch) | |
tree | 006ea2adba999881bf31366d64a7986828ad594b /clang/lib/Sema/SemaTemplate.cpp | |
parent | f17c5f6ba6a2764b0d8d17fdd2b0700dff2e2753 (diff) | |
download | bcm5719-llvm-67b03de9a2d354d41eb88a801e16a7df193f1de2.tar.gz bcm5719-llvm-67b03de9a2d354d41eb88a801e16a7df193f1de2.zip |
[Sema]improve static_assert(!expr)
llvm-svn: 348830
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 56302d62484..cb6e32fc5e5 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3071,6 +3071,20 @@ static void prettyPrintFailedBooleanCondition(llvm::raw_string_ostream &OS, } return; } + if (const auto *Paren = dyn_cast<ParenExpr>(FailedCond)) { + OS << "("; + prettyPrintFailedBooleanCondition(OS, Paren->getSubExpr(), Policy); + OS << ")"; + return; + } + // If this is !(BooleanExpression), try pretty-printing the inner expression. + const auto *UnaryOp = dyn_cast<UnaryOperator>(FailedCond); + if (UnaryOp && UnaryOp->getOpcode() == UO_LNot) { + OS << "!"; + prettyPrintFailedBooleanCondition(OS, UnaryOp->getSubExpr(), Policy); + return; + } + FailedCond->printPretty(OS, nullptr, Policy); } |