diff options
author | Szabolcs Sipos <szabolcs.sipos@ericsson.com> | 2015-05-29 09:49:59 +0000 |
---|---|---|
committer | Szabolcs Sipos <szabolcs.sipos@ericsson.com> | 2015-05-29 09:49:59 +0000 |
commit | 43a298cb36f8e05e9335bd3deb3214ef5bb99df8 (patch) | |
tree | 1e9c0ae7f5ca8c40e623b4a84aecc6056ab84421 /clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp | |
parent | e4770da766d675917b315145e1c54165ea73f9fb (diff) | |
download | llvm-43a298cb36f8e05e9335bd3deb3214ef5bb99df8.zip llvm-43a298cb36f8e05e9335bd3deb3214ef5bb99df8.tar.gz llvm-43a298cb36f8e05e9335bd3deb3214ef5bb99df8.tar.bz2 |
[clang-tidy] Fix for llvm.org/PR23355
misc-static-assert and misc-assert-side-effect will handle __builtin_expect based asserts correctly.
llvm-svn: 238548
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index ed9367c..1b6b897 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -41,15 +41,18 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) { IsAlwaysFalse); auto NonConstexprFunctionCall = callExpr(hasDeclaration(functionDecl(unless(isConstexpr())))); - auto Condition = expr(anyOf( + auto AssertCondition = expr(anyOf( expr(ignoringParenCasts(anyOf( AssertExprRoot, unaryOperator(hasUnaryOperand(ignoringParenCasts(AssertExprRoot)))))), - anything()), unless(findAll(NonConstexprFunctionCall))); + anything()), unless(findAll(NonConstexprFunctionCall))).bind("condition"); + auto Condition = anyOf(ignoringParenImpCasts(callExpr( + hasDeclaration(functionDecl(hasName("__builtin_expect"))), + hasArgument(0, AssertCondition))), AssertCondition); Finder->addMatcher( - stmt(anyOf(conditionalOperator(hasCondition(Condition.bind("condition"))), - ifStmt(hasCondition(Condition.bind("condition")))), + stmt(anyOf(conditionalOperator(hasCondition(Condition)), + ifStmt(hasCondition(Condition))), unless(isInTemplateInstantiation())).bind("condStmt"), this); } |