From 43a298cb36f8e05e9335bd3deb3214ef5bb99df8 Mon Sep 17 00:00:00 2001 From: Szabolcs Sipos Date: Fri, 29 May 2015 09:49:59 +0000 Subject: [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 --- clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp') 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(E)) { bool Result = CheckFunctionCalls; - if (const auto *FuncDecl = CExpr->getDirectCallee()) - if (const auto *MethodDecl = dyn_cast(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(FuncDecl)) Result &= !MethodDecl->isConst(); + } return Result; } -- cgit v1.2.3