Skip to content

Fix clang-analyzer-core.uninitialized.Branch warnings #59

Description

@igormunkin

As a result of updating clang-tidy up to version 11, new check clang-analyzer-core.uninitialized.Branch produced several warnings.

/luavela/src/jit/lj_asm_x86.h:291:9: error: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch,-warnings-as-errors]
    if (args[i] && irt_isfp(IR(args[i])->t)) {
        ^
/luavela/src/jit/lj_asm.c:1328:47: note: Assuming 'ir' is >= 'lastir'
  for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++)
                                              ^
/luavela/src/jit/lj_asm.c:1328:3: note: Loop condition is false. Execution continues on line 1332
  for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++)
  ^
/luavela/src/jit/lj_asm.c:1335:7: note: Assuming field 'o' is not equal to IR_RENAME
  if (ir->o == IR_RENAME) {
      ^
/luavela/src/jit/lj_asm.c:1335:3: note: Taking false branch
  if (ir->o == IR_RENAME) {
  ^
/luavela/src/jit/lj_asm.c:1349:7: note: Assuming field 'parent' is null
  if (as->parent) {
      ^
/luavela/src/jit/lj_asm.c:1349:3: note: Taking false branch
  if (as->parent) {
  ^
/luavela/src/jit/lj_asm.c:1367:27: note: Assuming 'ir' is < 'lastir'
  for (lastir = IR(nins); ir < lastir; ir++) {
                          ^
/luavela/src/jit/lj_asm.c:1367:3: note: Loop condition is true.  Entering loop body
  for (lastir = IR(nins); ir < lastir; ir++) {
  ^
/luavela/src/jit/lj_asm.c:1368:9: note: Assuming 'sink' is 0
    if (sink) {
        ^
/luavela/src/jit/lj_asm.c:1368:5: note: Taking false branch
    if (sink) {
    ^
/luavela/src/jit/lj_asm.c:1376:5: note: Control jumps to 'case IR_CALLXS:'  at line 1380
    switch (ir->o) {
    ^
/luavela/src/jit/lj_asm.c:1383:18: note: Calling 'asm_setup_call_slots'
      ir->prev = asm_setup_call_slots(as, ir, &ci);
                 ^
/luavela/src/jit/lj_asm_x86.h:2587:3: note: Calling 'asm_collectargs'
  asm_collectargs(as, ir, ci, args);
  ^
/luavela/src/jit/lj_asm.c:710:14: note: Assuming the condition is true
  lua_assert(n <= CCI_NARGS_MAX*2);  /* Account for split args. */
             ^
/luavela/src/luaconf.h:25:36: note: expanded from macro 'lua_assert'
#define lua_assert(c)       assert(c)
                                   ^
/usr/include/assert.h:98:7: note: expanded from macro 'assert'  
    ((expr)                                                             \
      ^
/luavela/src/jit/lj_asm.c:710:3: note: '?' condition is true
  lua_assert(n <= CCI_NARGS_MAX*2);  /* Account for split args. */
  ^
/luavela/src/luaconf.h:25:29: note: expanded from macro 'lua_assert'
#define lua_assert(c)       assert(c)
                            ^
/usr/include/assert.h:98:6: note: expanded from macro 'assert'  
    ((expr)                                                             \
     ^
/luavela/src/jit/lj_asm.c:711:8: note: Assuming the condition is true
  if ((ci->flags & CCI_L)) { *args++ = ASMREF_L; n--; }
       ^
/luavela/src/jit/lj_asm.c:711:3: note: Taking true branch
  if ((ci->flags & CCI_L)) { *args++ = ASMREF_L; n--; }
  ^
/luavela/src/jit/lj_asm.c:712:10: note: Assuming the condition is true
  while (n-- > 1) {
         ^
/luavela/src/jit/lj_asm.c:712:3: note: Loop condition is true.  Entering loop body
  while (n-- > 1) {
  ^
/luavela/src/jit/lj_asm.c:714:16: note: Assuming field 'o' is equal to IR_CARG
    lua_assert(ir->o == IR_CARG);
               ^
/luavela/src/luaconf.h:25:36: note: expanded from macro 'lua_assert'
#define lua_assert(c)       assert(c)
                                   ^
/usr/include/assert.h:98:7: note: expanded from macro 'assert'  
    ((expr)                                                             \
      ^
/luavela/src/jit/lj_asm.c:714:5: note: '?' condition is true
    lua_assert(ir->o == IR_CARG);
    ^
/luavela/src/luaconf.h:25:29: note: expanded from macro 'lua_assert'
#define lua_assert(c)       assert(c)
                            ^
/usr/include/assert.h:98:6: note: expanded from macro 'assert'  
    ((expr)                                                             \
     ^
/luavela/src/jit/lj_asm.c:715:15: note: Assuming field 'op2' is equal to REF_NIL
    args[n] = ir->op2 == REF_NIL ? 0 : ir->op2;
              ^
/luavela/src/jit/lj_asm.c:715:15: note: '?' condition is true
/luavela/src/jit/lj_asm.c:712:10: note: Assuming the condition is false
  while (n-- > 1) {
         ^
/luavela/src/jit/lj_asm.c:712:3: note: Loop condition is false. Execution continues on line 717
  while (n-- > 1) {
  ^
/luavela/src/jit/lj_asm.c:717:13: note: Assuming field 'op1' is not equal to REF_NIL
  args[0] = ir->op1 == REF_NIL ? 0 : ir->op1;
            ^
/luavela/src/jit/lj_asm.c:717:13: note: '?' condition is false
/luavela/src/jit/lj_asm.c:718:14: note: Assuming field 'o' is not equal to IR_CARG
  lua_assert(IR(ir->op1)->o != IR_CARG);
             ^
/luavela/src/jit/lj_asm.c:37:33: note: expanded from macro 'IR'
#define IR(ref)                 (&as->ir[(ref)])
                                ^
/luavela/src/luaconf.h:25:36: note: expanded from macro 'lua_assert'
#define lua_assert(c)       assert(c)
                                   ^
/usr/include/assert.h:98:7: note: expanded from macro 'assert'  
    ((expr)                                                             \
      ^
/luavela/src/jit/lj_asm.c:718:3: note: '?' condition is true
  lua_assert(IR(ir->op1)->o != IR_CARG);
  ^
/luavela/src/luaconf.h:25:29: note: expanded from macro 'lua_assert'
#define lua_assert(c)       assert(c)
                            ^
/usr/include/assert.h:98:6: note: expanded from macro 'assert'  
    ((expr)                                                             \
     ^
/luavela/src/jit/lj_asm_x86.h:2587:3: note: Returning from 'asm_collectargs'
  asm_collectargs(as, ir, ci, args);
  ^
/luavela/src/jit/lj_asm_x86.h:2588:12: note: Calling 'asm_count_call_slots'
  nslots = asm_count_call_slots(as, ci, args);
           ^
/luavela/src/jit/lj_asm_x86.h:290:3: note: Loop condition is true.  Entering loop body
  for (i = 0; i < nargs; i++) {
  ^
/luavela/src/jit/lj_asm_x86.h:291:9: note: Left side of '&&' is true
    if (args[i] && irt_isfp(IR(args[i])->t)) {
        ^
/luavela/src/jit/lj_asm_x86.h:291:20: note: Assuming the condition is true
    if (args[i] && irt_isfp(IR(args[i])->t)) {
                   ^
/luavela/src/jit/lj_ir.h:384:34: note: expanded from macro 'irt_isfp'
#define irt_isfp(t)             (irt_isnum(t) || irt_isfloat(t))
                                 ^
/luavela/src/jit/lj_ir.h:373:34: note: expanded from macro 'irt_isnum'
#define irt_isnum(t)            (irt_type(t) == IRT_NUM)
                                 ^
/luavela/src/jit/lj_ir.h:360:33: note: expanded from macro 'irt_type'
#define irt_type(t)             ((IRType)((t).irt & IRT_TYPE))  
                                ^
/luavela/src/jit/lj_asm_x86.h:291:20: note: Left side of '||' is true
    if (args[i] && irt_isfp(IR(args[i])->t)) {
                   ^
/luavela/src/jit/lj_ir.h:384:47: note: expanded from macro 'irt_isfp'
#define irt_isfp(t)             (irt_isnum(t) || irt_isfloat(t))
                                              ^
/luavela/src/jit/lj_asm_x86.h:292:11: note: 'nfpr' is > 0
      if (nfpr > 0) nfpr--; else nslots += 2;
          ^
/luavela/src/jit/lj_asm_x86.h:292:7: note: Taking true branch
      if (nfpr > 0) nfpr--; else nslots += 2;
      ^
/luavela/src/jit/lj_asm_x86.h:290:3: note: Loop condition is true.  Entering loop body
  for (i = 0; i < nargs; i++) {
  ^
/luavela/src/jit/lj_asm_x86.h:291:9: note: Assuming the condition is false
    if (args[i] && irt_isfp(IR(args[i])->t)) {
        ^
/luavela/src/jit/lj_asm_x86.h:291:17: note: Left side of '&&' is false
    if (args[i] && irt_isfp(IR(args[i])->t)) {
                ^
/luavela/src/jit/lj_asm_x86.h:294:11: note: 'ngpr' is > 0
      if (ngpr > 0) ngpr--; else nslots += 2;
          ^
/luavela/src/jit/lj_asm_x86.h:294:7: note: Taking true branch
      if (ngpr > 0) ngpr--; else nslots += 2;
      ^
/luavela/src/jit/lj_asm_x86.h:290:26: note: The value 2 is assigned to 'i'
  for (i = 0; i < nargs; i++) {
                         ^
/luavela/src/jit/lj_asm_x86.h:290:3: note: Loop condition is true.  Entering loop body
  for (i = 0; i < nargs; i++) {
  ^
/luavela/src/jit/lj_asm_x86.h:291:9: note: Branch condition evaluates to a garbage value
    if (args[i] && irt_isfp(IR(args[i])->t)) {
        ^

All the warnings should be verified whether any of them found the real bug or it's just a false positive.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions