[all-commits] [llvm/llvm-project] 4d4d90: Fix warning caused by __builtin_expect_with_probab...

Erich Keane via All-commits all-commits at lists.llvm.org
Thu Jul 9 08:01:59 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 4d4d9037670a3537c14092807a717284ea0c4f92
      https://github.com/llvm/llvm-project/commit/4d4d9037670a3537c14092807a717284ea0c4f92
  Author: Zhi Zhuang <Zhi.Zhuang at mediatek.com>
  Date:   2020-07-09 (Thu, 09 Jul 2020)

  Changed paths:
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
    M clang/test/Sema/builtin-expect-with-probability.cpp

  Log Message:
  -----------
  Fix warning caused by __builtin_expect_with_probability was not handled
in places such as constant folding

Previously some places that should have handled
__builtin_expect_with_probability is missing, so in some case it acts
differently than __builtin_expect.
For example it was not handled in constant folding, thus in the
following program, the "if" condition should be constantly true and
folded, but previously it was not handled and cause warning "control may
reach end of non-void function" (while __builtin_expect does not):

__attribute__((noreturn)) extern void bar();
int foo(int x, int y) {
  if (y) {
    if (__builtin_expect_with_probability(1, 1, 1))
      bar();
  }
  else
    return 0;
}

Now it's fixed.

Differential Revisions: https://reviews.llvm.org/D83362




More information about the All-commits mailing list