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/AssertSideEffectCheck.cpp | |
parent | e4770da766d675917b315145e1c54165ea73f9fb (diff) | |
download | bcm5719-llvm-43a298cb36f8e05e9335bd3deb3214ef5bb99df8.tar.gz bcm5719-llvm-43a298cb36f8e05e9335bd3deb3214ef5bb99df8.zip |
[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/AssertSideEffectCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp b/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp index 9d21b499ee9..fa589a4c759 100644 --- a/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp @@ -55,9 +55,13 @@ AST_MATCHER_P(Expr, hasSideEffect, bool, CheckFunctionCalls) { if (const auto *CExpr = dyn_cast<CallExpr>(E)) { bool Result = CheckFunctionCalls; - if (const auto *FuncDecl = CExpr->getDirectCallee()) - if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(FuncDecl)) + if (const auto *FuncDecl = CExpr->getDirectCallee()) { + if (FuncDecl->getDeclName().isIdentifier() && + FuncDecl->getName() == "__builtin_expect") // exceptions come here + Result = false; + else if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(FuncDecl)) Result &= !MethodDecl->isConst(); + } return Result; } |